babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501
  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. * Defines if the texture contains multiview data
  6287. */
  6288. isMultiview: boolean;
  6289. /**
  6290. * Gets the URL used to load this texture
  6291. */
  6292. url: string;
  6293. /**
  6294. * Gets the sampling mode of the texture
  6295. */
  6296. samplingMode: number;
  6297. /**
  6298. * Gets a boolean indicating if the texture needs mipmaps generation
  6299. */
  6300. generateMipMaps: boolean;
  6301. /**
  6302. * Gets the number of samples used by the texture (WebGL2+ only)
  6303. */
  6304. samples: number;
  6305. /**
  6306. * Gets the type of the texture (int, float...)
  6307. */
  6308. type: number;
  6309. /**
  6310. * Gets the format of the texture (RGB, RGBA...)
  6311. */
  6312. format: number;
  6313. /**
  6314. * Observable called when the texture is loaded
  6315. */
  6316. onLoadedObservable: Observable<InternalTexture>;
  6317. /**
  6318. * Gets the width of the texture
  6319. */
  6320. width: number;
  6321. /**
  6322. * Gets the height of the texture
  6323. */
  6324. height: number;
  6325. /**
  6326. * Gets the depth of the texture
  6327. */
  6328. depth: number;
  6329. /**
  6330. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6331. */
  6332. baseWidth: number;
  6333. /**
  6334. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6335. */
  6336. baseHeight: number;
  6337. /**
  6338. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6339. */
  6340. baseDepth: number;
  6341. /**
  6342. * Gets a boolean indicating if the texture is inverted on Y axis
  6343. */
  6344. invertY: boolean;
  6345. /**
  6346. * Gets or set the previous tracker in the list
  6347. */
  6348. previous: Nullable<IInternalTextureTracker>;
  6349. /**
  6350. * Gets or set the next tracker in the list
  6351. */
  6352. next: Nullable<IInternalTextureTracker>;
  6353. /** @hidden */
  6354. _invertVScale: boolean;
  6355. /** @hidden */
  6356. _initialSlot: number;
  6357. /** @hidden */
  6358. _designatedSlot: number;
  6359. /** @hidden */
  6360. _dataSource: number;
  6361. /** @hidden */
  6362. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6363. /** @hidden */
  6364. _bufferView: Nullable<ArrayBufferView>;
  6365. /** @hidden */
  6366. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6367. /** @hidden */
  6368. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6369. /** @hidden */
  6370. _size: number;
  6371. /** @hidden */
  6372. _extension: string;
  6373. /** @hidden */
  6374. _files: Nullable<string[]>;
  6375. /** @hidden */
  6376. _workingCanvas: HTMLCanvasElement;
  6377. /** @hidden */
  6378. _workingContext: CanvasRenderingContext2D;
  6379. /** @hidden */
  6380. _framebuffer: Nullable<WebGLFramebuffer>;
  6381. /** @hidden */
  6382. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6383. /** @hidden */
  6384. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6385. /** @hidden */
  6386. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6387. /** @hidden */
  6388. _attachments: Nullable<number[]>;
  6389. /** @hidden */
  6390. _cachedCoordinatesMode: Nullable<number>;
  6391. /** @hidden */
  6392. _cachedWrapU: Nullable<number>;
  6393. /** @hidden */
  6394. _cachedWrapV: Nullable<number>;
  6395. /** @hidden */
  6396. _cachedWrapR: Nullable<number>;
  6397. /** @hidden */
  6398. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6399. /** @hidden */
  6400. _isDisabled: boolean;
  6401. /** @hidden */
  6402. _compression: Nullable<string>;
  6403. /** @hidden */
  6404. _generateStencilBuffer: boolean;
  6405. /** @hidden */
  6406. _generateDepthBuffer: boolean;
  6407. /** @hidden */
  6408. _comparisonFunction: number;
  6409. /** @hidden */
  6410. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6411. /** @hidden */
  6412. _lodGenerationScale: number;
  6413. /** @hidden */
  6414. _lodGenerationOffset: number;
  6415. /** @hidden */
  6416. _colorTextureArray: Nullable<WebGLTexture>;
  6417. /** @hidden */
  6418. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6419. /** @hidden */
  6420. _lodTextureHigh: BaseTexture;
  6421. /** @hidden */
  6422. _lodTextureMid: BaseTexture;
  6423. /** @hidden */
  6424. _lodTextureLow: BaseTexture;
  6425. /** @hidden */
  6426. _isRGBD: boolean;
  6427. /** @hidden */
  6428. _webGLTexture: Nullable<WebGLTexture>;
  6429. /** @hidden */
  6430. _references: number;
  6431. private _engine;
  6432. /**
  6433. * Gets the Engine the texture belongs to.
  6434. * @returns The babylon engine
  6435. */
  6436. getEngine(): Engine;
  6437. /**
  6438. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6439. */
  6440. readonly dataSource: number;
  6441. /**
  6442. * Creates a new InternalTexture
  6443. * @param engine defines the engine to use
  6444. * @param dataSource defines the type of data that will be used
  6445. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6446. */
  6447. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6448. /**
  6449. * Increments the number of references (ie. the number of Texture that point to it)
  6450. */
  6451. incrementReferences(): void;
  6452. /**
  6453. * Change the size of the texture (not the size of the content)
  6454. * @param width defines the new width
  6455. * @param height defines the new height
  6456. * @param depth defines the new depth (1 by default)
  6457. */
  6458. updateSize(width: int, height: int, depth?: int): void;
  6459. /** @hidden */
  6460. _rebuild(): void;
  6461. /** @hidden */
  6462. _swapAndDie(target: InternalTexture): void;
  6463. /**
  6464. * Dispose the current allocated resources
  6465. */
  6466. dispose(): void;
  6467. }
  6468. }
  6469. declare module "babylonjs/Animations/easing" {
  6470. /**
  6471. * This represents the main contract an easing function should follow.
  6472. * Easing functions are used throughout the animation system.
  6473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6474. */
  6475. export interface IEasingFunction {
  6476. /**
  6477. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6478. * of the easing function.
  6479. * The link below provides some of the most common examples of easing functions.
  6480. * @see https://easings.net/
  6481. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6482. * @returns the corresponding value on the curve defined by the easing function
  6483. */
  6484. ease(gradient: number): number;
  6485. }
  6486. /**
  6487. * Base class used for every default easing function.
  6488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6489. */
  6490. export class EasingFunction implements IEasingFunction {
  6491. /**
  6492. * Interpolation follows the mathematical formula associated with the easing function.
  6493. */
  6494. static readonly EASINGMODE_EASEIN: number;
  6495. /**
  6496. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6497. */
  6498. static readonly EASINGMODE_EASEOUT: number;
  6499. /**
  6500. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6501. */
  6502. static readonly EASINGMODE_EASEINOUT: number;
  6503. private _easingMode;
  6504. /**
  6505. * Sets the easing mode of the current function.
  6506. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6507. */
  6508. setEasingMode(easingMode: number): void;
  6509. /**
  6510. * Gets the current easing mode.
  6511. * @returns the easing mode
  6512. */
  6513. getEasingMode(): number;
  6514. /**
  6515. * @hidden
  6516. */
  6517. easeInCore(gradient: number): number;
  6518. /**
  6519. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6520. * of the easing function.
  6521. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6522. * @returns the corresponding value on the curve defined by the easing function
  6523. */
  6524. ease(gradient: number): number;
  6525. }
  6526. /**
  6527. * Easing function with a circle shape (see link below).
  6528. * @see https://easings.net/#easeInCirc
  6529. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6530. */
  6531. export class CircleEase extends EasingFunction implements IEasingFunction {
  6532. /** @hidden */
  6533. easeInCore(gradient: number): number;
  6534. }
  6535. /**
  6536. * Easing function with a ease back shape (see link below).
  6537. * @see https://easings.net/#easeInBack
  6538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6539. */
  6540. export class BackEase extends EasingFunction implements IEasingFunction {
  6541. /** Defines the amplitude of the function */
  6542. amplitude: number;
  6543. /**
  6544. * Instantiates a back ease easing
  6545. * @see https://easings.net/#easeInBack
  6546. * @param amplitude Defines the amplitude of the function
  6547. */
  6548. constructor(
  6549. /** Defines the amplitude of the function */
  6550. amplitude?: number);
  6551. /** @hidden */
  6552. easeInCore(gradient: number): number;
  6553. }
  6554. /**
  6555. * Easing function with a bouncing shape (see link below).
  6556. * @see https://easings.net/#easeInBounce
  6557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6558. */
  6559. export class BounceEase extends EasingFunction implements IEasingFunction {
  6560. /** Defines the number of bounces */
  6561. bounces: number;
  6562. /** Defines the amplitude of the bounce */
  6563. bounciness: number;
  6564. /**
  6565. * Instantiates a bounce easing
  6566. * @see https://easings.net/#easeInBounce
  6567. * @param bounces Defines the number of bounces
  6568. * @param bounciness Defines the amplitude of the bounce
  6569. */
  6570. constructor(
  6571. /** Defines the number of bounces */
  6572. bounces?: number,
  6573. /** Defines the amplitude of the bounce */
  6574. bounciness?: number);
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 3 shape (see link below).
  6580. * @see https://easings.net/#easeInCubic
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class CubicEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with an elastic shape (see link below).
  6589. * @see https://easings.net/#easeInElastic
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6593. /** Defines the number of oscillations*/
  6594. oscillations: number;
  6595. /** Defines the amplitude of the oscillations*/
  6596. springiness: number;
  6597. /**
  6598. * Instantiates an elastic easing function
  6599. * @see https://easings.net/#easeInElastic
  6600. * @param oscillations Defines the number of oscillations
  6601. * @param springiness Defines the amplitude of the oscillations
  6602. */
  6603. constructor(
  6604. /** Defines the number of oscillations*/
  6605. oscillations?: number,
  6606. /** Defines the amplitude of the oscillations*/
  6607. springiness?: number);
  6608. /** @hidden */
  6609. easeInCore(gradient: number): number;
  6610. }
  6611. /**
  6612. * Easing function with an exponential shape (see link below).
  6613. * @see https://easings.net/#easeInExpo
  6614. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6615. */
  6616. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6617. /** Defines the exponent of the function */
  6618. exponent: number;
  6619. /**
  6620. * Instantiates an exponential easing function
  6621. * @see https://easings.net/#easeInExpo
  6622. * @param exponent Defines the exponent of the function
  6623. */
  6624. constructor(
  6625. /** Defines the exponent of the function */
  6626. exponent?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. /**
  6631. * Easing function with a power shape (see link below).
  6632. * @see https://easings.net/#easeInQuad
  6633. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6634. */
  6635. export class PowerEase extends EasingFunction implements IEasingFunction {
  6636. /** Defines the power of the function */
  6637. power: number;
  6638. /**
  6639. * Instantiates an power base easing function
  6640. * @see https://easings.net/#easeInQuad
  6641. * @param power Defines the power of the function
  6642. */
  6643. constructor(
  6644. /** Defines the power of the function */
  6645. power?: number);
  6646. /** @hidden */
  6647. easeInCore(gradient: number): number;
  6648. }
  6649. /**
  6650. * Easing function with a power of 2 shape (see link below).
  6651. * @see https://easings.net/#easeInQuad
  6652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6653. */
  6654. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6655. /** @hidden */
  6656. easeInCore(gradient: number): number;
  6657. }
  6658. /**
  6659. * Easing function with a power of 4 shape (see link below).
  6660. * @see https://easings.net/#easeInQuart
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a power of 5 shape (see link below).
  6669. * @see https://easings.net/#easeInQuint
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6673. /** @hidden */
  6674. easeInCore(gradient: number): number;
  6675. }
  6676. /**
  6677. * Easing function with a sin shape (see link below).
  6678. * @see https://easings.net/#easeInSine
  6679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6680. */
  6681. export class SineEase extends EasingFunction implements IEasingFunction {
  6682. /** @hidden */
  6683. easeInCore(gradient: number): number;
  6684. }
  6685. /**
  6686. * Easing function with a bezier shape (see link below).
  6687. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6691. /** Defines the x component of the start tangent in the bezier curve */
  6692. x1: number;
  6693. /** Defines the y component of the start tangent in the bezier curve */
  6694. y1: number;
  6695. /** Defines the x component of the end tangent in the bezier curve */
  6696. x2: number;
  6697. /** Defines the y component of the end tangent in the bezier curve */
  6698. y2: number;
  6699. /**
  6700. * Instantiates a bezier function
  6701. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6702. * @param x1 Defines the x component of the start tangent in the bezier curve
  6703. * @param y1 Defines the y component of the start tangent in the bezier curve
  6704. * @param x2 Defines the x component of the end tangent in the bezier curve
  6705. * @param y2 Defines the y component of the end tangent in the bezier curve
  6706. */
  6707. constructor(
  6708. /** Defines the x component of the start tangent in the bezier curve */
  6709. x1?: number,
  6710. /** Defines the y component of the start tangent in the bezier curve */
  6711. y1?: number,
  6712. /** Defines the x component of the end tangent in the bezier curve */
  6713. x2?: number,
  6714. /** Defines the y component of the end tangent in the bezier curve */
  6715. y2?: number);
  6716. /** @hidden */
  6717. easeInCore(gradient: number): number;
  6718. }
  6719. }
  6720. declare module "babylonjs/Animations/animationKey" {
  6721. /**
  6722. * Defines an interface which represents an animation key frame
  6723. */
  6724. export interface IAnimationKey {
  6725. /**
  6726. * Frame of the key frame
  6727. */
  6728. frame: number;
  6729. /**
  6730. * Value at the specifies key frame
  6731. */
  6732. value: any;
  6733. /**
  6734. * The input tangent for the cubic hermite spline
  6735. */
  6736. inTangent?: any;
  6737. /**
  6738. * The output tangent for the cubic hermite spline
  6739. */
  6740. outTangent?: any;
  6741. /**
  6742. * The animation interpolation type
  6743. */
  6744. interpolation?: AnimationKeyInterpolation;
  6745. }
  6746. /**
  6747. * Enum for the animation key frame interpolation type
  6748. */
  6749. export enum AnimationKeyInterpolation {
  6750. /**
  6751. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6752. */
  6753. STEP = 1
  6754. }
  6755. }
  6756. declare module "babylonjs/Animations/animationRange" {
  6757. /**
  6758. * Represents the range of an animation
  6759. */
  6760. export class AnimationRange {
  6761. /**The name of the animation range**/
  6762. name: string;
  6763. /**The starting frame of the animation */
  6764. from: number;
  6765. /**The ending frame of the animation*/
  6766. to: number;
  6767. /**
  6768. * Initializes the range of an animation
  6769. * @param name The name of the animation range
  6770. * @param from The starting frame of the animation
  6771. * @param to The ending frame of the animation
  6772. */
  6773. constructor(
  6774. /**The name of the animation range**/
  6775. name: string,
  6776. /**The starting frame of the animation */
  6777. from: number,
  6778. /**The ending frame of the animation*/
  6779. to: number);
  6780. /**
  6781. * Makes a copy of the animation range
  6782. * @returns A copy of the animation range
  6783. */
  6784. clone(): AnimationRange;
  6785. }
  6786. }
  6787. declare module "babylonjs/Animations/animationEvent" {
  6788. /**
  6789. * Composed of a frame, and an action function
  6790. */
  6791. export class AnimationEvent {
  6792. /** The frame for which the event is triggered **/
  6793. frame: number;
  6794. /** The event to perform when triggered **/
  6795. action: (currentFrame: number) => void;
  6796. /** Specifies if the event should be triggered only once**/
  6797. onlyOnce?: boolean | undefined;
  6798. /**
  6799. * Specifies if the animation event is done
  6800. */
  6801. isDone: boolean;
  6802. /**
  6803. * Initializes the animation event
  6804. * @param frame The frame for which the event is triggered
  6805. * @param action The event to perform when triggered
  6806. * @param onlyOnce Specifies if the event should be triggered only once
  6807. */
  6808. constructor(
  6809. /** The frame for which the event is triggered **/
  6810. frame: number,
  6811. /** The event to perform when triggered **/
  6812. action: (currentFrame: number) => void,
  6813. /** Specifies if the event should be triggered only once**/
  6814. onlyOnce?: boolean | undefined);
  6815. /** @hidden */
  6816. _clone(): AnimationEvent;
  6817. }
  6818. }
  6819. declare module "babylonjs/Behaviors/behavior" {
  6820. import { Nullable } from "babylonjs/types";
  6821. /**
  6822. * Interface used to define a behavior
  6823. */
  6824. export interface Behavior<T> {
  6825. /** gets or sets behavior's name */
  6826. name: string;
  6827. /**
  6828. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6829. */
  6830. init(): void;
  6831. /**
  6832. * Called when the behavior is attached to a target
  6833. * @param target defines the target where the behavior is attached to
  6834. */
  6835. attach(target: T): void;
  6836. /**
  6837. * Called when the behavior is detached from its target
  6838. */
  6839. detach(): void;
  6840. }
  6841. /**
  6842. * Interface implemented by classes supporting behaviors
  6843. */
  6844. export interface IBehaviorAware<T> {
  6845. /**
  6846. * Attach a behavior
  6847. * @param behavior defines the behavior to attach
  6848. * @returns the current host
  6849. */
  6850. addBehavior(behavior: Behavior<T>): T;
  6851. /**
  6852. * Remove a behavior from the current object
  6853. * @param behavior defines the behavior to detach
  6854. * @returns the current host
  6855. */
  6856. removeBehavior(behavior: Behavior<T>): T;
  6857. /**
  6858. * Gets a behavior using its name to search
  6859. * @param name defines the name to search
  6860. * @returns the behavior or null if not found
  6861. */
  6862. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6863. }
  6864. }
  6865. declare module "babylonjs/Collisions/intersectionInfo" {
  6866. import { Nullable } from "babylonjs/types";
  6867. /**
  6868. * @hidden
  6869. */
  6870. export class IntersectionInfo {
  6871. bu: Nullable<number>;
  6872. bv: Nullable<number>;
  6873. distance: number;
  6874. faceId: number;
  6875. subMeshId: number;
  6876. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6877. }
  6878. }
  6879. declare module "babylonjs/Culling/boundingSphere" {
  6880. import { DeepImmutable } from "babylonjs/types";
  6881. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6882. /**
  6883. * Class used to store bounding sphere information
  6884. */
  6885. export class BoundingSphere {
  6886. /**
  6887. * Gets the center of the bounding sphere in local space
  6888. */
  6889. readonly center: Vector3;
  6890. /**
  6891. * Radius of the bounding sphere in local space
  6892. */
  6893. radius: number;
  6894. /**
  6895. * Gets the center of the bounding sphere in world space
  6896. */
  6897. readonly centerWorld: Vector3;
  6898. /**
  6899. * Radius of the bounding sphere in world space
  6900. */
  6901. radiusWorld: number;
  6902. /**
  6903. * Gets the minimum vector in local space
  6904. */
  6905. readonly minimum: Vector3;
  6906. /**
  6907. * Gets the maximum vector in local space
  6908. */
  6909. readonly maximum: Vector3;
  6910. private _worldMatrix;
  6911. private static readonly TmpVector3;
  6912. /**
  6913. * Creates a new bounding sphere
  6914. * @param min defines the minimum vector (in local space)
  6915. * @param max defines the maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6919. /**
  6920. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6921. * @param min defines the new minimum vector (in local space)
  6922. * @param max defines the new maximum vector (in local space)
  6923. * @param worldMatrix defines the new world matrix
  6924. */
  6925. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6926. /**
  6927. * Scale the current bounding sphere by applying a scale factor
  6928. * @param factor defines the scale factor to apply
  6929. * @returns the current bounding box
  6930. */
  6931. scale(factor: number): BoundingSphere;
  6932. /**
  6933. * Gets the world matrix of the bounding box
  6934. * @returns a matrix
  6935. */
  6936. getWorldMatrix(): DeepImmutable<Matrix>;
  6937. /** @hidden */
  6938. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6939. /**
  6940. * Tests if the bounding sphere is intersecting the frustum planes
  6941. * @param frustumPlanes defines the frustum planes to test
  6942. * @returns true if there is an intersection
  6943. */
  6944. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6945. /**
  6946. * Tests if the bounding sphere center is in between the frustum planes.
  6947. * Used for optimistic fast inclusion.
  6948. * @param frustumPlanes defines the frustum planes to test
  6949. * @returns true if the sphere center is in between the frustum planes
  6950. */
  6951. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6952. /**
  6953. * Tests if a point is inside the bounding sphere
  6954. * @param point defines the point to test
  6955. * @returns true if the point is inside the bounding sphere
  6956. */
  6957. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6958. /**
  6959. * Checks if two sphere intersct
  6960. * @param sphere0 sphere 0
  6961. * @param sphere1 sphere 1
  6962. * @returns true if the speres intersect
  6963. */
  6964. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6965. }
  6966. }
  6967. declare module "babylonjs/Culling/boundingBox" {
  6968. import { DeepImmutable } from "babylonjs/types";
  6969. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6970. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6971. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6972. /**
  6973. * Class used to store bounding box information
  6974. */
  6975. export class BoundingBox implements ICullable {
  6976. /**
  6977. * Gets the 8 vectors representing the bounding box in local space
  6978. */
  6979. readonly vectors: Vector3[];
  6980. /**
  6981. * Gets the center of the bounding box in local space
  6982. */
  6983. readonly center: Vector3;
  6984. /**
  6985. * Gets the center of the bounding box in world space
  6986. */
  6987. readonly centerWorld: Vector3;
  6988. /**
  6989. * Gets the extend size in local space
  6990. */
  6991. readonly extendSize: Vector3;
  6992. /**
  6993. * Gets the extend size in world space
  6994. */
  6995. readonly extendSizeWorld: Vector3;
  6996. /**
  6997. * Gets the OBB (object bounding box) directions
  6998. */
  6999. readonly directions: Vector3[];
  7000. /**
  7001. * Gets the 8 vectors representing the bounding box in world space
  7002. */
  7003. readonly vectorsWorld: Vector3[];
  7004. /**
  7005. * Gets the minimum vector in world space
  7006. */
  7007. readonly minimumWorld: Vector3;
  7008. /**
  7009. * Gets the maximum vector in world space
  7010. */
  7011. readonly maximumWorld: Vector3;
  7012. /**
  7013. * Gets the minimum vector in local space
  7014. */
  7015. readonly minimum: Vector3;
  7016. /**
  7017. * Gets the maximum vector in local space
  7018. */
  7019. readonly maximum: Vector3;
  7020. private _worldMatrix;
  7021. private static readonly TmpVector3;
  7022. /**
  7023. * @hidden
  7024. */
  7025. _tag: number;
  7026. /**
  7027. * Creates a new bounding box
  7028. * @param min defines the minimum vector (in local space)
  7029. * @param max defines the maximum vector (in local space)
  7030. * @param worldMatrix defines the new world matrix
  7031. */
  7032. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7033. /**
  7034. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7035. * @param min defines the new minimum vector (in local space)
  7036. * @param max defines the new maximum vector (in local space)
  7037. * @param worldMatrix defines the new world matrix
  7038. */
  7039. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7040. /**
  7041. * Scale the current bounding box by applying a scale factor
  7042. * @param factor defines the scale factor to apply
  7043. * @returns the current bounding box
  7044. */
  7045. scale(factor: number): BoundingBox;
  7046. /**
  7047. * Gets the world matrix of the bounding box
  7048. * @returns a matrix
  7049. */
  7050. getWorldMatrix(): DeepImmutable<Matrix>;
  7051. /** @hidden */
  7052. _update(world: DeepImmutable<Matrix>): void;
  7053. /**
  7054. * Tests if the bounding box is intersecting the frustum planes
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @returns true if there is an intersection
  7057. */
  7058. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. /**
  7060. * Tests if the bounding box is entirely inside the frustum planes
  7061. * @param frustumPlanes defines the frustum planes to test
  7062. * @returns true if there is an inclusion
  7063. */
  7064. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7065. /**
  7066. * Tests if a point is inside the bounding box
  7067. * @param point defines the point to test
  7068. * @returns true if the point is inside the bounding box
  7069. */
  7070. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7071. /**
  7072. * Tests if the bounding box intersects with a bounding sphere
  7073. * @param sphere defines the sphere to test
  7074. * @returns true if there is an intersection
  7075. */
  7076. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7077. /**
  7078. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7079. * @param min defines the min vector to use
  7080. * @param max defines the max vector to use
  7081. * @returns true if there is an intersection
  7082. */
  7083. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7084. /**
  7085. * Tests if two bounding boxes are intersections
  7086. * @param box0 defines the first box to test
  7087. * @param box1 defines the second box to test
  7088. * @returns true if there is an intersection
  7089. */
  7090. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7091. /**
  7092. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7093. * @param minPoint defines the minimum vector of the bounding box
  7094. * @param maxPoint defines the maximum vector of the bounding box
  7095. * @param sphereCenter defines the sphere center
  7096. * @param sphereRadius defines the sphere radius
  7097. * @returns true if there is an intersection
  7098. */
  7099. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7100. /**
  7101. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7102. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7103. * @param frustumPlanes defines the frustum planes to test
  7104. * @return true if there is an inclusion
  7105. */
  7106. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7107. /**
  7108. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7109. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7110. * @param frustumPlanes defines the frustum planes to test
  7111. * @return true if there is an intersection
  7112. */
  7113. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7114. }
  7115. }
  7116. declare module "babylonjs/Collisions/collider" {
  7117. import { Nullable, IndicesArray } from "babylonjs/types";
  7118. import { Vector3, Plane } from "babylonjs/Maths/math";
  7119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7120. /** @hidden */
  7121. export class Collider {
  7122. /** Define if a collision was found */
  7123. collisionFound: boolean;
  7124. /**
  7125. * Define last intersection point in local space
  7126. */
  7127. intersectionPoint: Vector3;
  7128. /**
  7129. * Define last collided mesh
  7130. */
  7131. collidedMesh: Nullable<AbstractMesh>;
  7132. private _collisionPoint;
  7133. private _planeIntersectionPoint;
  7134. private _tempVector;
  7135. private _tempVector2;
  7136. private _tempVector3;
  7137. private _tempVector4;
  7138. private _edge;
  7139. private _baseToVertex;
  7140. private _destinationPoint;
  7141. private _slidePlaneNormal;
  7142. private _displacementVector;
  7143. /** @hidden */
  7144. _radius: Vector3;
  7145. /** @hidden */
  7146. _retry: number;
  7147. private _velocity;
  7148. private _basePoint;
  7149. private _epsilon;
  7150. /** @hidden */
  7151. _velocityWorldLength: number;
  7152. /** @hidden */
  7153. _basePointWorld: Vector3;
  7154. private _velocityWorld;
  7155. private _normalizedVelocity;
  7156. /** @hidden */
  7157. _initialVelocity: Vector3;
  7158. /** @hidden */
  7159. _initialPosition: Vector3;
  7160. private _nearestDistance;
  7161. private _collisionMask;
  7162. collisionMask: number;
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. readonly slidePlaneNormal: Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Collider } from "babylonjs/Collisions/collider";
  7187. /**
  7188. * Interface for cullable objects
  7189. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7190. */
  7191. export interface ICullable {
  7192. /**
  7193. * Checks if the object or part of the object is in the frustum
  7194. * @param frustumPlanes Camera near/planes
  7195. * @returns true if the object is in frustum otherwise false
  7196. */
  7197. isInFrustum(frustumPlanes: Plane[]): boolean;
  7198. /**
  7199. * Checks if a cullable object (mesh...) is in the camera frustum
  7200. * Unlike isInFrustum this cheks the full bounding box
  7201. * @param frustumPlanes Camera near/planes
  7202. * @returns true if the object is in frustum otherwise false
  7203. */
  7204. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7205. }
  7206. /**
  7207. * Info for a bounding data of a mesh
  7208. */
  7209. export class BoundingInfo implements ICullable {
  7210. /**
  7211. * Bounding box for the mesh
  7212. */
  7213. readonly boundingBox: BoundingBox;
  7214. /**
  7215. * Bounding sphere for the mesh
  7216. */
  7217. readonly boundingSphere: BoundingSphere;
  7218. private _isLocked;
  7219. private static readonly TmpVector3;
  7220. /**
  7221. * Constructs bounding info
  7222. * @param minimum min vector of the bounding box/sphere
  7223. * @param maximum max vector of the bounding box/sphere
  7224. * @param worldMatrix defines the new world matrix
  7225. */
  7226. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7227. /**
  7228. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7229. * @param min defines the new minimum vector (in local space)
  7230. * @param max defines the new maximum vector (in local space)
  7231. * @param worldMatrix defines the new world matrix
  7232. */
  7233. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7234. /**
  7235. * min vector of the bounding box/sphere
  7236. */
  7237. readonly minimum: Vector3;
  7238. /**
  7239. * max vector of the bounding box/sphere
  7240. */
  7241. readonly maximum: Vector3;
  7242. /**
  7243. * If the info is locked and won't be updated to avoid perf overhead
  7244. */
  7245. isLocked: boolean;
  7246. /**
  7247. * Updates the bounding sphere and box
  7248. * @param world world matrix to be used to update
  7249. */
  7250. update(world: DeepImmutable<Matrix>): void;
  7251. /**
  7252. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7253. * @param center New center of the bounding info
  7254. * @param extend New extend of the bounding info
  7255. * @returns the current bounding info
  7256. */
  7257. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7258. /**
  7259. * Scale the current bounding info by applying a scale factor
  7260. * @param factor defines the scale factor to apply
  7261. * @returns the current bounding info
  7262. */
  7263. scale(factor: number): BoundingInfo;
  7264. /**
  7265. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7266. * @param frustumPlanes defines the frustum to test
  7267. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7268. * @returns true if the bounding info is in the frustum planes
  7269. */
  7270. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7271. /**
  7272. * Gets the world distance between the min and max points of the bounding box
  7273. */
  7274. readonly diagonalLength: number;
  7275. /**
  7276. * Checks if a cullable object (mesh...) is in the camera frustum
  7277. * Unlike isInFrustum this cheks the full bounding box
  7278. * @param frustumPlanes Camera near/planes
  7279. * @returns true if the object is in frustum otherwise false
  7280. */
  7281. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7282. /** @hidden */
  7283. _checkCollision(collider: Collider): boolean;
  7284. /**
  7285. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7286. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7287. * @param point the point to check intersection with
  7288. * @returns if the point intersects
  7289. */
  7290. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7291. /**
  7292. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7293. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7294. * @param boundingInfo the bounding info to check intersection with
  7295. * @param precise if the intersection should be done using OBB
  7296. * @returns if the bounding info intersects
  7297. */
  7298. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7299. }
  7300. }
  7301. declare module "babylonjs/Misc/smartArray" {
  7302. /**
  7303. * Defines an array and its length.
  7304. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7305. */
  7306. export interface ISmartArrayLike<T> {
  7307. /**
  7308. * The data of the array.
  7309. */
  7310. data: Array<T>;
  7311. /**
  7312. * The active length of the array.
  7313. */
  7314. length: number;
  7315. }
  7316. /**
  7317. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7318. */
  7319. export class SmartArray<T> implements ISmartArrayLike<T> {
  7320. /**
  7321. * The full set of data from the array.
  7322. */
  7323. data: Array<T>;
  7324. /**
  7325. * The active length of the array.
  7326. */
  7327. length: number;
  7328. protected _id: number;
  7329. /**
  7330. * Instantiates a Smart Array.
  7331. * @param capacity defines the default capacity of the array.
  7332. */
  7333. constructor(capacity: number);
  7334. /**
  7335. * Pushes a value at the end of the active data.
  7336. * @param value defines the object to push in the array.
  7337. */
  7338. push(value: T): void;
  7339. /**
  7340. * Iterates over the active data and apply the lambda to them.
  7341. * @param func defines the action to apply on each value.
  7342. */
  7343. forEach(func: (content: T) => void): void;
  7344. /**
  7345. * Sorts the full sets of data.
  7346. * @param compareFn defines the comparison function to apply.
  7347. */
  7348. sort(compareFn: (a: T, b: T) => number): void;
  7349. /**
  7350. * Resets the active data to an empty array.
  7351. */
  7352. reset(): void;
  7353. /**
  7354. * Releases all the data from the array as well as the array.
  7355. */
  7356. dispose(): void;
  7357. /**
  7358. * Concats the active data with a given array.
  7359. * @param array defines the data to concatenate with.
  7360. */
  7361. concat(array: any): void;
  7362. /**
  7363. * Returns the position of a value in the active data.
  7364. * @param value defines the value to find the index for
  7365. * @returns the index if found in the active data otherwise -1
  7366. */
  7367. indexOf(value: T): number;
  7368. /**
  7369. * Returns whether an element is part of the active data.
  7370. * @param value defines the value to look for
  7371. * @returns true if found in the active data otherwise false
  7372. */
  7373. contains(value: T): boolean;
  7374. private static _GlobalId;
  7375. }
  7376. /**
  7377. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7378. * The data in this array can only be present once
  7379. */
  7380. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7381. private _duplicateId;
  7382. /**
  7383. * Pushes a value at the end of the active data.
  7384. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7385. * @param value defines the object to push in the array.
  7386. */
  7387. push(value: T): void;
  7388. /**
  7389. * Pushes a value at the end of the active data.
  7390. * If the data is already present, it won t be added again
  7391. * @param value defines the object to push in the array.
  7392. * @returns true if added false if it was already present
  7393. */
  7394. pushNoDuplicate(value: T): boolean;
  7395. /**
  7396. * Resets the active data to an empty array.
  7397. */
  7398. reset(): void;
  7399. /**
  7400. * Concats the active data with a given array.
  7401. * This ensures no dupplicate will be present in the result.
  7402. * @param array defines the data to concatenate with.
  7403. */
  7404. concatWithNoDuplicate(array: any): void;
  7405. }
  7406. }
  7407. declare module "babylonjs/Materials/multiMaterial" {
  7408. import { Nullable } from "babylonjs/types";
  7409. import { Scene } from "babylonjs/scene";
  7410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7411. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7413. import { Material } from "babylonjs/Materials/material";
  7414. /**
  7415. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7416. * separate meshes. This can be use to improve performances.
  7417. * @see http://doc.babylonjs.com/how_to/multi_materials
  7418. */
  7419. export class MultiMaterial extends Material {
  7420. private _subMaterials;
  7421. /**
  7422. * Gets or Sets the list of Materials used within the multi material.
  7423. * They need to be ordered according to the submeshes order in the associated mesh
  7424. */
  7425. subMaterials: Nullable<Material>[];
  7426. /**
  7427. * Function used to align with Node.getChildren()
  7428. * @returns the list of Materials used within the multi material
  7429. */
  7430. getChildren(): Nullable<Material>[];
  7431. /**
  7432. * Instantiates a new Multi Material
  7433. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7434. * separate meshes. This can be use to improve performances.
  7435. * @see http://doc.babylonjs.com/how_to/multi_materials
  7436. * @param name Define the name in the scene
  7437. * @param scene Define the scene the material belongs to
  7438. */
  7439. constructor(name: string, scene: Scene);
  7440. private _hookArray;
  7441. /**
  7442. * Get one of the submaterial by its index in the submaterials array
  7443. * @param index The index to look the sub material at
  7444. * @returns The Material if the index has been defined
  7445. */
  7446. getSubMaterial(index: number): Nullable<Material>;
  7447. /**
  7448. * Get the list of active textures for the whole sub materials list.
  7449. * @returns All the textures that will be used during the rendering
  7450. */
  7451. getActiveTextures(): BaseTexture[];
  7452. /**
  7453. * Gets the current class name of the material e.g. "MultiMaterial"
  7454. * Mainly use in serialization.
  7455. * @returns the class name
  7456. */
  7457. getClassName(): string;
  7458. /**
  7459. * Checks if the material is ready to render the requested sub mesh
  7460. * @param mesh Define the mesh the submesh belongs to
  7461. * @param subMesh Define the sub mesh to look readyness for
  7462. * @param useInstances Define whether or not the material is used with instances
  7463. * @returns true if ready, otherwise false
  7464. */
  7465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7466. /**
  7467. * Clones the current material and its related sub materials
  7468. * @param name Define the name of the newly cloned material
  7469. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7470. * @returns the cloned material
  7471. */
  7472. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7473. /**
  7474. * Serializes the materials into a JSON representation.
  7475. * @returns the JSON representation
  7476. */
  7477. serialize(): any;
  7478. /**
  7479. * Dispose the material and release its associated resources
  7480. * @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)
  7481. * @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)
  7482. * @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)
  7483. */
  7484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7485. /**
  7486. * Creates a MultiMaterial from parsed MultiMaterial data.
  7487. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7488. * @param scene defines the hosting scene
  7489. * @returns a new MultiMaterial
  7490. */
  7491. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7492. }
  7493. }
  7494. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7495. /**
  7496. * Class used to represent data loading progression
  7497. */
  7498. export class SceneLoaderFlags {
  7499. private static _ForceFullSceneLoadingForIncremental;
  7500. private static _ShowLoadingScreen;
  7501. private static _CleanBoneMatrixWeights;
  7502. private static _loggingLevel;
  7503. /**
  7504. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7505. */
  7506. static ForceFullSceneLoadingForIncremental: boolean;
  7507. /**
  7508. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7509. */
  7510. static ShowLoadingScreen: boolean;
  7511. /**
  7512. * Defines the current logging level (while loading the scene)
  7513. * @ignorenaming
  7514. */
  7515. static loggingLevel: number;
  7516. /**
  7517. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7518. */
  7519. static CleanBoneMatrixWeights: boolean;
  7520. }
  7521. }
  7522. declare module "babylonjs/Meshes/transformNode" {
  7523. import { DeepImmutable } from "babylonjs/types";
  7524. import { Observable } from "babylonjs/Misc/observable";
  7525. import { Nullable } from "babylonjs/types";
  7526. import { Camera } from "babylonjs/Cameras/camera";
  7527. import { Scene } from "babylonjs/scene";
  7528. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7529. import { Node } from "babylonjs/node";
  7530. import { Bone } from "babylonjs/Bones/bone";
  7531. /**
  7532. * 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.
  7533. * @see https://doc.babylonjs.com/how_to/transformnode
  7534. */
  7535. export class TransformNode extends Node {
  7536. /**
  7537. * Object will not rotate to face the camera
  7538. */
  7539. static BILLBOARDMODE_NONE: number;
  7540. /**
  7541. * Object will rotate to face the camera but only on the x axis
  7542. */
  7543. static BILLBOARDMODE_X: number;
  7544. /**
  7545. * Object will rotate to face the camera but only on the y axis
  7546. */
  7547. static BILLBOARDMODE_Y: number;
  7548. /**
  7549. * Object will rotate to face the camera but only on the z axis
  7550. */
  7551. static BILLBOARDMODE_Z: number;
  7552. /**
  7553. * Object will rotate to face the camera
  7554. */
  7555. static BILLBOARDMODE_ALL: number;
  7556. private _forward;
  7557. private _forwardInverted;
  7558. private _up;
  7559. private _right;
  7560. private _rightInverted;
  7561. private _position;
  7562. private _rotation;
  7563. private _rotationQuaternion;
  7564. protected _scaling: Vector3;
  7565. protected _isDirty: boolean;
  7566. private _transformToBoneReferal;
  7567. /**
  7568. * Set the billboard mode. Default is 0.
  7569. *
  7570. * | Value | Type | Description |
  7571. * | --- | --- | --- |
  7572. * | 0 | BILLBOARDMODE_NONE | |
  7573. * | 1 | BILLBOARDMODE_X | |
  7574. * | 2 | BILLBOARDMODE_Y | |
  7575. * | 4 | BILLBOARDMODE_Z | |
  7576. * | 7 | BILLBOARDMODE_ALL | |
  7577. *
  7578. */
  7579. billboardMode: number;
  7580. /**
  7581. * 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
  7582. */
  7583. scalingDeterminant: number;
  7584. /**
  7585. * Sets the distance of the object to max, often used by skybox
  7586. */
  7587. infiniteDistance: boolean;
  7588. /**
  7589. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7590. * By default the system will update normals to compensate
  7591. */
  7592. ignoreNonUniformScaling: boolean;
  7593. /** @hidden */
  7594. _poseMatrix: Matrix;
  7595. /** @hidden */
  7596. _localMatrix: Matrix;
  7597. private _absolutePosition;
  7598. private _pivotMatrix;
  7599. private _pivotMatrixInverse;
  7600. protected _postMultiplyPivotMatrix: boolean;
  7601. private _tempMatrix;
  7602. private _tempMatrix2;
  7603. protected _isWorldMatrixFrozen: boolean;
  7604. /** @hidden */
  7605. _indexInSceneTransformNodesArray: number;
  7606. /**
  7607. * An event triggered after the world matrix is updated
  7608. */
  7609. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7610. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7611. /**
  7612. * Gets a string identifying the name of the class
  7613. * @returns "TransformNode" string
  7614. */
  7615. getClassName(): string;
  7616. /**
  7617. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7618. */
  7619. position: Vector3;
  7620. /**
  7621. * 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)).
  7622. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7623. */
  7624. rotation: Vector3;
  7625. /**
  7626. * 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)).
  7627. */
  7628. scaling: Vector3;
  7629. /**
  7630. * 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).
  7631. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7632. */
  7633. rotationQuaternion: Nullable<Quaternion>;
  7634. /**
  7635. * The forward direction of that transform in world space.
  7636. */
  7637. readonly forward: Vector3;
  7638. /**
  7639. * The up direction of that transform in world space.
  7640. */
  7641. readonly up: Vector3;
  7642. /**
  7643. * The right direction of that transform in world space.
  7644. */
  7645. readonly right: Vector3;
  7646. /**
  7647. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7648. * @param matrix the matrix to copy the pose from
  7649. * @returns this TransformNode.
  7650. */
  7651. updatePoseMatrix(matrix: Matrix): TransformNode;
  7652. /**
  7653. * Returns the mesh Pose matrix.
  7654. * @returns the pose matrix
  7655. */
  7656. getPoseMatrix(): Matrix;
  7657. /** @hidden */
  7658. _isSynchronized(): boolean;
  7659. /** @hidden */
  7660. _initCache(): void;
  7661. /**
  7662. * Flag the transform node as dirty (Forcing it to update everything)
  7663. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7664. * @returns this transform node
  7665. */
  7666. markAsDirty(property: string): TransformNode;
  7667. /**
  7668. * Returns the current mesh absolute position.
  7669. * Returns a Vector3.
  7670. */
  7671. readonly absolutePosition: Vector3;
  7672. /**
  7673. * Sets a new matrix to apply before all other transformation
  7674. * @param matrix defines the transform matrix
  7675. * @returns the current TransformNode
  7676. */
  7677. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7678. /**
  7679. * Sets a new pivot matrix to the current node
  7680. * @param matrix defines the new pivot matrix to use
  7681. * @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
  7682. * @returns the current TransformNode
  7683. */
  7684. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7685. /**
  7686. * Returns the mesh pivot matrix.
  7687. * Default : Identity.
  7688. * @returns the matrix
  7689. */
  7690. getPivotMatrix(): Matrix;
  7691. /**
  7692. * Prevents the World matrix to be computed any longer.
  7693. * @returns the TransformNode.
  7694. */
  7695. freezeWorldMatrix(): TransformNode;
  7696. /**
  7697. * Allows back the World matrix computation.
  7698. * @returns the TransformNode.
  7699. */
  7700. unfreezeWorldMatrix(): this;
  7701. /**
  7702. * True if the World matrix has been frozen.
  7703. */
  7704. readonly isWorldMatrixFrozen: boolean;
  7705. /**
  7706. * Retuns the mesh absolute position in the World.
  7707. * @returns a Vector3.
  7708. */
  7709. getAbsolutePosition(): Vector3;
  7710. /**
  7711. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7712. * @param absolutePosition the absolute position to set
  7713. * @returns the TransformNode.
  7714. */
  7715. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7716. /**
  7717. * Sets the mesh position in its local space.
  7718. * @param vector3 the position to set in localspace
  7719. * @returns the TransformNode.
  7720. */
  7721. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7722. /**
  7723. * Returns the mesh position in the local space from the current World matrix values.
  7724. * @returns a new Vector3.
  7725. */
  7726. getPositionExpressedInLocalSpace(): Vector3;
  7727. /**
  7728. * Translates the mesh along the passed Vector3 in its local space.
  7729. * @param vector3 the distance to translate in localspace
  7730. * @returns the TransformNode.
  7731. */
  7732. locallyTranslate(vector3: Vector3): TransformNode;
  7733. private static _lookAtVectorCache;
  7734. /**
  7735. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7736. * @param targetPoint the position (must be in same space as current mesh) to look at
  7737. * @param yawCor optional yaw (y-axis) correction in radians
  7738. * @param pitchCor optional pitch (x-axis) correction in radians
  7739. * @param rollCor optional roll (z-axis) correction in radians
  7740. * @param space the choosen space of the target
  7741. * @returns the TransformNode.
  7742. */
  7743. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7744. /**
  7745. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7746. * This Vector3 is expressed in the World space.
  7747. * @param localAxis axis to rotate
  7748. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7749. */
  7750. getDirection(localAxis: Vector3): Vector3;
  7751. /**
  7752. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7753. * localAxis is expressed in the mesh local space.
  7754. * result is computed in the Wordl space from the mesh World matrix.
  7755. * @param localAxis axis to rotate
  7756. * @param result the resulting transformnode
  7757. * @returns this TransformNode.
  7758. */
  7759. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7760. /**
  7761. * Sets this transform node rotation to the given local axis.
  7762. * @param localAxis the axis in local space
  7763. * @param yawCor optional yaw (y-axis) correction in radians
  7764. * @param pitchCor optional pitch (x-axis) correction in radians
  7765. * @param rollCor optional roll (z-axis) correction in radians
  7766. * @returns this TransformNode
  7767. */
  7768. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7769. /**
  7770. * Sets a new pivot point to the current node
  7771. * @param point defines the new pivot point to use
  7772. * @param space defines if the point is in world or local space (local by default)
  7773. * @returns the current TransformNode
  7774. */
  7775. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7776. /**
  7777. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7778. * @returns the pivot point
  7779. */
  7780. getPivotPoint(): Vector3;
  7781. /**
  7782. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7783. * @param result the vector3 to store the result
  7784. * @returns this TransformNode.
  7785. */
  7786. getPivotPointToRef(result: Vector3): TransformNode;
  7787. /**
  7788. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7789. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7790. */
  7791. getAbsolutePivotPoint(): Vector3;
  7792. /**
  7793. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7794. * @param result vector3 to store the result
  7795. * @returns this TransformNode.
  7796. */
  7797. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7798. /**
  7799. * Defines the passed node as the parent of the current node.
  7800. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7801. * @see https://doc.babylonjs.com/how_to/parenting
  7802. * @param node the node ot set as the parent
  7803. * @returns this TransformNode.
  7804. */
  7805. setParent(node: Nullable<Node>): TransformNode;
  7806. private _nonUniformScaling;
  7807. /**
  7808. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7809. */
  7810. readonly nonUniformScaling: boolean;
  7811. /** @hidden */
  7812. _updateNonUniformScalingState(value: boolean): boolean;
  7813. /**
  7814. * Attach the current TransformNode to another TransformNode associated with a bone
  7815. * @param bone Bone affecting the TransformNode
  7816. * @param affectedTransformNode TransformNode associated with the bone
  7817. * @returns this object
  7818. */
  7819. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7820. /**
  7821. * Detach the transform node if its associated with a bone
  7822. * @returns this object
  7823. */
  7824. detachFromBone(): TransformNode;
  7825. private static _rotationAxisCache;
  7826. /**
  7827. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7828. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7830. * The passed axis is also normalized.
  7831. * @param axis the axis to rotate around
  7832. * @param amount the amount to rotate in radians
  7833. * @param space Space to rotate in (Default: local)
  7834. * @returns the TransformNode.
  7835. */
  7836. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7837. /**
  7838. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7839. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7840. * The passed axis is also normalized. .
  7841. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7842. * @param point the point to rotate around
  7843. * @param axis the axis to rotate around
  7844. * @param amount the amount to rotate in radians
  7845. * @returns the TransformNode
  7846. */
  7847. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7848. /**
  7849. * Translates the mesh along the axis vector for the passed distance in the given space.
  7850. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7851. * @param axis the axis to translate in
  7852. * @param distance the distance to translate
  7853. * @param space Space to rotate in (Default: local)
  7854. * @returns the TransformNode.
  7855. */
  7856. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7857. /**
  7858. * Adds a rotation step to the mesh current rotation.
  7859. * x, y, z are Euler angles expressed in radians.
  7860. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7861. * This means this rotation is made in the mesh local space only.
  7862. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7863. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7864. * ```javascript
  7865. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7866. * ```
  7867. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7868. * 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.
  7869. * @param x Rotation to add
  7870. * @param y Rotation to add
  7871. * @param z Rotation to add
  7872. * @returns the TransformNode.
  7873. */
  7874. addRotation(x: number, y: number, z: number): TransformNode;
  7875. /**
  7876. * Computes the world matrix of the node
  7877. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7878. * @returns the world matrix
  7879. */
  7880. computeWorldMatrix(force?: boolean): Matrix;
  7881. protected _afterComputeWorldMatrix(): void;
  7882. /**
  7883. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7884. * @param func callback function to add
  7885. *
  7886. * @returns the TransformNode.
  7887. */
  7888. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7889. /**
  7890. * Removes a registered callback function.
  7891. * @param func callback function to remove
  7892. * @returns the TransformNode.
  7893. */
  7894. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7895. /**
  7896. * Gets the position of the current mesh in camera space
  7897. * @param camera defines the camera to use
  7898. * @returns a position
  7899. */
  7900. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7901. /**
  7902. * Returns the distance from the mesh to the active camera
  7903. * @param camera defines the camera to use
  7904. * @returns the distance
  7905. */
  7906. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7907. /**
  7908. * Clone the current transform node
  7909. * @param name Name of the new clone
  7910. * @param newParent New parent for the clone
  7911. * @param doNotCloneChildren Do not clone children hierarchy
  7912. * @returns the new transform node
  7913. */
  7914. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7915. /**
  7916. * Serializes the objects information.
  7917. * @param currentSerializationObject defines the object to serialize in
  7918. * @returns the serialized object
  7919. */
  7920. serialize(currentSerializationObject?: any): any;
  7921. /**
  7922. * Returns a new TransformNode object parsed from the source provided.
  7923. * @param parsedTransformNode is the source.
  7924. * @param scene the scne the object belongs to
  7925. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7926. * @returns a new TransformNode object parsed from the source provided.
  7927. */
  7928. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7929. /**
  7930. * Get all child-transformNodes of this node
  7931. * @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
  7932. * @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
  7933. * @returns an array of TransformNode
  7934. */
  7935. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7936. /**
  7937. * Releases resources associated with this transform node.
  7938. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7939. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7940. */
  7941. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7942. }
  7943. }
  7944. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7945. /**
  7946. * Class used to override all child animations of a given target
  7947. */
  7948. export class AnimationPropertiesOverride {
  7949. /**
  7950. * Gets or sets a value indicating if animation blending must be used
  7951. */
  7952. enableBlending: boolean;
  7953. /**
  7954. * Gets or sets the blending speed to use when enableBlending is true
  7955. */
  7956. blendingSpeed: number;
  7957. /**
  7958. * Gets or sets the default loop mode to use
  7959. */
  7960. loopMode: number;
  7961. }
  7962. }
  7963. declare module "babylonjs/Bones/bone" {
  7964. import { Skeleton } from "babylonjs/Bones/skeleton";
  7965. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7966. import { Nullable } from "babylonjs/types";
  7967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7968. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7969. import { Node } from "babylonjs/node";
  7970. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7971. /**
  7972. * Class used to store bone information
  7973. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7974. */
  7975. export class Bone extends Node {
  7976. /**
  7977. * defines the bone name
  7978. */
  7979. name: string;
  7980. private static _tmpVecs;
  7981. private static _tmpQuat;
  7982. private static _tmpMats;
  7983. /**
  7984. * Gets the list of child bones
  7985. */
  7986. children: Bone[];
  7987. /** Gets the animations associated with this bone */
  7988. animations: import("babylonjs/Animations/animation").Animation[];
  7989. /**
  7990. * Gets or sets bone length
  7991. */
  7992. length: number;
  7993. /**
  7994. * @hidden Internal only
  7995. * Set this value to map this bone to a different index in the transform matrices
  7996. * Set this value to -1 to exclude the bone from the transform matrices
  7997. */
  7998. _index: Nullable<number>;
  7999. private _skeleton;
  8000. private _localMatrix;
  8001. private _restPose;
  8002. private _baseMatrix;
  8003. private _absoluteTransform;
  8004. private _invertedAbsoluteTransform;
  8005. private _parent;
  8006. private _scalingDeterminant;
  8007. private _worldTransform;
  8008. private _localScaling;
  8009. private _localRotation;
  8010. private _localPosition;
  8011. private _needToDecompose;
  8012. private _needToCompose;
  8013. /** @hidden */
  8014. _linkedTransformNode: Nullable<TransformNode>;
  8015. /** @hidden */
  8016. /** @hidden */
  8017. _matrix: Matrix;
  8018. /**
  8019. * Create a new bone
  8020. * @param name defines the bone name
  8021. * @param skeleton defines the parent skeleton
  8022. * @param parentBone defines the parent (can be null if the bone is the root)
  8023. * @param localMatrix defines the local matrix
  8024. * @param restPose defines the rest pose matrix
  8025. * @param baseMatrix defines the base matrix
  8026. * @param index defines index of the bone in the hiearchy
  8027. */
  8028. constructor(
  8029. /**
  8030. * defines the bone name
  8031. */
  8032. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8033. /**
  8034. * Gets the current object class name.
  8035. * @return the class name
  8036. */
  8037. getClassName(): string;
  8038. /**
  8039. * Gets the parent skeleton
  8040. * @returns a skeleton
  8041. */
  8042. getSkeleton(): Skeleton;
  8043. /**
  8044. * Gets parent bone
  8045. * @returns a bone or null if the bone is the root of the bone hierarchy
  8046. */
  8047. getParent(): Nullable<Bone>;
  8048. /**
  8049. * Returns an array containing the root bones
  8050. * @returns an array containing the root bones
  8051. */
  8052. getChildren(): Array<Bone>;
  8053. /**
  8054. * Sets the parent bone
  8055. * @param parent defines the parent (can be null if the bone is the root)
  8056. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8057. */
  8058. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8059. /**
  8060. * Gets the local matrix
  8061. * @returns a matrix
  8062. */
  8063. getLocalMatrix(): Matrix;
  8064. /**
  8065. * Gets the base matrix (initial matrix which remains unchanged)
  8066. * @returns a matrix
  8067. */
  8068. getBaseMatrix(): Matrix;
  8069. /**
  8070. * Gets the rest pose matrix
  8071. * @returns a matrix
  8072. */
  8073. getRestPose(): Matrix;
  8074. /**
  8075. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8076. */
  8077. getWorldMatrix(): Matrix;
  8078. /**
  8079. * Sets the local matrix to rest pose matrix
  8080. */
  8081. returnToRest(): void;
  8082. /**
  8083. * Gets the inverse of the absolute transform matrix.
  8084. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8085. * @returns a matrix
  8086. */
  8087. getInvertedAbsoluteTransform(): Matrix;
  8088. /**
  8089. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8090. * @returns a matrix
  8091. */
  8092. getAbsoluteTransform(): Matrix;
  8093. /**
  8094. * Links with the given transform node.
  8095. * The local matrix of this bone is copied from the transform node every frame.
  8096. * @param transformNode defines the transform node to link to
  8097. */
  8098. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8099. /** Gets or sets current position (in local space) */
  8100. position: Vector3;
  8101. /** Gets or sets current rotation (in local space) */
  8102. rotation: Vector3;
  8103. /** Gets or sets current rotation quaternion (in local space) */
  8104. rotationQuaternion: Quaternion;
  8105. /** Gets or sets current scaling (in local space) */
  8106. scaling: Vector3;
  8107. /**
  8108. * Gets the animation properties override
  8109. */
  8110. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8111. private _decompose;
  8112. private _compose;
  8113. /**
  8114. * Update the base and local matrices
  8115. * @param matrix defines the new base or local matrix
  8116. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8117. * @param updateLocalMatrix defines if the local matrix should be updated
  8118. */
  8119. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8120. /** @hidden */
  8121. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8122. /**
  8123. * Flag the bone as dirty (Forcing it to update everything)
  8124. */
  8125. markAsDirty(): void;
  8126. private _markAsDirtyAndCompose;
  8127. private _markAsDirtyAndDecompose;
  8128. /**
  8129. * Translate the bone in local or world space
  8130. * @param vec The amount to translate the bone
  8131. * @param space The space that the translation is in
  8132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8133. */
  8134. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8135. /**
  8136. * Set the postion of the bone in local or world space
  8137. * @param position The position to set the bone
  8138. * @param space The space that the position is in
  8139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8140. */
  8141. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8142. /**
  8143. * Set the absolute position of the bone (world space)
  8144. * @param position The position to set the bone
  8145. * @param mesh The mesh that this bone is attached to
  8146. */
  8147. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8148. /**
  8149. * Scale the bone on the x, y and z axes (in local space)
  8150. * @param x The amount to scale the bone on the x axis
  8151. * @param y The amount to scale the bone on the y axis
  8152. * @param z The amount to scale the bone on the z axis
  8153. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8154. */
  8155. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8156. /**
  8157. * Set the bone scaling in local space
  8158. * @param scale defines the scaling vector
  8159. */
  8160. setScale(scale: Vector3): void;
  8161. /**
  8162. * Gets the current scaling in local space
  8163. * @returns the current scaling vector
  8164. */
  8165. getScale(): Vector3;
  8166. /**
  8167. * Gets the current scaling in local space and stores it in a target vector
  8168. * @param result defines the target vector
  8169. */
  8170. getScaleToRef(result: Vector3): void;
  8171. /**
  8172. * Set the yaw, pitch, and roll of the bone in local or world space
  8173. * @param yaw The rotation of the bone on the y axis
  8174. * @param pitch The rotation of the bone on the x axis
  8175. * @param roll The rotation of the bone on the z axis
  8176. * @param space The space that the axes of rotation are in
  8177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8178. */
  8179. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8180. /**
  8181. * Add a rotation to the bone on an axis in local or world space
  8182. * @param axis The axis to rotate the bone on
  8183. * @param amount The amount to rotate the bone
  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. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8188. /**
  8189. * Set the rotation of the bone to a particular axis angle in local or world space
  8190. * @param axis The axis to rotate the bone on
  8191. * @param angle The angle that the bone should be rotated to
  8192. * @param space The space that the axis is in
  8193. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8194. */
  8195. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8196. /**
  8197. * Set the euler rotation of the bone in local of world space
  8198. * @param rotation The euler rotation that the bone should be set to
  8199. * @param space The space that the rotation is in
  8200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8201. */
  8202. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8203. /**
  8204. * Set the quaternion rotation of the bone in local of world space
  8205. * @param quat The quaternion rotation that the bone should be set to
  8206. * @param space The space that the rotation is in
  8207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8208. */
  8209. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8210. /**
  8211. * Set the rotation matrix of the bone in local of world space
  8212. * @param rotMat The rotation matrix that the bone should be set to
  8213. * @param space The space that the rotation is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. */
  8216. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8217. private _rotateWithMatrix;
  8218. private _getNegativeRotationToRef;
  8219. /**
  8220. * Get the position of the bone in local or world space
  8221. * @param space The space that the returned position is in
  8222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8223. * @returns The position of the bone
  8224. */
  8225. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8226. /**
  8227. * Copy the position of the bone to a vector3 in local or world space
  8228. * @param space The space that the returned position is in
  8229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8230. * @param result The vector3 to copy the position to
  8231. */
  8232. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8233. /**
  8234. * Get the absolute position of the bone (world space)
  8235. * @param mesh The mesh that this bone is attached to
  8236. * @returns The absolute position of the bone
  8237. */
  8238. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8239. /**
  8240. * Copy the absolute position of the bone (world space) to the result param
  8241. * @param mesh The mesh that this bone is attached to
  8242. * @param result The vector3 to copy the absolute position to
  8243. */
  8244. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8245. /**
  8246. * Compute the absolute transforms of this bone and its children
  8247. */
  8248. computeAbsoluteTransforms(): void;
  8249. /**
  8250. * Get the world direction from an axis that is in the local space of the bone
  8251. * @param localAxis The local direction that is used to compute the world direction
  8252. * @param mesh The mesh that this bone is attached to
  8253. * @returns The world direction
  8254. */
  8255. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8256. /**
  8257. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8258. * @param localAxis The local direction that is used to compute the world direction
  8259. * @param mesh The mesh that this bone is attached to
  8260. * @param result The vector3 that the world direction will be copied to
  8261. */
  8262. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8263. /**
  8264. * Get the euler rotation of the bone in local or world space
  8265. * @param space The space that the rotation should be in
  8266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8267. * @returns The euler rotation
  8268. */
  8269. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8270. /**
  8271. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8272. * @param space The space that the rotation should be in
  8273. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8274. * @param result The vector3 that the rotation should be copied to
  8275. */
  8276. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8277. /**
  8278. * Get the quaternion rotation of the bone in either local or world space
  8279. * @param space The space that the rotation should be in
  8280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8281. * @returns The quaternion rotation
  8282. */
  8283. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8284. /**
  8285. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8286. * @param space The space that the rotation should be in
  8287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8288. * @param result The quaternion that the rotation should be copied to
  8289. */
  8290. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8291. /**
  8292. * Get the rotation matrix of the bone in local or world space
  8293. * @param space The space that the rotation should be in
  8294. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8295. * @returns The rotation matrix
  8296. */
  8297. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8298. /**
  8299. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8300. * @param space The space that the rotation should be in
  8301. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8302. * @param result The quaternion that the rotation should be copied to
  8303. */
  8304. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8305. /**
  8306. * Get the world position of a point that is in the local space of the bone
  8307. * @param position The local position
  8308. * @param mesh The mesh that this bone is attached to
  8309. * @returns The world position
  8310. */
  8311. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8312. /**
  8313. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8314. * @param position The local position
  8315. * @param mesh The mesh that this bone is attached to
  8316. * @param result The vector3 that the world position should be copied to
  8317. */
  8318. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8319. /**
  8320. * Get the local position of a point that is in world space
  8321. * @param position The world position
  8322. * @param mesh The mesh that this bone is attached to
  8323. * @returns The local position
  8324. */
  8325. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8326. /**
  8327. * Get the local position of a point that is in world space and copy it to the result param
  8328. * @param position The world position
  8329. * @param mesh The mesh that this bone is attached to
  8330. * @param result The vector3 that the local position should be copied to
  8331. */
  8332. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8333. }
  8334. }
  8335. declare module "babylonjs/Misc/iInspectable" {
  8336. /**
  8337. * Enum that determines the text-wrapping mode to use.
  8338. */
  8339. export enum InspectableType {
  8340. /**
  8341. * Checkbox for booleans
  8342. */
  8343. Checkbox = 0,
  8344. /**
  8345. * Sliders for numbers
  8346. */
  8347. Slider = 1,
  8348. /**
  8349. * Vector3
  8350. */
  8351. Vector3 = 2,
  8352. /**
  8353. * Quaternions
  8354. */
  8355. Quaternion = 3,
  8356. /**
  8357. * Color3
  8358. */
  8359. Color3 = 4
  8360. }
  8361. /**
  8362. * Interface used to define custom inspectable properties.
  8363. * This interface is used by the inspector to display custom property grids
  8364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8365. */
  8366. export interface IInspectable {
  8367. /**
  8368. * Gets the label to display
  8369. */
  8370. label: string;
  8371. /**
  8372. * Gets the name of the property to edit
  8373. */
  8374. propertyName: string;
  8375. /**
  8376. * Gets the type of the editor to use
  8377. */
  8378. type: InspectableType;
  8379. /**
  8380. * Gets the minimum value of the property when using in "slider" mode
  8381. */
  8382. min?: number;
  8383. /**
  8384. * Gets the maximum value of the property when using in "slider" mode
  8385. */
  8386. max?: number;
  8387. /**
  8388. * Gets the setp to use when using in "slider" mode
  8389. */
  8390. step?: number;
  8391. }
  8392. }
  8393. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8394. import { Nullable } from "babylonjs/types";
  8395. import { Scene } from "babylonjs/scene";
  8396. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8398. /**
  8399. * Class for creating a cube texture
  8400. */
  8401. export class CubeTexture extends BaseTexture {
  8402. private _delayedOnLoad;
  8403. /**
  8404. * The url of the texture
  8405. */
  8406. url: string;
  8407. /**
  8408. * Gets or sets the center of the bounding box associated with the cube texture.
  8409. * It must define where the camera used to render the texture was set
  8410. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8411. */
  8412. boundingBoxPosition: Vector3;
  8413. private _boundingBoxSize;
  8414. /**
  8415. * Gets or sets the size of the bounding box associated with the cube texture
  8416. * When defined, the cubemap will switch to local mode
  8417. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8418. * @example https://www.babylonjs-playground.com/#RNASML
  8419. */
  8420. /**
  8421. * Returns the bounding box size
  8422. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8423. */
  8424. boundingBoxSize: Vector3;
  8425. protected _rotationY: number;
  8426. /**
  8427. * Sets texture matrix rotation angle around Y axis in radians.
  8428. */
  8429. /**
  8430. * Gets texture matrix rotation angle around Y axis radians.
  8431. */
  8432. rotationY: number;
  8433. /**
  8434. * Are mip maps generated for this texture or not.
  8435. */
  8436. readonly noMipmap: boolean;
  8437. private _noMipmap;
  8438. private _files;
  8439. private _extensions;
  8440. private _textureMatrix;
  8441. private _format;
  8442. private _createPolynomials;
  8443. /** @hidden */
  8444. _prefiltered: boolean;
  8445. /**
  8446. * Creates a cube texture from an array of image urls
  8447. * @param files defines an array of image urls
  8448. * @param scene defines the hosting scene
  8449. * @param noMipmap specifies if mip maps are not used
  8450. * @returns a cube texture
  8451. */
  8452. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8453. /**
  8454. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8455. * @param url defines the url of the prefiltered texture
  8456. * @param scene defines the scene the texture is attached to
  8457. * @param forcedExtension defines the extension of the file if different from the url
  8458. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8459. * @return the prefiltered texture
  8460. */
  8461. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8462. /**
  8463. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8464. * as prefiltered data.
  8465. * @param rootUrl defines the url of the texture or the root name of the six images
  8466. * @param scene defines the scene the texture is attached to
  8467. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8468. * @param noMipmap defines if mipmaps should be created or not
  8469. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8470. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8471. * @param onError defines a callback triggered in case of error during load
  8472. * @param format defines the internal format to use for the texture once loaded
  8473. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8474. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8475. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8476. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8477. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8478. * @return the cube texture
  8479. */
  8480. 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);
  8481. /**
  8482. * Get the current class name of the texture useful for serialization or dynamic coding.
  8483. * @returns "CubeTexture"
  8484. */
  8485. getClassName(): string;
  8486. /**
  8487. * Update the url (and optional buffer) of this texture if url was null during construction.
  8488. * @param url the url of the texture
  8489. * @param forcedExtension defines the extension to use
  8490. * @param onLoad callback called when the texture is loaded (defaults to null)
  8491. */
  8492. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8493. /**
  8494. * Delays loading of the cube texture
  8495. * @param forcedExtension defines the extension to use
  8496. */
  8497. delayLoad(forcedExtension?: string): void;
  8498. /**
  8499. * Returns the reflection texture matrix
  8500. * @returns the reflection texture matrix
  8501. */
  8502. getReflectionTextureMatrix(): Matrix;
  8503. /**
  8504. * Sets the reflection texture matrix
  8505. * @param value Reflection texture matrix
  8506. */
  8507. setReflectionTextureMatrix(value: Matrix): void;
  8508. /**
  8509. * Parses text to create a cube texture
  8510. * @param parsedTexture define the serialized text to read from
  8511. * @param scene defines the hosting scene
  8512. * @param rootUrl defines the root url of the cube texture
  8513. * @returns a cube texture
  8514. */
  8515. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8516. /**
  8517. * Makes a clone, or deep copy, of the cube texture
  8518. * @returns a new cube texture
  8519. */
  8520. clone(): CubeTexture;
  8521. }
  8522. }
  8523. declare module "babylonjs/Shaders/postprocess.vertex" {
  8524. /** @hidden */
  8525. export var postprocessVertexShader: {
  8526. name: string;
  8527. shader: string;
  8528. };
  8529. }
  8530. declare module "babylonjs/Cameras/targetCamera" {
  8531. import { Nullable } from "babylonjs/types";
  8532. import { Camera } from "babylonjs/Cameras/camera";
  8533. import { Scene } from "babylonjs/scene";
  8534. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8535. /**
  8536. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8537. * This is the base of the follow, arc rotate cameras and Free camera
  8538. * @see http://doc.babylonjs.com/features/cameras
  8539. */
  8540. export class TargetCamera extends Camera {
  8541. private static _RigCamTransformMatrix;
  8542. private static _TargetTransformMatrix;
  8543. private static _TargetFocalPoint;
  8544. /**
  8545. * Define the current direction the camera is moving to
  8546. */
  8547. cameraDirection: Vector3;
  8548. /**
  8549. * Define the current rotation the camera is rotating to
  8550. */
  8551. cameraRotation: Vector2;
  8552. /**
  8553. * When set, the up vector of the camera will be updated by the rotation of the camera
  8554. */
  8555. updateUpVectorFromRotation: boolean;
  8556. private _tmpQuaternion;
  8557. /**
  8558. * Define the current rotation of the camera
  8559. */
  8560. rotation: Vector3;
  8561. /**
  8562. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8563. */
  8564. rotationQuaternion: Quaternion;
  8565. /**
  8566. * Define the current speed of the camera
  8567. */
  8568. speed: number;
  8569. /**
  8570. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8571. * around all axis.
  8572. */
  8573. noRotationConstraint: boolean;
  8574. /**
  8575. * Define the current target of the camera as an object or a position.
  8576. */
  8577. lockedTarget: any;
  8578. /** @hidden */
  8579. _currentTarget: Vector3;
  8580. /** @hidden */
  8581. _initialFocalDistance: number;
  8582. /** @hidden */
  8583. _viewMatrix: Matrix;
  8584. /** @hidden */
  8585. _camMatrix: Matrix;
  8586. /** @hidden */
  8587. _cameraTransformMatrix: Matrix;
  8588. /** @hidden */
  8589. _cameraRotationMatrix: Matrix;
  8590. /** @hidden */
  8591. _referencePoint: Vector3;
  8592. /** @hidden */
  8593. _transformedReferencePoint: Vector3;
  8594. protected _globalCurrentTarget: Vector3;
  8595. protected _globalCurrentUpVector: Vector3;
  8596. /** @hidden */
  8597. _reset: () => void;
  8598. private _defaultUp;
  8599. /**
  8600. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8601. * This is the base of the follow, arc rotate cameras and Free camera
  8602. * @see http://doc.babylonjs.com/features/cameras
  8603. * @param name Defines the name of the camera in the scene
  8604. * @param position Defines the start position of the camera in the scene
  8605. * @param scene Defines the scene the camera belongs to
  8606. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8607. */
  8608. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8609. /**
  8610. * Gets the position in front of the camera at a given distance.
  8611. * @param distance The distance from the camera we want the position to be
  8612. * @returns the position
  8613. */
  8614. getFrontPosition(distance: number): Vector3;
  8615. /** @hidden */
  8616. _getLockedTargetPosition(): Nullable<Vector3>;
  8617. private _storedPosition;
  8618. private _storedRotation;
  8619. private _storedRotationQuaternion;
  8620. /**
  8621. * Store current camera state of the camera (fov, position, rotation, etc..)
  8622. * @returns the camera
  8623. */
  8624. storeState(): Camera;
  8625. /**
  8626. * Restored camera state. You must call storeState() first
  8627. * @returns whether it was successful or not
  8628. * @hidden
  8629. */
  8630. _restoreStateValues(): boolean;
  8631. /** @hidden */
  8632. _initCache(): void;
  8633. /** @hidden */
  8634. _updateCache(ignoreParentClass?: boolean): void;
  8635. /** @hidden */
  8636. _isSynchronizedViewMatrix(): boolean;
  8637. /** @hidden */
  8638. _computeLocalCameraSpeed(): number;
  8639. /**
  8640. * Defines the target the camera should look at.
  8641. * This will automatically adapt alpha beta and radius to fit within the new target.
  8642. * @param target Defines the new target as a Vector or a mesh
  8643. */
  8644. setTarget(target: Vector3): void;
  8645. /**
  8646. * Return the current target position of the camera. This value is expressed in local space.
  8647. * @returns the target position
  8648. */
  8649. getTarget(): Vector3;
  8650. /** @hidden */
  8651. _decideIfNeedsToMove(): boolean;
  8652. /** @hidden */
  8653. _updatePosition(): void;
  8654. /** @hidden */
  8655. _checkInputs(): void;
  8656. protected _updateCameraRotationMatrix(): void;
  8657. /**
  8658. * 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)
  8659. * @returns the current camera
  8660. */
  8661. private _rotateUpVectorWithCameraRotationMatrix;
  8662. private _cachedRotationZ;
  8663. private _cachedQuaternionRotationZ;
  8664. /** @hidden */
  8665. _getViewMatrix(): Matrix;
  8666. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8667. /**
  8668. * @hidden
  8669. */
  8670. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8671. /**
  8672. * @hidden
  8673. */
  8674. _updateRigCameras(): void;
  8675. private _getRigCamPositionAndTarget;
  8676. /**
  8677. * Gets the current object class name.
  8678. * @return the class name
  8679. */
  8680. getClassName(): string;
  8681. }
  8682. }
  8683. declare module "babylonjs/Cameras/cameraInputsManager" {
  8684. import { Nullable } from "babylonjs/types";
  8685. import { Camera } from "babylonjs/Cameras/camera";
  8686. /**
  8687. * @ignore
  8688. * This is a list of all the different input types that are available in the application.
  8689. * Fo instance: ArcRotateCameraGamepadInput...
  8690. */
  8691. export var CameraInputTypes: {};
  8692. /**
  8693. * This is the contract to implement in order to create a new input class.
  8694. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8695. */
  8696. export interface ICameraInput<TCamera extends Camera> {
  8697. /**
  8698. * Defines the camera the input is attached to.
  8699. */
  8700. camera: Nullable<TCamera>;
  8701. /**
  8702. * Gets the class name of the current intput.
  8703. * @returns the class name
  8704. */
  8705. getClassName(): string;
  8706. /**
  8707. * Get the friendly name associated with the input class.
  8708. * @returns the input friendly name
  8709. */
  8710. getSimpleName(): string;
  8711. /**
  8712. * Attach the input controls to a specific dom element to get the input from.
  8713. * @param element Defines the element the controls should be listened from
  8714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8715. */
  8716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8717. /**
  8718. * Detach the current controls from the specified dom element.
  8719. * @param element Defines the element to stop listening the inputs from
  8720. */
  8721. detachControl(element: Nullable<HTMLElement>): void;
  8722. /**
  8723. * Update the current camera state depending on the inputs that have been used this frame.
  8724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8725. */
  8726. checkInputs?: () => void;
  8727. }
  8728. /**
  8729. * Represents a map of input types to input instance or input index to input instance.
  8730. */
  8731. export interface CameraInputsMap<TCamera extends Camera> {
  8732. /**
  8733. * Accessor to the input by input type.
  8734. */
  8735. [name: string]: ICameraInput<TCamera>;
  8736. /**
  8737. * Accessor to the input by input index.
  8738. */
  8739. [idx: number]: ICameraInput<TCamera>;
  8740. }
  8741. /**
  8742. * This represents the input manager used within a camera.
  8743. * It helps dealing with all the different kind of input attached to a camera.
  8744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8745. */
  8746. export class CameraInputsManager<TCamera extends Camera> {
  8747. /**
  8748. * Defines the list of inputs attahed to the camera.
  8749. */
  8750. attached: CameraInputsMap<TCamera>;
  8751. /**
  8752. * Defines the dom element the camera is collecting inputs from.
  8753. * This is null if the controls have not been attached.
  8754. */
  8755. attachedElement: Nullable<HTMLElement>;
  8756. /**
  8757. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8758. */
  8759. noPreventDefault: boolean;
  8760. /**
  8761. * Defined the camera the input manager belongs to.
  8762. */
  8763. camera: TCamera;
  8764. /**
  8765. * Update the current camera state depending on the inputs that have been used this frame.
  8766. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8767. */
  8768. checkInputs: () => void;
  8769. /**
  8770. * Instantiate a new Camera Input Manager.
  8771. * @param camera Defines the camera the input manager blongs to
  8772. */
  8773. constructor(camera: TCamera);
  8774. /**
  8775. * Add an input method to a camera
  8776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8777. * @param input camera input method
  8778. */
  8779. add(input: ICameraInput<TCamera>): void;
  8780. /**
  8781. * Remove a specific input method from a camera
  8782. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8783. * @param inputToRemove camera input method
  8784. */
  8785. remove(inputToRemove: ICameraInput<TCamera>): void;
  8786. /**
  8787. * Remove a specific input type from a camera
  8788. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8789. * @param inputType the type of the input to remove
  8790. */
  8791. removeByType(inputType: string): void;
  8792. private _addCheckInputs;
  8793. /**
  8794. * Attach the input controls to the currently attached dom element to listen the events from.
  8795. * @param input Defines the input to attach
  8796. */
  8797. attachInput(input: ICameraInput<TCamera>): void;
  8798. /**
  8799. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8800. * @param element Defines the dom element to collect the events from
  8801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8802. */
  8803. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8804. /**
  8805. * Detach the current manager inputs controls from a specific dom element.
  8806. * @param element Defines the dom element to collect the events from
  8807. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8808. */
  8809. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8810. /**
  8811. * Rebuild the dynamic inputCheck function from the current list of
  8812. * defined inputs in the manager.
  8813. */
  8814. rebuildInputCheck(): void;
  8815. /**
  8816. * Remove all attached input methods from a camera
  8817. */
  8818. clear(): void;
  8819. /**
  8820. * Serialize the current input manager attached to a camera.
  8821. * This ensures than once parsed,
  8822. * the input associated to the camera will be identical to the current ones
  8823. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8824. */
  8825. serialize(serializedCamera: any): void;
  8826. /**
  8827. * Parses an input manager serialized JSON to restore the previous list of inputs
  8828. * and states associated to a camera.
  8829. * @param parsedCamera Defines the JSON to parse
  8830. */
  8831. parse(parsedCamera: any): void;
  8832. }
  8833. }
  8834. declare module "babylonjs/Events/keyboardEvents" {
  8835. /**
  8836. * Gather the list of keyboard event types as constants.
  8837. */
  8838. export class KeyboardEventTypes {
  8839. /**
  8840. * The keydown event is fired when a key becomes active (pressed).
  8841. */
  8842. static readonly KEYDOWN: number;
  8843. /**
  8844. * The keyup event is fired when a key has been released.
  8845. */
  8846. static readonly KEYUP: number;
  8847. }
  8848. /**
  8849. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8850. */
  8851. export class KeyboardInfo {
  8852. /**
  8853. * Defines the type of event (KeyboardEventTypes)
  8854. */
  8855. type: number;
  8856. /**
  8857. * Defines the related dom event
  8858. */
  8859. event: KeyboardEvent;
  8860. /**
  8861. * Instantiates a new keyboard info.
  8862. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8863. * @param type Defines the type of event (KeyboardEventTypes)
  8864. * @param event Defines the related dom event
  8865. */
  8866. constructor(
  8867. /**
  8868. * Defines the type of event (KeyboardEventTypes)
  8869. */
  8870. type: number,
  8871. /**
  8872. * Defines the related dom event
  8873. */
  8874. event: KeyboardEvent);
  8875. }
  8876. /**
  8877. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8878. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8879. */
  8880. export class KeyboardInfoPre extends KeyboardInfo {
  8881. /**
  8882. * Defines the type of event (KeyboardEventTypes)
  8883. */
  8884. type: number;
  8885. /**
  8886. * Defines the related dom event
  8887. */
  8888. event: KeyboardEvent;
  8889. /**
  8890. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8891. */
  8892. skipOnPointerObservable: boolean;
  8893. /**
  8894. * Instantiates a new keyboard pre info.
  8895. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8896. * @param type Defines the type of event (KeyboardEventTypes)
  8897. * @param event Defines the related dom event
  8898. */
  8899. constructor(
  8900. /**
  8901. * Defines the type of event (KeyboardEventTypes)
  8902. */
  8903. type: number,
  8904. /**
  8905. * Defines the related dom event
  8906. */
  8907. event: KeyboardEvent);
  8908. }
  8909. }
  8910. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8911. import { Nullable } from "babylonjs/types";
  8912. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8913. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8914. /**
  8915. * Manage the keyboard inputs to control the movement of a free camera.
  8916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8917. */
  8918. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8919. /**
  8920. * Defines the camera the input is attached to.
  8921. */
  8922. camera: FreeCamera;
  8923. /**
  8924. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8925. */
  8926. keysUp: number[];
  8927. /**
  8928. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8929. */
  8930. keysDown: number[];
  8931. /**
  8932. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8933. */
  8934. keysLeft: number[];
  8935. /**
  8936. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8937. */
  8938. keysRight: number[];
  8939. private _keys;
  8940. private _onCanvasBlurObserver;
  8941. private _onKeyboardObserver;
  8942. private _engine;
  8943. private _scene;
  8944. /**
  8945. * Attach the input controls to a specific dom element to get the input from.
  8946. * @param element Defines the element the controls should be listened from
  8947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8948. */
  8949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8950. /**
  8951. * Detach the current controls from the specified dom element.
  8952. * @param element Defines the element to stop listening the inputs from
  8953. */
  8954. detachControl(element: Nullable<HTMLElement>): void;
  8955. /**
  8956. * Update the current camera state depending on the inputs that have been used this frame.
  8957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8958. */
  8959. checkInputs(): void;
  8960. /**
  8961. * Gets the class name of the current intput.
  8962. * @returns the class name
  8963. */
  8964. getClassName(): string;
  8965. /** @hidden */
  8966. _onLostFocus(): void;
  8967. /**
  8968. * Get the friendly name associated with the input class.
  8969. * @returns the input friendly name
  8970. */
  8971. getSimpleName(): string;
  8972. }
  8973. }
  8974. declare module "babylonjs/Lights/shadowLight" {
  8975. import { Camera } from "babylonjs/Cameras/camera";
  8976. import { Scene } from "babylonjs/scene";
  8977. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8979. import { Light } from "babylonjs/Lights/light";
  8980. /**
  8981. * Interface describing all the common properties and methods a shadow light needs to implement.
  8982. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8983. * as well as binding the different shadow properties to the effects.
  8984. */
  8985. export interface IShadowLight extends Light {
  8986. /**
  8987. * The light id in the scene (used in scene.findLighById for instance)
  8988. */
  8989. id: string;
  8990. /**
  8991. * The position the shdow will be casted from.
  8992. */
  8993. position: Vector3;
  8994. /**
  8995. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8996. */
  8997. direction: Vector3;
  8998. /**
  8999. * The transformed position. Position of the light in world space taking parenting in account.
  9000. */
  9001. transformedPosition: Vector3;
  9002. /**
  9003. * The transformed direction. Direction of the light in world space taking parenting in account.
  9004. */
  9005. transformedDirection: Vector3;
  9006. /**
  9007. * The friendly name of the light in the scene.
  9008. */
  9009. name: string;
  9010. /**
  9011. * Defines the shadow projection clipping minimum z value.
  9012. */
  9013. shadowMinZ: number;
  9014. /**
  9015. * Defines the shadow projection clipping maximum z value.
  9016. */
  9017. shadowMaxZ: number;
  9018. /**
  9019. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9020. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9021. */
  9022. computeTransformedInformation(): boolean;
  9023. /**
  9024. * Gets the scene the light belongs to.
  9025. * @returns The scene
  9026. */
  9027. getScene(): Scene;
  9028. /**
  9029. * Callback defining a custom Projection Matrix Builder.
  9030. * This can be used to override the default projection matrix computation.
  9031. */
  9032. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9033. /**
  9034. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9035. * @param matrix The materix to updated with the projection information
  9036. * @param viewMatrix The transform matrix of the light
  9037. * @param renderList The list of mesh to render in the map
  9038. * @returns The current light
  9039. */
  9040. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9041. /**
  9042. * Gets the current depth scale used in ESM.
  9043. * @returns The scale
  9044. */
  9045. getDepthScale(): number;
  9046. /**
  9047. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9048. * @returns true if a cube texture needs to be use
  9049. */
  9050. needCube(): boolean;
  9051. /**
  9052. * Detects if the projection matrix requires to be recomputed this frame.
  9053. * @returns true if it requires to be recomputed otherwise, false.
  9054. */
  9055. needProjectionMatrixCompute(): boolean;
  9056. /**
  9057. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9058. */
  9059. forceProjectionMatrixCompute(): void;
  9060. /**
  9061. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9062. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9063. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9064. */
  9065. getShadowDirection(faceIndex?: number): Vector3;
  9066. /**
  9067. * Gets the minZ used for shadow according to both the scene and the light.
  9068. * @param activeCamera The camera we are returning the min for
  9069. * @returns the depth min z
  9070. */
  9071. getDepthMinZ(activeCamera: Camera): number;
  9072. /**
  9073. * Gets the maxZ used for shadow according to both the scene and the light.
  9074. * @param activeCamera The camera we are returning the max for
  9075. * @returns the depth max z
  9076. */
  9077. getDepthMaxZ(activeCamera: Camera): number;
  9078. }
  9079. /**
  9080. * Base implementation IShadowLight
  9081. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9082. */
  9083. export abstract class ShadowLight extends Light implements IShadowLight {
  9084. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9085. protected _position: Vector3;
  9086. protected _setPosition(value: Vector3): void;
  9087. /**
  9088. * Sets the position the shadow will be casted from. Also use as the light position for both
  9089. * point and spot lights.
  9090. */
  9091. /**
  9092. * Sets the position the shadow will be casted from. Also use as the light position for both
  9093. * point and spot lights.
  9094. */
  9095. position: Vector3;
  9096. protected _direction: Vector3;
  9097. protected _setDirection(value: Vector3): void;
  9098. /**
  9099. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9100. * Also use as the light direction on spot and directional lights.
  9101. */
  9102. /**
  9103. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9104. * Also use as the light direction on spot and directional lights.
  9105. */
  9106. direction: Vector3;
  9107. private _shadowMinZ;
  9108. /**
  9109. * Gets the shadow projection clipping minimum z value.
  9110. */
  9111. /**
  9112. * Sets the shadow projection clipping minimum z value.
  9113. */
  9114. shadowMinZ: number;
  9115. private _shadowMaxZ;
  9116. /**
  9117. * Sets the shadow projection clipping maximum z value.
  9118. */
  9119. /**
  9120. * Gets the shadow projection clipping maximum z value.
  9121. */
  9122. shadowMaxZ: number;
  9123. /**
  9124. * Callback defining a custom Projection Matrix Builder.
  9125. * This can be used to override the default projection matrix computation.
  9126. */
  9127. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9128. /**
  9129. * The transformed position. Position of the light in world space taking parenting in account.
  9130. */
  9131. transformedPosition: Vector3;
  9132. /**
  9133. * The transformed direction. Direction of the light in world space taking parenting in account.
  9134. */
  9135. transformedDirection: Vector3;
  9136. private _needProjectionMatrixCompute;
  9137. /**
  9138. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9139. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9140. */
  9141. computeTransformedInformation(): boolean;
  9142. /**
  9143. * Return the depth scale used for the shadow map.
  9144. * @returns the depth scale.
  9145. */
  9146. getDepthScale(): number;
  9147. /**
  9148. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9149. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9150. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9151. */
  9152. getShadowDirection(faceIndex?: number): Vector3;
  9153. /**
  9154. * Returns the ShadowLight absolute position in the World.
  9155. * @returns the position vector in world space
  9156. */
  9157. getAbsolutePosition(): Vector3;
  9158. /**
  9159. * Sets the ShadowLight direction toward the passed target.
  9160. * @param target The point to target in local space
  9161. * @returns the updated ShadowLight direction
  9162. */
  9163. setDirectionToTarget(target: Vector3): Vector3;
  9164. /**
  9165. * Returns the light rotation in euler definition.
  9166. * @returns the x y z rotation in local space.
  9167. */
  9168. getRotation(): Vector3;
  9169. /**
  9170. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9171. * @returns true if a cube texture needs to be use
  9172. */
  9173. needCube(): boolean;
  9174. /**
  9175. * Detects if the projection matrix requires to be recomputed this frame.
  9176. * @returns true if it requires to be recomputed otherwise, false.
  9177. */
  9178. needProjectionMatrixCompute(): boolean;
  9179. /**
  9180. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9181. */
  9182. forceProjectionMatrixCompute(): void;
  9183. /** @hidden */
  9184. _initCache(): void;
  9185. /** @hidden */
  9186. _isSynchronized(): boolean;
  9187. /**
  9188. * Computes the world matrix of the node
  9189. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9190. * @returns the world matrix
  9191. */
  9192. computeWorldMatrix(force?: boolean): Matrix;
  9193. /**
  9194. * Gets the minZ used for shadow according to both the scene and the light.
  9195. * @param activeCamera The camera we are returning the min for
  9196. * @returns the depth min z
  9197. */
  9198. getDepthMinZ(activeCamera: Camera): number;
  9199. /**
  9200. * Gets the maxZ used for shadow according to both the scene and the light.
  9201. * @param activeCamera The camera we are returning the max for
  9202. * @returns the depth max z
  9203. */
  9204. getDepthMaxZ(activeCamera: Camera): number;
  9205. /**
  9206. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9207. * @param matrix The materix to updated with the projection information
  9208. * @param viewMatrix The transform matrix of the light
  9209. * @param renderList The list of mesh to render in the map
  9210. * @returns The current light
  9211. */
  9212. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9213. }
  9214. }
  9215. declare module "babylonjs/Materials/materialHelper" {
  9216. import { Nullable } from "babylonjs/types";
  9217. import { Scene } from "babylonjs/scene";
  9218. import { Engine } from "babylonjs/Engines/engine";
  9219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9220. import { Light } from "babylonjs/Lights/light";
  9221. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9222. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9224. /**
  9225. * "Static Class" containing the most commonly used helper while dealing with material for
  9226. * rendering purpose.
  9227. *
  9228. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9229. *
  9230. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9231. */
  9232. export class MaterialHelper {
  9233. /**
  9234. * Bind the current view position to an effect.
  9235. * @param effect The effect to be bound
  9236. * @param scene The scene the eyes position is used from
  9237. */
  9238. static BindEyePosition(effect: Effect, scene: Scene): void;
  9239. /**
  9240. * Helps preparing the defines values about the UVs in used in the effect.
  9241. * UVs are shared as much as we can accross channels in the shaders.
  9242. * @param texture The texture we are preparing the UVs for
  9243. * @param defines The defines to update
  9244. * @param key The channel key "diffuse", "specular"... used in the shader
  9245. */
  9246. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9247. /**
  9248. * Binds a texture matrix value to its corrsponding uniform
  9249. * @param texture The texture to bind the matrix for
  9250. * @param uniformBuffer The uniform buffer receivin the data
  9251. * @param key The channel key "diffuse", "specular"... used in the shader
  9252. */
  9253. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9254. /**
  9255. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9256. * @param mesh defines the current mesh
  9257. * @param scene defines the current scene
  9258. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9259. * @param pointsCloud defines if point cloud rendering has to be turned on
  9260. * @param fogEnabled defines if fog has to be turned on
  9261. * @param alphaTest defines if alpha testing has to be turned on
  9262. * @param defines defines the current list of defines
  9263. */
  9264. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9265. /**
  9266. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9267. * @param scene defines the current scene
  9268. * @param engine defines the current engine
  9269. * @param defines specifies the list of active defines
  9270. * @param useInstances defines if instances have to be turned on
  9271. * @param useClipPlane defines if clip plane have to be turned on
  9272. */
  9273. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9274. /**
  9275. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9276. * @param mesh The mesh containing the geometry data we will draw
  9277. * @param defines The defines to update
  9278. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9279. * @param useBones Precise whether bones should be used or not (override mesh info)
  9280. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9281. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9282. * @returns false if defines are considered not dirty and have not been checked
  9283. */
  9284. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9285. /**
  9286. * Prepares the defines related to multiview
  9287. * @param scene The scene we are intending to draw
  9288. * @param defines The defines to update
  9289. */
  9290. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9291. /**
  9292. * Prepares the defines related to the light information passed in parameter
  9293. * @param scene The scene we are intending to draw
  9294. * @param mesh The mesh the effect is compiling for
  9295. * @param defines The defines to update
  9296. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9297. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9298. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9299. * @returns true if normals will be required for the rest of the effect
  9300. */
  9301. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9302. /**
  9303. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9304. * that won t be acctive due to defines being turned off.
  9305. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9306. * @param samplersList The samplers list
  9307. * @param defines The defines helping in the list generation
  9308. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9309. */
  9310. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9311. /**
  9312. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9313. * @param defines The defines to update while falling back
  9314. * @param fallbacks The authorized effect fallbacks
  9315. * @param maxSimultaneousLights The maximum number of lights allowed
  9316. * @param rank the current rank of the Effect
  9317. * @returns The newly affected rank
  9318. */
  9319. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9320. /**
  9321. * Prepares the list of attributes required for morph targets according to the effect defines.
  9322. * @param attribs The current list of supported attribs
  9323. * @param mesh The mesh to prepare the morph targets attributes for
  9324. * @param defines The current Defines of the effect
  9325. */
  9326. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9327. /**
  9328. * Prepares the list of attributes required for bones according to the effect defines.
  9329. * @param attribs The current list of supported attribs
  9330. * @param mesh The mesh to prepare the bones attributes for
  9331. * @param defines The current Defines of the effect
  9332. * @param fallbacks The current efffect fallback strategy
  9333. */
  9334. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9335. /**
  9336. * Prepares the list of attributes required for instances according to the effect defines.
  9337. * @param attribs The current list of supported attribs
  9338. * @param defines The current Defines of the effect
  9339. */
  9340. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9341. /**
  9342. * Binds the light shadow information to the effect for the given mesh.
  9343. * @param light The light containing the generator
  9344. * @param scene The scene the lights belongs to
  9345. * @param mesh The mesh we are binding the information to render
  9346. * @param lightIndex The light index in the effect used to render the mesh
  9347. * @param effect The effect we are binding the data to
  9348. */
  9349. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9350. /**
  9351. * Binds the light information to the effect.
  9352. * @param light The light containing the generator
  9353. * @param effect The effect we are binding the data to
  9354. * @param lightIndex The light index in the effect used to render
  9355. */
  9356. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9357. /**
  9358. * Binds the lights information from the scene to the effect for the given mesh.
  9359. * @param scene The scene the lights belongs to
  9360. * @param mesh The mesh we are binding the information to render
  9361. * @param effect The effect we are binding the data to
  9362. * @param defines The generated defines for the effect
  9363. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9364. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9365. */
  9366. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9367. private static _tempFogColor;
  9368. /**
  9369. * Binds the fog information from the scene to the effect for the given mesh.
  9370. * @param scene The scene the lights belongs to
  9371. * @param mesh The mesh we are binding the information to render
  9372. * @param effect The effect we are binding the data to
  9373. * @param linearSpace Defines if the fog effect is applied in linear space
  9374. */
  9375. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9376. /**
  9377. * Binds the bones information from the mesh to the effect.
  9378. * @param mesh The mesh we are binding the information to render
  9379. * @param effect The effect we are binding the data to
  9380. */
  9381. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9382. /**
  9383. * Binds the morph targets information from the mesh to the effect.
  9384. * @param abstractMesh The mesh we are binding the information to render
  9385. * @param effect The effect we are binding the data to
  9386. */
  9387. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9388. /**
  9389. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9390. * @param defines The generated defines used in the effect
  9391. * @param effect The effect we are binding the data to
  9392. * @param scene The scene we are willing to render with logarithmic scale for
  9393. */
  9394. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9395. /**
  9396. * Binds the clip plane information from the scene to the effect.
  9397. * @param scene The scene the clip plane information are extracted from
  9398. * @param effect The effect we are binding the data to
  9399. */
  9400. static BindClipPlane(effect: Effect, scene: Scene): void;
  9401. }
  9402. }
  9403. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9404. /** @hidden */
  9405. export var kernelBlurVaryingDeclaration: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9411. /** @hidden */
  9412. export var kernelBlurFragment: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9418. /** @hidden */
  9419. export var kernelBlurFragment2: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9425. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9426. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9427. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9428. /** @hidden */
  9429. export var kernelBlurPixelShader: {
  9430. name: string;
  9431. shader: string;
  9432. };
  9433. }
  9434. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9435. /** @hidden */
  9436. export var kernelBlurVertex: {
  9437. name: string;
  9438. shader: string;
  9439. };
  9440. }
  9441. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9442. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9443. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9444. /** @hidden */
  9445. export var kernelBlurVertexShader: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9451. import { Vector2 } from "babylonjs/Maths/math";
  9452. import { Nullable } from "babylonjs/types";
  9453. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9454. import { Camera } from "babylonjs/Cameras/camera";
  9455. import { Effect } from "babylonjs/Materials/effect";
  9456. import { Engine } from "babylonjs/Engines/engine";
  9457. import "babylonjs/Shaders/kernelBlur.fragment";
  9458. import "babylonjs/Shaders/kernelBlur.vertex";
  9459. /**
  9460. * The Blur Post Process which blurs an image based on a kernel and direction.
  9461. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9462. */
  9463. export class BlurPostProcess extends PostProcess {
  9464. /** The direction in which to blur the image. */
  9465. direction: Vector2;
  9466. private blockCompilation;
  9467. protected _kernel: number;
  9468. protected _idealKernel: number;
  9469. protected _packedFloat: boolean;
  9470. private _staticDefines;
  9471. /**
  9472. * Sets the length in pixels of the blur sample region
  9473. */
  9474. /**
  9475. * Gets the length in pixels of the blur sample region
  9476. */
  9477. kernel: number;
  9478. /**
  9479. * Sets wether or not the blur needs to unpack/repack floats
  9480. */
  9481. /**
  9482. * Gets wether or not the blur is unpacking/repacking floats
  9483. */
  9484. packedFloat: boolean;
  9485. /**
  9486. * Creates a new instance BlurPostProcess
  9487. * @param name The name of the effect.
  9488. * @param direction The direction in which to blur the image.
  9489. * @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.
  9490. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9491. * @param camera The camera to apply the render pass to.
  9492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9493. * @param engine The engine which the post process will be applied. (default: current engine)
  9494. * @param reusable If the post process can be reused on the same frame. (default: false)
  9495. * @param textureType Type of textures used when performing the post process. (default: 0)
  9496. * @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)
  9497. */
  9498. constructor(name: string,
  9499. /** The direction in which to blur the image. */
  9500. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9501. /**
  9502. * Updates the effect with the current post process compile time values and recompiles the shader.
  9503. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9504. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9505. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9506. * @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
  9507. * @param onCompiled Called when the shader has been compiled.
  9508. * @param onError Called if there is an error when compiling a shader.
  9509. */
  9510. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9511. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9512. /**
  9513. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9514. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9515. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9516. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9517. * The gaps between physical kernels are compensated for in the weighting of the samples
  9518. * @param idealKernel Ideal blur kernel.
  9519. * @return Nearest best kernel.
  9520. */
  9521. protected _nearestBestKernel(idealKernel: number): number;
  9522. /**
  9523. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9524. * @param x The point on the Gaussian distribution to sample.
  9525. * @return the value of the Gaussian function at x.
  9526. */
  9527. protected _gaussianWeight(x: number): number;
  9528. /**
  9529. * Generates a string that can be used as a floating point number in GLSL.
  9530. * @param x Value to print.
  9531. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9532. * @return GLSL float string.
  9533. */
  9534. protected _glslFloat(x: number, decimalFigures?: number): string;
  9535. }
  9536. }
  9537. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9538. /** @hidden */
  9539. export var shadowMapPixelShader: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9545. /** @hidden */
  9546. export var bonesDeclaration: {
  9547. name: string;
  9548. shader: string;
  9549. };
  9550. }
  9551. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9552. /** @hidden */
  9553. export var morphTargetsVertexGlobalDeclaration: {
  9554. name: string;
  9555. shader: string;
  9556. };
  9557. }
  9558. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9559. /** @hidden */
  9560. export var morphTargetsVertexDeclaration: {
  9561. name: string;
  9562. shader: string;
  9563. };
  9564. }
  9565. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9566. /** @hidden */
  9567. export var instancesDeclaration: {
  9568. name: string;
  9569. shader: string;
  9570. };
  9571. }
  9572. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9573. /** @hidden */
  9574. export var helperFunctions: {
  9575. name: string;
  9576. shader: string;
  9577. };
  9578. }
  9579. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9580. /** @hidden */
  9581. export var morphTargetsVertex: {
  9582. name: string;
  9583. shader: string;
  9584. };
  9585. }
  9586. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9587. /** @hidden */
  9588. export var instancesVertex: {
  9589. name: string;
  9590. shader: string;
  9591. };
  9592. }
  9593. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9594. /** @hidden */
  9595. export var bonesVertex: {
  9596. name: string;
  9597. shader: string;
  9598. };
  9599. }
  9600. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9601. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9602. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9603. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9604. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9605. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9606. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9607. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9608. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9609. /** @hidden */
  9610. export var shadowMapVertexShader: {
  9611. name: string;
  9612. shader: string;
  9613. };
  9614. }
  9615. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9616. /** @hidden */
  9617. export var depthBoxBlurPixelShader: {
  9618. name: string;
  9619. shader: string;
  9620. };
  9621. }
  9622. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9623. import { Nullable } from "babylonjs/types";
  9624. import { Scene } from "babylonjs/scene";
  9625. import { Matrix } from "babylonjs/Maths/math";
  9626. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9628. import { Mesh } from "babylonjs/Meshes/mesh";
  9629. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9630. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9631. import { Effect } from "babylonjs/Materials/effect";
  9632. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9633. import "babylonjs/Shaders/shadowMap.fragment";
  9634. import "babylonjs/Shaders/shadowMap.vertex";
  9635. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9636. import { Observable } from "babylonjs/Misc/observable";
  9637. /**
  9638. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9639. */
  9640. export interface ICustomShaderOptions {
  9641. /**
  9642. * Gets or sets the custom shader name to use
  9643. */
  9644. shaderName: string;
  9645. /**
  9646. * The list of attribute names used in the shader
  9647. */
  9648. attributes?: string[];
  9649. /**
  9650. * The list of unifrom names used in the shader
  9651. */
  9652. uniforms?: string[];
  9653. /**
  9654. * The list of sampler names used in the shader
  9655. */
  9656. samplers?: string[];
  9657. /**
  9658. * The list of defines used in the shader
  9659. */
  9660. defines?: string[];
  9661. }
  9662. /**
  9663. * Interface to implement to create a shadow generator compatible with BJS.
  9664. */
  9665. export interface IShadowGenerator {
  9666. /**
  9667. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9668. * @returns The render target texture if present otherwise, null
  9669. */
  9670. getShadowMap(): Nullable<RenderTargetTexture>;
  9671. /**
  9672. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9673. * @returns The render target texture if the shadow map is present otherwise, null
  9674. */
  9675. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9676. /**
  9677. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9678. * @param subMesh The submesh we want to render in the shadow map
  9679. * @param useInstances Defines wether will draw in the map using instances
  9680. * @returns true if ready otherwise, false
  9681. */
  9682. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9683. /**
  9684. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9685. * @param defines Defines of the material we want to update
  9686. * @param lightIndex Index of the light in the enabled light list of the material
  9687. */
  9688. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9689. /**
  9690. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9691. * defined in the generator but impacting the effect).
  9692. * It implies the unifroms available on the materials are the standard BJS ones.
  9693. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9694. * @param effect The effect we are binfing the information for
  9695. */
  9696. bindShadowLight(lightIndex: string, effect: Effect): void;
  9697. /**
  9698. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9699. * (eq to shadow prjection matrix * light transform matrix)
  9700. * @returns The transform matrix used to create the shadow map
  9701. */
  9702. getTransformMatrix(): Matrix;
  9703. /**
  9704. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9705. * Cube and 2D textures for instance.
  9706. */
  9707. recreateShadowMap(): void;
  9708. /**
  9709. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9710. * @param onCompiled Callback triggered at the and of the effects compilation
  9711. * @param options Sets of optional options forcing the compilation with different modes
  9712. */
  9713. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9714. useInstances: boolean;
  9715. }>): void;
  9716. /**
  9717. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9718. * @param options Sets of optional options forcing the compilation with different modes
  9719. * @returns A promise that resolves when the compilation completes
  9720. */
  9721. forceCompilationAsync(options?: Partial<{
  9722. useInstances: boolean;
  9723. }>): Promise<void>;
  9724. /**
  9725. * Serializes the shadow generator setup to a json object.
  9726. * @returns The serialized JSON object
  9727. */
  9728. serialize(): any;
  9729. /**
  9730. * Disposes the Shadow map and related Textures and effects.
  9731. */
  9732. dispose(): void;
  9733. }
  9734. /**
  9735. * Default implementation IShadowGenerator.
  9736. * This is the main object responsible of generating shadows in the framework.
  9737. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9738. */
  9739. export class ShadowGenerator implements IShadowGenerator {
  9740. /**
  9741. * Shadow generator mode None: no filtering applied.
  9742. */
  9743. static readonly FILTER_NONE: number;
  9744. /**
  9745. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9746. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9747. */
  9748. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9749. /**
  9750. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9751. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9752. */
  9753. static readonly FILTER_POISSONSAMPLING: number;
  9754. /**
  9755. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9756. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9757. */
  9758. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9759. /**
  9760. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9761. * edge artifacts on steep falloff.
  9762. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9763. */
  9764. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9765. /**
  9766. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9767. * edge artifacts on steep falloff.
  9768. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9769. */
  9770. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9771. /**
  9772. * Shadow generator mode PCF: Percentage Closer Filtering
  9773. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9774. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9775. */
  9776. static readonly FILTER_PCF: number;
  9777. /**
  9778. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9779. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9780. * Contact Hardening
  9781. */
  9782. static readonly FILTER_PCSS: number;
  9783. /**
  9784. * Reserved for PCF and PCSS
  9785. * Highest Quality.
  9786. *
  9787. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9788. *
  9789. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9790. */
  9791. static readonly QUALITY_HIGH: number;
  9792. /**
  9793. * Reserved for PCF and PCSS
  9794. * Good tradeoff for quality/perf cross devices
  9795. *
  9796. * Execute PCF on a 3*3 kernel.
  9797. *
  9798. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9799. */
  9800. static readonly QUALITY_MEDIUM: number;
  9801. /**
  9802. * Reserved for PCF and PCSS
  9803. * The lowest quality but the fastest.
  9804. *
  9805. * Execute PCF on a 1*1 kernel.
  9806. *
  9807. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9808. */
  9809. static readonly QUALITY_LOW: number;
  9810. /** Gets or sets the custom shader name to use */
  9811. customShaderOptions: ICustomShaderOptions;
  9812. /**
  9813. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9814. */
  9815. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9816. /**
  9817. * Observable triggered before a mesh is rendered in the shadow map.
  9818. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9819. */
  9820. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9821. private _bias;
  9822. /**
  9823. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9824. */
  9825. /**
  9826. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9827. */
  9828. bias: number;
  9829. private _normalBias;
  9830. /**
  9831. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9832. */
  9833. /**
  9834. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9835. */
  9836. normalBias: number;
  9837. private _blurBoxOffset;
  9838. /**
  9839. * Gets the blur box offset: offset applied during the blur pass.
  9840. * Only useful if useKernelBlur = false
  9841. */
  9842. /**
  9843. * Sets the blur box offset: offset applied during the blur pass.
  9844. * Only useful if useKernelBlur = false
  9845. */
  9846. blurBoxOffset: number;
  9847. private _blurScale;
  9848. /**
  9849. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9850. * 2 means half of the size.
  9851. */
  9852. /**
  9853. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9854. * 2 means half of the size.
  9855. */
  9856. blurScale: number;
  9857. private _blurKernel;
  9858. /**
  9859. * Gets the blur kernel: kernel size of the blur pass.
  9860. * Only useful if useKernelBlur = true
  9861. */
  9862. /**
  9863. * Sets the blur kernel: kernel size of the blur pass.
  9864. * Only useful if useKernelBlur = true
  9865. */
  9866. blurKernel: number;
  9867. private _useKernelBlur;
  9868. /**
  9869. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9870. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9871. */
  9872. /**
  9873. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9874. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9875. */
  9876. useKernelBlur: boolean;
  9877. private _depthScale;
  9878. /**
  9879. * Gets the depth scale used in ESM mode.
  9880. */
  9881. /**
  9882. * Sets the depth scale used in ESM mode.
  9883. * This can override the scale stored on the light.
  9884. */
  9885. depthScale: number;
  9886. private _filter;
  9887. /**
  9888. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9889. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9890. */
  9891. /**
  9892. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9893. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9894. */
  9895. filter: number;
  9896. /**
  9897. * Gets if the current filter is set to Poisson Sampling.
  9898. */
  9899. /**
  9900. * Sets the current filter to Poisson Sampling.
  9901. */
  9902. usePoissonSampling: boolean;
  9903. /**
  9904. * Gets if the current filter is set to ESM.
  9905. */
  9906. /**
  9907. * Sets the current filter is to ESM.
  9908. */
  9909. useExponentialShadowMap: boolean;
  9910. /**
  9911. * Gets if the current filter is set to filtered ESM.
  9912. */
  9913. /**
  9914. * Gets if the current filter is set to filtered ESM.
  9915. */
  9916. useBlurExponentialShadowMap: boolean;
  9917. /**
  9918. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9919. * exponential to prevent steep falloff artifacts).
  9920. */
  9921. /**
  9922. * Sets the current filter to "close ESM" (using the inverse of the
  9923. * exponential to prevent steep falloff artifacts).
  9924. */
  9925. useCloseExponentialShadowMap: boolean;
  9926. /**
  9927. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9928. * exponential to prevent steep falloff artifacts).
  9929. */
  9930. /**
  9931. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9932. * exponential to prevent steep falloff artifacts).
  9933. */
  9934. useBlurCloseExponentialShadowMap: boolean;
  9935. /**
  9936. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9937. */
  9938. /**
  9939. * Sets the current filter to "PCF" (percentage closer filtering).
  9940. */
  9941. usePercentageCloserFiltering: boolean;
  9942. private _filteringQuality;
  9943. /**
  9944. * Gets the PCF or PCSS Quality.
  9945. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9946. */
  9947. /**
  9948. * Sets the PCF or PCSS Quality.
  9949. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9950. */
  9951. filteringQuality: number;
  9952. /**
  9953. * Gets if the current filter is set to "PCSS" (contact hardening).
  9954. */
  9955. /**
  9956. * Sets the current filter to "PCSS" (contact hardening).
  9957. */
  9958. useContactHardeningShadow: boolean;
  9959. private _contactHardeningLightSizeUVRatio;
  9960. /**
  9961. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9962. * Using a ratio helps keeping shape stability independently of the map size.
  9963. *
  9964. * It does not account for the light projection as it was having too much
  9965. * instability during the light setup or during light position changes.
  9966. *
  9967. * Only valid if useContactHardeningShadow is true.
  9968. */
  9969. /**
  9970. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9971. * Using a ratio helps keeping shape stability independently of the map size.
  9972. *
  9973. * It does not account for the light projection as it was having too much
  9974. * instability during the light setup or during light position changes.
  9975. *
  9976. * Only valid if useContactHardeningShadow is true.
  9977. */
  9978. contactHardeningLightSizeUVRatio: number;
  9979. private _darkness;
  9980. /**
  9981. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9982. * 0 means strongest and 1 would means no shadow.
  9983. * @returns the darkness.
  9984. */
  9985. getDarkness(): number;
  9986. /**
  9987. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9988. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9989. * @returns the shadow generator allowing fluent coding.
  9990. */
  9991. setDarkness(darkness: number): ShadowGenerator;
  9992. private _transparencyShadow;
  9993. /**
  9994. * Sets the ability to have transparent shadow (boolean).
  9995. * @param transparent True if transparent else False
  9996. * @returns the shadow generator allowing fluent coding
  9997. */
  9998. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9999. private _shadowMap;
  10000. private _shadowMap2;
  10001. /**
  10002. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10003. * @returns The render target texture if present otherwise, null
  10004. */
  10005. getShadowMap(): Nullable<RenderTargetTexture>;
  10006. /**
  10007. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10008. * @returns The render target texture if the shadow map is present otherwise, null
  10009. */
  10010. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10011. /**
  10012. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10013. * @param mesh Mesh to add
  10014. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10015. * @returns the Shadow Generator itself
  10016. */
  10017. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10018. /**
  10019. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10020. * @param mesh Mesh to remove
  10021. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10022. * @returns the Shadow Generator itself
  10023. */
  10024. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10025. /**
  10026. * Controls the extent to which the shadows fade out at the edge of the frustum
  10027. * Used only by directionals and spots
  10028. */
  10029. frustumEdgeFalloff: number;
  10030. private _light;
  10031. /**
  10032. * Returns the associated light object.
  10033. * @returns the light generating the shadow
  10034. */
  10035. getLight(): IShadowLight;
  10036. /**
  10037. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10038. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10039. * It might on the other hand introduce peter panning.
  10040. */
  10041. forceBackFacesOnly: boolean;
  10042. private _scene;
  10043. private _lightDirection;
  10044. private _effect;
  10045. private _viewMatrix;
  10046. private _projectionMatrix;
  10047. private _transformMatrix;
  10048. private _cachedPosition;
  10049. private _cachedDirection;
  10050. private _cachedDefines;
  10051. private _currentRenderID;
  10052. private _boxBlurPostprocess;
  10053. private _kernelBlurXPostprocess;
  10054. private _kernelBlurYPostprocess;
  10055. private _blurPostProcesses;
  10056. private _mapSize;
  10057. private _currentFaceIndex;
  10058. private _currentFaceIndexCache;
  10059. private _textureType;
  10060. private _defaultTextureMatrix;
  10061. /** @hidden */
  10062. static _SceneComponentInitialization: (scene: Scene) => void;
  10063. /**
  10064. * Creates a ShadowGenerator object.
  10065. * A ShadowGenerator is the required tool to use the shadows.
  10066. * Each light casting shadows needs to use its own ShadowGenerator.
  10067. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10068. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10069. * @param light The light object generating the shadows.
  10070. * @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.
  10071. */
  10072. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10073. private _initializeGenerator;
  10074. private _initializeShadowMap;
  10075. private _initializeBlurRTTAndPostProcesses;
  10076. private _renderForShadowMap;
  10077. private _renderSubMeshForShadowMap;
  10078. private _applyFilterValues;
  10079. /**
  10080. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10081. * @param onCompiled Callback triggered at the and of the effects compilation
  10082. * @param options Sets of optional options forcing the compilation with different modes
  10083. */
  10084. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10085. useInstances: boolean;
  10086. }>): void;
  10087. /**
  10088. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10089. * @param options Sets of optional options forcing the compilation with different modes
  10090. * @returns A promise that resolves when the compilation completes
  10091. */
  10092. forceCompilationAsync(options?: Partial<{
  10093. useInstances: boolean;
  10094. }>): Promise<void>;
  10095. /**
  10096. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10097. * @param subMesh The submesh we want to render in the shadow map
  10098. * @param useInstances Defines wether will draw in the map using instances
  10099. * @returns true if ready otherwise, false
  10100. */
  10101. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10102. /**
  10103. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10104. * @param defines Defines of the material we want to update
  10105. * @param lightIndex Index of the light in the enabled light list of the material
  10106. */
  10107. prepareDefines(defines: any, lightIndex: number): void;
  10108. /**
  10109. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10110. * defined in the generator but impacting the effect).
  10111. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10112. * @param effect The effect we are binfing the information for
  10113. */
  10114. bindShadowLight(lightIndex: string, effect: Effect): void;
  10115. /**
  10116. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10117. * (eq to shadow prjection matrix * light transform matrix)
  10118. * @returns The transform matrix used to create the shadow map
  10119. */
  10120. getTransformMatrix(): Matrix;
  10121. /**
  10122. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10123. * Cube and 2D textures for instance.
  10124. */
  10125. recreateShadowMap(): void;
  10126. private _disposeBlurPostProcesses;
  10127. private _disposeRTTandPostProcesses;
  10128. /**
  10129. * Disposes the ShadowGenerator.
  10130. * Returns nothing.
  10131. */
  10132. dispose(): void;
  10133. /**
  10134. * Serializes the shadow generator setup to a json object.
  10135. * @returns The serialized JSON object
  10136. */
  10137. serialize(): any;
  10138. /**
  10139. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10140. * @param parsedShadowGenerator The JSON object to parse
  10141. * @param scene The scene to create the shadow map for
  10142. * @returns The parsed shadow generator
  10143. */
  10144. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10145. }
  10146. }
  10147. declare module "babylonjs/Lights/light" {
  10148. import { Nullable } from "babylonjs/types";
  10149. import { Scene } from "babylonjs/scene";
  10150. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10151. import { Node } from "babylonjs/node";
  10152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10153. import { Effect } from "babylonjs/Materials/effect";
  10154. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10155. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10156. /**
  10157. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10158. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10159. * 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.
  10160. */
  10161. export abstract class Light extends Node {
  10162. /**
  10163. * Falloff Default: light is falling off following the material specification:
  10164. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10165. */
  10166. static readonly FALLOFF_DEFAULT: number;
  10167. /**
  10168. * Falloff Physical: light is falling off following the inverse squared distance law.
  10169. */
  10170. static readonly FALLOFF_PHYSICAL: number;
  10171. /**
  10172. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10173. * to enhance interoperability with other engines.
  10174. */
  10175. static readonly FALLOFF_GLTF: number;
  10176. /**
  10177. * Falloff Standard: light is falling off like in the standard material
  10178. * to enhance interoperability with other materials.
  10179. */
  10180. static readonly FALLOFF_STANDARD: number;
  10181. /**
  10182. * If every light affecting the material is in this lightmapMode,
  10183. * material.lightmapTexture adds or multiplies
  10184. * (depends on material.useLightmapAsShadowmap)
  10185. * after every other light calculations.
  10186. */
  10187. static readonly LIGHTMAP_DEFAULT: number;
  10188. /**
  10189. * material.lightmapTexture as only diffuse lighting from this light
  10190. * adds only specular lighting from this light
  10191. * adds dynamic shadows
  10192. */
  10193. static readonly LIGHTMAP_SPECULAR: number;
  10194. /**
  10195. * material.lightmapTexture as only lighting
  10196. * no light calculation from this light
  10197. * only adds dynamic shadows from this light
  10198. */
  10199. static readonly LIGHTMAP_SHADOWSONLY: number;
  10200. /**
  10201. * Each light type uses the default quantity according to its type:
  10202. * point/spot lights use luminous intensity
  10203. * directional lights use illuminance
  10204. */
  10205. static readonly INTENSITYMODE_AUTOMATIC: number;
  10206. /**
  10207. * lumen (lm)
  10208. */
  10209. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10210. /**
  10211. * candela (lm/sr)
  10212. */
  10213. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10214. /**
  10215. * lux (lm/m^2)
  10216. */
  10217. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10218. /**
  10219. * nit (cd/m^2)
  10220. */
  10221. static readonly INTENSITYMODE_LUMINANCE: number;
  10222. /**
  10223. * Light type const id of the point light.
  10224. */
  10225. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10226. /**
  10227. * Light type const id of the directional light.
  10228. */
  10229. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10230. /**
  10231. * Light type const id of the spot light.
  10232. */
  10233. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10234. /**
  10235. * Light type const id of the hemispheric light.
  10236. */
  10237. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10238. /**
  10239. * Diffuse gives the basic color to an object.
  10240. */
  10241. diffuse: Color3;
  10242. /**
  10243. * Specular produces a highlight color on an object.
  10244. * Note: This is note affecting PBR materials.
  10245. */
  10246. specular: Color3;
  10247. /**
  10248. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10249. * falling off base on range or angle.
  10250. * This can be set to any values in Light.FALLOFF_x.
  10251. *
  10252. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10253. * other types of materials.
  10254. */
  10255. falloffType: number;
  10256. /**
  10257. * Strength of the light.
  10258. * Note: By default it is define in the framework own unit.
  10259. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10260. */
  10261. intensity: number;
  10262. private _range;
  10263. protected _inverseSquaredRange: number;
  10264. /**
  10265. * Defines how far from the source the light is impacting in scene units.
  10266. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10267. */
  10268. /**
  10269. * Defines how far from the source the light is impacting in scene units.
  10270. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10271. */
  10272. range: number;
  10273. /**
  10274. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10275. * of light.
  10276. */
  10277. private _photometricScale;
  10278. private _intensityMode;
  10279. /**
  10280. * Gets the photometric scale used to interpret the intensity.
  10281. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10282. */
  10283. /**
  10284. * Sets the photometric scale used to interpret the intensity.
  10285. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10286. */
  10287. intensityMode: number;
  10288. private _radius;
  10289. /**
  10290. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10291. */
  10292. /**
  10293. * sets the light radius used by PBR Materials to simulate soft area lights.
  10294. */
  10295. radius: number;
  10296. private _renderPriority;
  10297. /**
  10298. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10299. * exceeding the number allowed of the materials.
  10300. */
  10301. renderPriority: number;
  10302. private _shadowEnabled;
  10303. /**
  10304. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10305. * the current shadow generator.
  10306. */
  10307. /**
  10308. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10309. * the current shadow generator.
  10310. */
  10311. shadowEnabled: boolean;
  10312. private _includedOnlyMeshes;
  10313. /**
  10314. * Gets the only meshes impacted by this light.
  10315. */
  10316. /**
  10317. * Sets the only meshes impacted by this light.
  10318. */
  10319. includedOnlyMeshes: AbstractMesh[];
  10320. private _excludedMeshes;
  10321. /**
  10322. * Gets the meshes not impacted by this light.
  10323. */
  10324. /**
  10325. * Sets the meshes not impacted by this light.
  10326. */
  10327. excludedMeshes: AbstractMesh[];
  10328. private _excludeWithLayerMask;
  10329. /**
  10330. * Gets the layer id use to find what meshes are not impacted by the light.
  10331. * Inactive if 0
  10332. */
  10333. /**
  10334. * Sets the layer id use to find what meshes are not impacted by the light.
  10335. * Inactive if 0
  10336. */
  10337. excludeWithLayerMask: number;
  10338. private _includeOnlyWithLayerMask;
  10339. /**
  10340. * Gets the layer id use to find what meshes are impacted by the light.
  10341. * Inactive if 0
  10342. */
  10343. /**
  10344. * Sets the layer id use to find what meshes are impacted by the light.
  10345. * Inactive if 0
  10346. */
  10347. includeOnlyWithLayerMask: number;
  10348. private _lightmapMode;
  10349. /**
  10350. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10351. */
  10352. /**
  10353. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10354. */
  10355. lightmapMode: number;
  10356. /**
  10357. * Shadow generator associted to the light.
  10358. * @hidden Internal use only.
  10359. */
  10360. _shadowGenerator: Nullable<IShadowGenerator>;
  10361. /**
  10362. * @hidden Internal use only.
  10363. */
  10364. _excludedMeshesIds: string[];
  10365. /**
  10366. * @hidden Internal use only.
  10367. */
  10368. _includedOnlyMeshesIds: string[];
  10369. /**
  10370. * The current light unifom buffer.
  10371. * @hidden Internal use only.
  10372. */
  10373. _uniformBuffer: UniformBuffer;
  10374. /**
  10375. * Creates a Light object in the scene.
  10376. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10377. * @param name The firendly name of the light
  10378. * @param scene The scene the light belongs too
  10379. */
  10380. constructor(name: string, scene: Scene);
  10381. protected abstract _buildUniformLayout(): void;
  10382. /**
  10383. * Sets the passed Effect "effect" with the Light information.
  10384. * @param effect The effect to update
  10385. * @param lightIndex The index of the light in the effect to update
  10386. * @returns The light
  10387. */
  10388. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10389. /**
  10390. * Returns the string "Light".
  10391. * @returns the class name
  10392. */
  10393. getClassName(): string;
  10394. /** @hidden */
  10395. readonly _isLight: boolean;
  10396. /**
  10397. * Converts the light information to a readable string for debug purpose.
  10398. * @param fullDetails Supports for multiple levels of logging within scene loading
  10399. * @returns the human readable light info
  10400. */
  10401. toString(fullDetails?: boolean): string;
  10402. /** @hidden */
  10403. protected _syncParentEnabledState(): void;
  10404. /**
  10405. * Set the enabled state of this node.
  10406. * @param value - the new enabled state
  10407. */
  10408. setEnabled(value: boolean): void;
  10409. /**
  10410. * Returns the Light associated shadow generator if any.
  10411. * @return the associated shadow generator.
  10412. */
  10413. getShadowGenerator(): Nullable<IShadowGenerator>;
  10414. /**
  10415. * Returns a Vector3, the absolute light position in the World.
  10416. * @returns the world space position of the light
  10417. */
  10418. getAbsolutePosition(): Vector3;
  10419. /**
  10420. * Specifies if the light will affect the passed mesh.
  10421. * @param mesh The mesh to test against the light
  10422. * @return true the mesh is affected otherwise, false.
  10423. */
  10424. canAffectMesh(mesh: AbstractMesh): boolean;
  10425. /**
  10426. * Sort function to order lights for rendering.
  10427. * @param a First Light object to compare to second.
  10428. * @param b Second Light object to compare first.
  10429. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10430. */
  10431. static CompareLightsPriority(a: Light, b: Light): number;
  10432. /**
  10433. * Releases resources associated with this node.
  10434. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10435. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10436. */
  10437. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10438. /**
  10439. * Returns the light type ID (integer).
  10440. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10441. */
  10442. getTypeID(): number;
  10443. /**
  10444. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10445. * @returns the scaled intensity in intensity mode unit
  10446. */
  10447. getScaledIntensity(): number;
  10448. /**
  10449. * Returns a new Light object, named "name", from the current one.
  10450. * @param name The name of the cloned light
  10451. * @returns the new created light
  10452. */
  10453. clone(name: string): Nullable<Light>;
  10454. /**
  10455. * Serializes the current light into a Serialization object.
  10456. * @returns the serialized object.
  10457. */
  10458. serialize(): any;
  10459. /**
  10460. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10461. * This new light is named "name" and added to the passed scene.
  10462. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10463. * @param name The friendly name of the light
  10464. * @param scene The scene the new light will belong to
  10465. * @returns the constructor function
  10466. */
  10467. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10468. /**
  10469. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10470. * @param parsedLight The JSON representation of the light
  10471. * @param scene The scene to create the parsed light in
  10472. * @returns the created light after parsing
  10473. */
  10474. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10475. private _hookArrayForExcluded;
  10476. private _hookArrayForIncludedOnly;
  10477. private _resyncMeshes;
  10478. /**
  10479. * Forces the meshes to update their light related information in their rendering used effects
  10480. * @hidden Internal Use Only
  10481. */
  10482. _markMeshesAsLightDirty(): void;
  10483. /**
  10484. * Recomputes the cached photometric scale if needed.
  10485. */
  10486. private _computePhotometricScale;
  10487. /**
  10488. * Returns the Photometric Scale according to the light type and intensity mode.
  10489. */
  10490. private _getPhotometricScale;
  10491. /**
  10492. * Reorder the light in the scene according to their defined priority.
  10493. * @hidden Internal Use Only
  10494. */
  10495. _reorderLightsInScene(): void;
  10496. /**
  10497. * Prepares the list of defines specific to the light type.
  10498. * @param defines the list of defines
  10499. * @param lightIndex defines the index of the light for the effect
  10500. */
  10501. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10502. }
  10503. }
  10504. declare module "babylonjs/Actions/action" {
  10505. import { Observable } from "babylonjs/Misc/observable";
  10506. import { Condition } from "babylonjs/Actions/condition";
  10507. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10508. import { ActionManager } from "babylonjs/Actions/actionManager";
  10509. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10510. /**
  10511. * Interface used to define Action
  10512. */
  10513. export interface IAction {
  10514. /**
  10515. * Trigger for the action
  10516. */
  10517. trigger: number;
  10518. /** Options of the trigger */
  10519. triggerOptions: any;
  10520. /**
  10521. * Gets the trigger parameters
  10522. * @returns the trigger parameters
  10523. */
  10524. getTriggerParameter(): any;
  10525. /**
  10526. * Internal only - executes current action event
  10527. * @hidden
  10528. */
  10529. _executeCurrent(evt?: ActionEvent): void;
  10530. /**
  10531. * Serialize placeholder for child classes
  10532. * @param parent of child
  10533. * @returns the serialized object
  10534. */
  10535. serialize(parent: any): any;
  10536. /**
  10537. * Internal only
  10538. * @hidden
  10539. */
  10540. _prepare(): void;
  10541. /**
  10542. * Internal only - manager for action
  10543. * @hidden
  10544. */
  10545. _actionManager: AbstractActionManager;
  10546. }
  10547. /**
  10548. * The action to be carried out following a trigger
  10549. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10550. */
  10551. export class Action implements IAction {
  10552. /** the trigger, with or without parameters, for the action */
  10553. triggerOptions: any;
  10554. /**
  10555. * Trigger for the action
  10556. */
  10557. trigger: number;
  10558. /**
  10559. * Internal only - manager for action
  10560. * @hidden
  10561. */
  10562. _actionManager: ActionManager;
  10563. private _nextActiveAction;
  10564. private _child;
  10565. private _condition?;
  10566. private _triggerParameter;
  10567. /**
  10568. * An event triggered prior to action being executed.
  10569. */
  10570. onBeforeExecuteObservable: Observable<Action>;
  10571. /**
  10572. * Creates a new Action
  10573. * @param triggerOptions the trigger, with or without parameters, for the action
  10574. * @param condition an optional determinant of action
  10575. */
  10576. constructor(
  10577. /** the trigger, with or without parameters, for the action */
  10578. triggerOptions: any, condition?: Condition);
  10579. /**
  10580. * Internal only
  10581. * @hidden
  10582. */
  10583. _prepare(): void;
  10584. /**
  10585. * Gets the trigger parameters
  10586. * @returns the trigger parameters
  10587. */
  10588. getTriggerParameter(): any;
  10589. /**
  10590. * Internal only - executes current action event
  10591. * @hidden
  10592. */
  10593. _executeCurrent(evt?: ActionEvent): void;
  10594. /**
  10595. * Execute placeholder for child classes
  10596. * @param evt optional action event
  10597. */
  10598. execute(evt?: ActionEvent): void;
  10599. /**
  10600. * Skips to next active action
  10601. */
  10602. skipToNextActiveAction(): void;
  10603. /**
  10604. * Adds action to chain of actions, may be a DoNothingAction
  10605. * @param action defines the next action to execute
  10606. * @returns The action passed in
  10607. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10608. */
  10609. then(action: Action): Action;
  10610. /**
  10611. * Internal only
  10612. * @hidden
  10613. */
  10614. _getProperty(propertyPath: string): string;
  10615. /**
  10616. * Internal only
  10617. * @hidden
  10618. */
  10619. _getEffectiveTarget(target: any, propertyPath: string): any;
  10620. /**
  10621. * Serialize placeholder for child classes
  10622. * @param parent of child
  10623. * @returns the serialized object
  10624. */
  10625. serialize(parent: any): any;
  10626. /**
  10627. * Internal only called by serialize
  10628. * @hidden
  10629. */
  10630. protected _serialize(serializedAction: any, parent?: any): any;
  10631. /**
  10632. * Internal only
  10633. * @hidden
  10634. */
  10635. static _SerializeValueAsString: (value: any) => string;
  10636. /**
  10637. * Internal only
  10638. * @hidden
  10639. */
  10640. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10641. name: string;
  10642. targetType: string;
  10643. value: string;
  10644. };
  10645. }
  10646. }
  10647. declare module "babylonjs/Actions/condition" {
  10648. import { ActionManager } from "babylonjs/Actions/actionManager";
  10649. /**
  10650. * A Condition applied to an Action
  10651. */
  10652. export class Condition {
  10653. /**
  10654. * Internal only - manager for action
  10655. * @hidden
  10656. */
  10657. _actionManager: ActionManager;
  10658. /**
  10659. * Internal only
  10660. * @hidden
  10661. */
  10662. _evaluationId: number;
  10663. /**
  10664. * Internal only
  10665. * @hidden
  10666. */
  10667. _currentResult: boolean;
  10668. /**
  10669. * Creates a new Condition
  10670. * @param actionManager the manager of the action the condition is applied to
  10671. */
  10672. constructor(actionManager: ActionManager);
  10673. /**
  10674. * Check if the current condition is valid
  10675. * @returns a boolean
  10676. */
  10677. isValid(): boolean;
  10678. /**
  10679. * Internal only
  10680. * @hidden
  10681. */
  10682. _getProperty(propertyPath: string): string;
  10683. /**
  10684. * Internal only
  10685. * @hidden
  10686. */
  10687. _getEffectiveTarget(target: any, propertyPath: string): any;
  10688. /**
  10689. * Serialize placeholder for child classes
  10690. * @returns the serialized object
  10691. */
  10692. serialize(): any;
  10693. /**
  10694. * Internal only
  10695. * @hidden
  10696. */
  10697. protected _serialize(serializedCondition: any): any;
  10698. }
  10699. /**
  10700. * Defines specific conditional operators as extensions of Condition
  10701. */
  10702. export class ValueCondition extends Condition {
  10703. /** path to specify the property of the target the conditional operator uses */
  10704. propertyPath: string;
  10705. /** the value compared by the conditional operator against the current value of the property */
  10706. value: any;
  10707. /** the conditional operator, default ValueCondition.IsEqual */
  10708. operator: number;
  10709. /**
  10710. * Internal only
  10711. * @hidden
  10712. */
  10713. private static _IsEqual;
  10714. /**
  10715. * Internal only
  10716. * @hidden
  10717. */
  10718. private static _IsDifferent;
  10719. /**
  10720. * Internal only
  10721. * @hidden
  10722. */
  10723. private static _IsGreater;
  10724. /**
  10725. * Internal only
  10726. * @hidden
  10727. */
  10728. private static _IsLesser;
  10729. /**
  10730. * returns the number for IsEqual
  10731. */
  10732. static readonly IsEqual: number;
  10733. /**
  10734. * Returns the number for IsDifferent
  10735. */
  10736. static readonly IsDifferent: number;
  10737. /**
  10738. * Returns the number for IsGreater
  10739. */
  10740. static readonly IsGreater: number;
  10741. /**
  10742. * Returns the number for IsLesser
  10743. */
  10744. static readonly IsLesser: number;
  10745. /**
  10746. * Internal only The action manager for the condition
  10747. * @hidden
  10748. */
  10749. _actionManager: ActionManager;
  10750. /**
  10751. * Internal only
  10752. * @hidden
  10753. */
  10754. private _target;
  10755. /**
  10756. * Internal only
  10757. * @hidden
  10758. */
  10759. private _effectiveTarget;
  10760. /**
  10761. * Internal only
  10762. * @hidden
  10763. */
  10764. private _property;
  10765. /**
  10766. * Creates a new ValueCondition
  10767. * @param actionManager manager for the action the condition applies to
  10768. * @param target for the action
  10769. * @param propertyPath path to specify the property of the target the conditional operator uses
  10770. * @param value the value compared by the conditional operator against the current value of the property
  10771. * @param operator the conditional operator, default ValueCondition.IsEqual
  10772. */
  10773. constructor(actionManager: ActionManager, target: any,
  10774. /** path to specify the property of the target the conditional operator uses */
  10775. propertyPath: string,
  10776. /** the value compared by the conditional operator against the current value of the property */
  10777. value: any,
  10778. /** the conditional operator, default ValueCondition.IsEqual */
  10779. operator?: number);
  10780. /**
  10781. * Compares the given value with the property value for the specified conditional operator
  10782. * @returns the result of the comparison
  10783. */
  10784. isValid(): boolean;
  10785. /**
  10786. * Serialize the ValueCondition into a JSON compatible object
  10787. * @returns serialization object
  10788. */
  10789. serialize(): any;
  10790. /**
  10791. * Gets the name of the conditional operator for the ValueCondition
  10792. * @param operator the conditional operator
  10793. * @returns the name
  10794. */
  10795. static GetOperatorName(operator: number): string;
  10796. }
  10797. /**
  10798. * Defines a predicate condition as an extension of Condition
  10799. */
  10800. export class PredicateCondition extends Condition {
  10801. /** defines the predicate function used to validate the condition */
  10802. predicate: () => boolean;
  10803. /**
  10804. * Internal only - manager for action
  10805. * @hidden
  10806. */
  10807. _actionManager: ActionManager;
  10808. /**
  10809. * Creates a new PredicateCondition
  10810. * @param actionManager manager for the action the condition applies to
  10811. * @param predicate defines the predicate function used to validate the condition
  10812. */
  10813. constructor(actionManager: ActionManager,
  10814. /** defines the predicate function used to validate the condition */
  10815. predicate: () => boolean);
  10816. /**
  10817. * @returns the validity of the predicate condition
  10818. */
  10819. isValid(): boolean;
  10820. }
  10821. /**
  10822. * Defines a state condition as an extension of Condition
  10823. */
  10824. export class StateCondition extends Condition {
  10825. /** Value to compare with target state */
  10826. value: string;
  10827. /**
  10828. * Internal only - manager for action
  10829. * @hidden
  10830. */
  10831. _actionManager: ActionManager;
  10832. /**
  10833. * Internal only
  10834. * @hidden
  10835. */
  10836. private _target;
  10837. /**
  10838. * Creates a new StateCondition
  10839. * @param actionManager manager for the action the condition applies to
  10840. * @param target of the condition
  10841. * @param value to compare with target state
  10842. */
  10843. constructor(actionManager: ActionManager, target: any,
  10844. /** Value to compare with target state */
  10845. value: string);
  10846. /**
  10847. * Gets a boolean indicating if the current condition is met
  10848. * @returns the validity of the state
  10849. */
  10850. isValid(): boolean;
  10851. /**
  10852. * Serialize the StateCondition into a JSON compatible object
  10853. * @returns serialization object
  10854. */
  10855. serialize(): any;
  10856. }
  10857. }
  10858. declare module "babylonjs/Actions/directActions" {
  10859. import { Action } from "babylonjs/Actions/action";
  10860. import { Condition } from "babylonjs/Actions/condition";
  10861. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10862. /**
  10863. * This defines an action responsible to toggle a boolean once triggered.
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10865. */
  10866. export class SwitchBooleanAction extends Action {
  10867. /**
  10868. * The path to the boolean property in the target object
  10869. */
  10870. propertyPath: string;
  10871. private _target;
  10872. private _effectiveTarget;
  10873. private _property;
  10874. /**
  10875. * Instantiate the action
  10876. * @param triggerOptions defines the trigger options
  10877. * @param target defines the object containing the boolean
  10878. * @param propertyPath defines the path to the boolean property in the target object
  10879. * @param condition defines the trigger related conditions
  10880. */
  10881. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10882. /** @hidden */
  10883. _prepare(): void;
  10884. /**
  10885. * Execute the action toggle the boolean value.
  10886. */
  10887. execute(): void;
  10888. /**
  10889. * Serializes the actions and its related information.
  10890. * @param parent defines the object to serialize in
  10891. * @returns the serialized object
  10892. */
  10893. serialize(parent: any): any;
  10894. }
  10895. /**
  10896. * This defines an action responsible to set a the state field of the target
  10897. * to a desired value once triggered.
  10898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10899. */
  10900. export class SetStateAction extends Action {
  10901. /**
  10902. * The value to store in the state field.
  10903. */
  10904. value: string;
  10905. private _target;
  10906. /**
  10907. * Instantiate the action
  10908. * @param triggerOptions defines the trigger options
  10909. * @param target defines the object containing the state property
  10910. * @param value defines the value to store in the state field
  10911. * @param condition defines the trigger related conditions
  10912. */
  10913. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10914. /**
  10915. * Execute the action and store the value on the target state property.
  10916. */
  10917. execute(): void;
  10918. /**
  10919. * Serializes the actions and its related information.
  10920. * @param parent defines the object to serialize in
  10921. * @returns the serialized object
  10922. */
  10923. serialize(parent: any): any;
  10924. }
  10925. /**
  10926. * This defines an action responsible to set a property of the target
  10927. * to a desired value once triggered.
  10928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10929. */
  10930. export class SetValueAction extends Action {
  10931. /**
  10932. * The path of the property to set in the target.
  10933. */
  10934. propertyPath: string;
  10935. /**
  10936. * The value to set in the property
  10937. */
  10938. value: any;
  10939. private _target;
  10940. private _effectiveTarget;
  10941. private _property;
  10942. /**
  10943. * Instantiate the action
  10944. * @param triggerOptions defines the trigger options
  10945. * @param target defines the object containing the property
  10946. * @param propertyPath defines the path of the property to set in the target
  10947. * @param value defines the value to set in the property
  10948. * @param condition defines the trigger related conditions
  10949. */
  10950. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10951. /** @hidden */
  10952. _prepare(): void;
  10953. /**
  10954. * Execute the action and set the targetted property to the desired value.
  10955. */
  10956. execute(): void;
  10957. /**
  10958. * Serializes the actions and its related information.
  10959. * @param parent defines the object to serialize in
  10960. * @returns the serialized object
  10961. */
  10962. serialize(parent: any): any;
  10963. }
  10964. /**
  10965. * This defines an action responsible to increment the target value
  10966. * to a desired value once triggered.
  10967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10968. */
  10969. export class IncrementValueAction extends Action {
  10970. /**
  10971. * The path of the property to increment in the target.
  10972. */
  10973. propertyPath: string;
  10974. /**
  10975. * The value we should increment the property by.
  10976. */
  10977. value: any;
  10978. private _target;
  10979. private _effectiveTarget;
  10980. private _property;
  10981. /**
  10982. * Instantiate the action
  10983. * @param triggerOptions defines the trigger options
  10984. * @param target defines the object containing the property
  10985. * @param propertyPath defines the path of the property to increment in the target
  10986. * @param value defines the value value we should increment the property by
  10987. * @param condition defines the trigger related conditions
  10988. */
  10989. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10990. /** @hidden */
  10991. _prepare(): void;
  10992. /**
  10993. * Execute the action and increment the target of the value amount.
  10994. */
  10995. execute(): void;
  10996. /**
  10997. * Serializes the actions and its related information.
  10998. * @param parent defines the object to serialize in
  10999. * @returns the serialized object
  11000. */
  11001. serialize(parent: any): any;
  11002. }
  11003. /**
  11004. * This defines an action responsible to start an animation once triggered.
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11006. */
  11007. export class PlayAnimationAction extends Action {
  11008. /**
  11009. * Where the animation should start (animation frame)
  11010. */
  11011. from: number;
  11012. /**
  11013. * Where the animation should stop (animation frame)
  11014. */
  11015. to: number;
  11016. /**
  11017. * Define if the animation should loop or stop after the first play.
  11018. */
  11019. loop?: boolean;
  11020. private _target;
  11021. /**
  11022. * Instantiate the action
  11023. * @param triggerOptions defines the trigger options
  11024. * @param target defines the target animation or animation name
  11025. * @param from defines from where the animation should start (animation frame)
  11026. * @param end defines where the animation should stop (animation frame)
  11027. * @param loop defines if the animation should loop or stop after the first play
  11028. * @param condition defines the trigger related conditions
  11029. */
  11030. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11031. /** @hidden */
  11032. _prepare(): void;
  11033. /**
  11034. * Execute the action and play the animation.
  11035. */
  11036. execute(): void;
  11037. /**
  11038. * Serializes the actions and its related information.
  11039. * @param parent defines the object to serialize in
  11040. * @returns the serialized object
  11041. */
  11042. serialize(parent: any): any;
  11043. }
  11044. /**
  11045. * This defines an action responsible to stop an animation once triggered.
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11047. */
  11048. export class StopAnimationAction extends Action {
  11049. private _target;
  11050. /**
  11051. * Instantiate the action
  11052. * @param triggerOptions defines the trigger options
  11053. * @param target defines the target animation or animation name
  11054. * @param condition defines the trigger related conditions
  11055. */
  11056. constructor(triggerOptions: any, target: any, condition?: Condition);
  11057. /** @hidden */
  11058. _prepare(): void;
  11059. /**
  11060. * Execute the action and stop the animation.
  11061. */
  11062. execute(): void;
  11063. /**
  11064. * Serializes the actions and its related information.
  11065. * @param parent defines the object to serialize in
  11066. * @returns the serialized object
  11067. */
  11068. serialize(parent: any): any;
  11069. }
  11070. /**
  11071. * This defines an action responsible that does nothing once triggered.
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11073. */
  11074. export class DoNothingAction extends Action {
  11075. /**
  11076. * Instantiate the action
  11077. * @param triggerOptions defines the trigger options
  11078. * @param condition defines the trigger related conditions
  11079. */
  11080. constructor(triggerOptions?: any, condition?: Condition);
  11081. /**
  11082. * Execute the action and do nothing.
  11083. */
  11084. execute(): void;
  11085. /**
  11086. * Serializes the actions and its related information.
  11087. * @param parent defines the object to serialize in
  11088. * @returns the serialized object
  11089. */
  11090. serialize(parent: any): any;
  11091. }
  11092. /**
  11093. * This defines an action responsible to trigger several actions once triggered.
  11094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11095. */
  11096. export class CombineAction extends Action {
  11097. /**
  11098. * The list of aggregated animations to run.
  11099. */
  11100. children: Action[];
  11101. /**
  11102. * Instantiate the action
  11103. * @param triggerOptions defines the trigger options
  11104. * @param children defines the list of aggregated animations to run
  11105. * @param condition defines the trigger related conditions
  11106. */
  11107. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11108. /** @hidden */
  11109. _prepare(): void;
  11110. /**
  11111. * Execute the action and executes all the aggregated actions.
  11112. */
  11113. execute(evt: ActionEvent): void;
  11114. /**
  11115. * Serializes the actions and its related information.
  11116. * @param parent defines the object to serialize in
  11117. * @returns the serialized object
  11118. */
  11119. serialize(parent: any): any;
  11120. }
  11121. /**
  11122. * This defines an action responsible to run code (external event) once triggered.
  11123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11124. */
  11125. export class ExecuteCodeAction extends Action {
  11126. /**
  11127. * The callback function to run.
  11128. */
  11129. func: (evt: ActionEvent) => void;
  11130. /**
  11131. * Instantiate the action
  11132. * @param triggerOptions defines the trigger options
  11133. * @param func defines the callback function to run
  11134. * @param condition defines the trigger related conditions
  11135. */
  11136. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11137. /**
  11138. * Execute the action and run the attached code.
  11139. */
  11140. execute(evt: ActionEvent): void;
  11141. }
  11142. /**
  11143. * This defines an action responsible to set the parent property of the target once triggered.
  11144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11145. */
  11146. export class SetParentAction extends Action {
  11147. private _parent;
  11148. private _target;
  11149. /**
  11150. * Instantiate the action
  11151. * @param triggerOptions defines the trigger options
  11152. * @param target defines the target containing the parent property
  11153. * @param parent defines from where the animation should start (animation frame)
  11154. * @param condition defines the trigger related conditions
  11155. */
  11156. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11157. /** @hidden */
  11158. _prepare(): void;
  11159. /**
  11160. * Execute the action and set the parent property.
  11161. */
  11162. execute(): void;
  11163. /**
  11164. * Serializes the actions and its related information.
  11165. * @param parent defines the object to serialize in
  11166. * @returns the serialized object
  11167. */
  11168. serialize(parent: any): any;
  11169. }
  11170. }
  11171. declare module "babylonjs/Actions/actionManager" {
  11172. import { Nullable } from "babylonjs/types";
  11173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11174. import { Scene } from "babylonjs/scene";
  11175. import { IAction } from "babylonjs/Actions/action";
  11176. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11177. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11178. /**
  11179. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11180. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11182. */
  11183. export class ActionManager extends AbstractActionManager {
  11184. /**
  11185. * Nothing
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11187. */
  11188. static readonly NothingTrigger: number;
  11189. /**
  11190. * On pick
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11192. */
  11193. static readonly OnPickTrigger: number;
  11194. /**
  11195. * On left pick
  11196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11197. */
  11198. static readonly OnLeftPickTrigger: number;
  11199. /**
  11200. * On right pick
  11201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11202. */
  11203. static readonly OnRightPickTrigger: number;
  11204. /**
  11205. * On center pick
  11206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11207. */
  11208. static readonly OnCenterPickTrigger: number;
  11209. /**
  11210. * On pick down
  11211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11212. */
  11213. static readonly OnPickDownTrigger: number;
  11214. /**
  11215. * On double pick
  11216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11217. */
  11218. static readonly OnDoublePickTrigger: number;
  11219. /**
  11220. * On pick up
  11221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11222. */
  11223. static readonly OnPickUpTrigger: number;
  11224. /**
  11225. * On pick out.
  11226. * This trigger will only be raised if you also declared a OnPickDown
  11227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11228. */
  11229. static readonly OnPickOutTrigger: number;
  11230. /**
  11231. * On long press
  11232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11233. */
  11234. static readonly OnLongPressTrigger: number;
  11235. /**
  11236. * On pointer over
  11237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11238. */
  11239. static readonly OnPointerOverTrigger: number;
  11240. /**
  11241. * On pointer out
  11242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11243. */
  11244. static readonly OnPointerOutTrigger: number;
  11245. /**
  11246. * On every frame
  11247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11248. */
  11249. static readonly OnEveryFrameTrigger: number;
  11250. /**
  11251. * On intersection enter
  11252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11253. */
  11254. static readonly OnIntersectionEnterTrigger: number;
  11255. /**
  11256. * On intersection exit
  11257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11258. */
  11259. static readonly OnIntersectionExitTrigger: number;
  11260. /**
  11261. * On key down
  11262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11263. */
  11264. static readonly OnKeyDownTrigger: number;
  11265. /**
  11266. * On key up
  11267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11268. */
  11269. static readonly OnKeyUpTrigger: number;
  11270. private _scene;
  11271. /**
  11272. * Creates a new action manager
  11273. * @param scene defines the hosting scene
  11274. */
  11275. constructor(scene: Scene);
  11276. /**
  11277. * Releases all associated resources
  11278. */
  11279. dispose(): void;
  11280. /**
  11281. * Gets hosting scene
  11282. * @returns the hosting scene
  11283. */
  11284. getScene(): Scene;
  11285. /**
  11286. * Does this action manager handles actions of any of the given triggers
  11287. * @param triggers defines the triggers to be tested
  11288. * @return a boolean indicating whether one (or more) of the triggers is handled
  11289. */
  11290. hasSpecificTriggers(triggers: number[]): boolean;
  11291. /**
  11292. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11293. * speed.
  11294. * @param triggerA defines the trigger to be tested
  11295. * @param triggerB defines the trigger to be tested
  11296. * @return a boolean indicating whether one (or more) of the triggers is handled
  11297. */
  11298. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11299. /**
  11300. * Does this action manager handles actions of a given trigger
  11301. * @param trigger defines the trigger to be tested
  11302. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11303. * @return whether the trigger is handled
  11304. */
  11305. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11306. /**
  11307. * Does this action manager has pointer triggers
  11308. */
  11309. readonly hasPointerTriggers: boolean;
  11310. /**
  11311. * Does this action manager has pick triggers
  11312. */
  11313. readonly hasPickTriggers: boolean;
  11314. /**
  11315. * Registers an action to this action manager
  11316. * @param action defines the action to be registered
  11317. * @return the action amended (prepared) after registration
  11318. */
  11319. registerAction(action: IAction): Nullable<IAction>;
  11320. /**
  11321. * Unregisters an action to this action manager
  11322. * @param action defines the action to be unregistered
  11323. * @return a boolean indicating whether the action has been unregistered
  11324. */
  11325. unregisterAction(action: IAction): Boolean;
  11326. /**
  11327. * Process a specific trigger
  11328. * @param trigger defines the trigger to process
  11329. * @param evt defines the event details to be processed
  11330. */
  11331. processTrigger(trigger: number, evt?: IActionEvent): void;
  11332. /** @hidden */
  11333. _getEffectiveTarget(target: any, propertyPath: string): any;
  11334. /** @hidden */
  11335. _getProperty(propertyPath: string): string;
  11336. /**
  11337. * Serialize this manager to a JSON object
  11338. * @param name defines the property name to store this manager
  11339. * @returns a JSON representation of this manager
  11340. */
  11341. serialize(name: string): any;
  11342. /**
  11343. * Creates a new ActionManager from a JSON data
  11344. * @param parsedActions defines the JSON data to read from
  11345. * @param object defines the hosting mesh
  11346. * @param scene defines the hosting scene
  11347. */
  11348. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11349. /**
  11350. * Get a trigger name by index
  11351. * @param trigger defines the trigger index
  11352. * @returns a trigger name
  11353. */
  11354. static GetTriggerName(trigger: number): string;
  11355. }
  11356. }
  11357. declare module "babylonjs/Culling/ray" {
  11358. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11359. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11361. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11362. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11363. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11364. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11365. /**
  11366. * Class representing a ray with position and direction
  11367. */
  11368. export class Ray {
  11369. /** origin point */
  11370. origin: Vector3;
  11371. /** direction */
  11372. direction: Vector3;
  11373. /** length of the ray */
  11374. length: number;
  11375. private static readonly TmpVector3;
  11376. private _tmpRay;
  11377. /**
  11378. * Creates a new ray
  11379. * @param origin origin point
  11380. * @param direction direction
  11381. * @param length length of the ray
  11382. */
  11383. constructor(
  11384. /** origin point */
  11385. origin: Vector3,
  11386. /** direction */
  11387. direction: Vector3,
  11388. /** length of the ray */
  11389. length?: number);
  11390. /**
  11391. * Checks if the ray intersects a box
  11392. * @param minimum bound of the box
  11393. * @param maximum bound of the box
  11394. * @param intersectionTreshold extra extend to be added to the box in all direction
  11395. * @returns if the box was hit
  11396. */
  11397. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11398. /**
  11399. * Checks if the ray intersects a box
  11400. * @param box the bounding box to check
  11401. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11402. * @returns if the box was hit
  11403. */
  11404. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11405. /**
  11406. * If the ray hits a sphere
  11407. * @param sphere the bounding sphere to check
  11408. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11409. * @returns true if it hits the sphere
  11410. */
  11411. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11412. /**
  11413. * If the ray hits a triange
  11414. * @param vertex0 triangle vertex
  11415. * @param vertex1 triangle vertex
  11416. * @param vertex2 triangle vertex
  11417. * @returns intersection information if hit
  11418. */
  11419. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11420. /**
  11421. * Checks if ray intersects a plane
  11422. * @param plane the plane to check
  11423. * @returns the distance away it was hit
  11424. */
  11425. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11426. /**
  11427. * Checks if ray intersects a mesh
  11428. * @param mesh the mesh to check
  11429. * @param fastCheck if only the bounding box should checked
  11430. * @returns picking info of the intersecton
  11431. */
  11432. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11433. /**
  11434. * Checks if ray intersects a mesh
  11435. * @param meshes the meshes to check
  11436. * @param fastCheck if only the bounding box should checked
  11437. * @param results array to store result in
  11438. * @returns Array of picking infos
  11439. */
  11440. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11441. private _comparePickingInfo;
  11442. private static smallnum;
  11443. private static rayl;
  11444. /**
  11445. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11446. * @param sega the first point of the segment to test the intersection against
  11447. * @param segb the second point of the segment to test the intersection against
  11448. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11449. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11450. */
  11451. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11452. /**
  11453. * Update the ray from viewport position
  11454. * @param x position
  11455. * @param y y position
  11456. * @param viewportWidth viewport width
  11457. * @param viewportHeight viewport height
  11458. * @param world world matrix
  11459. * @param view view matrix
  11460. * @param projection projection matrix
  11461. * @returns this ray updated
  11462. */
  11463. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11464. /**
  11465. * Creates a ray with origin and direction of 0,0,0
  11466. * @returns the new ray
  11467. */
  11468. static Zero(): Ray;
  11469. /**
  11470. * Creates a new ray from screen space and viewport
  11471. * @param x position
  11472. * @param y y position
  11473. * @param viewportWidth viewport width
  11474. * @param viewportHeight viewport height
  11475. * @param world world matrix
  11476. * @param view view matrix
  11477. * @param projection projection matrix
  11478. * @returns new ray
  11479. */
  11480. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11481. /**
  11482. * 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
  11483. * transformed to the given world matrix.
  11484. * @param origin The origin point
  11485. * @param end The end point
  11486. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11487. * @returns the new ray
  11488. */
  11489. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11490. /**
  11491. * Transforms a ray by a matrix
  11492. * @param ray ray to transform
  11493. * @param matrix matrix to apply
  11494. * @returns the resulting new ray
  11495. */
  11496. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11497. /**
  11498. * Transforms a ray by a matrix
  11499. * @param ray ray to transform
  11500. * @param matrix matrix to apply
  11501. * @param result ray to store result in
  11502. */
  11503. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11504. /**
  11505. * Unproject a ray from screen space to object space
  11506. * @param sourceX defines the screen space x coordinate to use
  11507. * @param sourceY defines the screen space y coordinate to use
  11508. * @param viewportWidth defines the current width of the viewport
  11509. * @param viewportHeight defines the current height of the viewport
  11510. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11511. * @param view defines the view matrix to use
  11512. * @param projection defines the projection matrix to use
  11513. */
  11514. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11515. }
  11516. /**
  11517. * Type used to define predicate used to select faces when a mesh intersection is detected
  11518. */
  11519. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11520. module "babylonjs/scene" {
  11521. interface Scene {
  11522. /** @hidden */
  11523. _tempPickingRay: Nullable<Ray>;
  11524. /** @hidden */
  11525. _cachedRayForTransform: Ray;
  11526. /** @hidden */
  11527. _pickWithRayInverseMatrix: Matrix;
  11528. /** @hidden */
  11529. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11530. /** @hidden */
  11531. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11532. }
  11533. }
  11534. }
  11535. declare module "babylonjs/sceneComponent" {
  11536. import { Scene } from "babylonjs/scene";
  11537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11538. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11539. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11540. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11541. import { Nullable } from "babylonjs/types";
  11542. import { Camera } from "babylonjs/Cameras/camera";
  11543. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11544. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11545. import { AbstractScene } from "babylonjs/abstractScene";
  11546. /**
  11547. * Groups all the scene component constants in one place to ease maintenance.
  11548. * @hidden
  11549. */
  11550. export class SceneComponentConstants {
  11551. static readonly NAME_EFFECTLAYER: string;
  11552. static readonly NAME_LAYER: string;
  11553. static readonly NAME_LENSFLARESYSTEM: string;
  11554. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11555. static readonly NAME_PARTICLESYSTEM: string;
  11556. static readonly NAME_GAMEPAD: string;
  11557. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11558. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11559. static readonly NAME_DEPTHRENDERER: string;
  11560. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11561. static readonly NAME_SPRITE: string;
  11562. static readonly NAME_OUTLINERENDERER: string;
  11563. static readonly NAME_PROCEDURALTEXTURE: string;
  11564. static readonly NAME_SHADOWGENERATOR: string;
  11565. static readonly NAME_OCTREE: string;
  11566. static readonly NAME_PHYSICSENGINE: string;
  11567. static readonly NAME_AUDIO: string;
  11568. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11569. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11570. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11571. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11572. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11573. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11574. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11575. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11576. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11577. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11578. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11579. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11580. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11581. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11582. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11583. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11584. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11585. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11586. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11587. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11588. static readonly STEP_AFTERRENDER_AUDIO: number;
  11589. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11590. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11591. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11592. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11593. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11594. static readonly STEP_POINTERMOVE_SPRITE: number;
  11595. static readonly STEP_POINTERDOWN_SPRITE: number;
  11596. static readonly STEP_POINTERUP_SPRITE: number;
  11597. }
  11598. /**
  11599. * This represents a scene component.
  11600. *
  11601. * This is used to decouple the dependency the scene is having on the different workloads like
  11602. * layers, post processes...
  11603. */
  11604. export interface ISceneComponent {
  11605. /**
  11606. * The name of the component. Each component must have a unique name.
  11607. */
  11608. name: string;
  11609. /**
  11610. * The scene the component belongs to.
  11611. */
  11612. scene: Scene;
  11613. /**
  11614. * Register the component to one instance of a scene.
  11615. */
  11616. register(): void;
  11617. /**
  11618. * Rebuilds the elements related to this component in case of
  11619. * context lost for instance.
  11620. */
  11621. rebuild(): void;
  11622. /**
  11623. * Disposes the component and the associated ressources.
  11624. */
  11625. dispose(): void;
  11626. }
  11627. /**
  11628. * This represents a SERIALIZABLE scene component.
  11629. *
  11630. * This extends Scene Component to add Serialization methods on top.
  11631. */
  11632. export interface ISceneSerializableComponent extends ISceneComponent {
  11633. /**
  11634. * Adds all the element from the container to the scene
  11635. * @param container the container holding the elements
  11636. */
  11637. addFromContainer(container: AbstractScene): void;
  11638. /**
  11639. * Removes all the elements in the container from the scene
  11640. * @param container contains the elements to remove
  11641. * @param dispose if the removed element should be disposed (default: false)
  11642. */
  11643. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11644. /**
  11645. * Serializes the component data to the specified json object
  11646. * @param serializationObject The object to serialize to
  11647. */
  11648. serialize(serializationObject: any): void;
  11649. }
  11650. /**
  11651. * Strong typing of a Mesh related stage step action
  11652. */
  11653. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11654. /**
  11655. * Strong typing of a Evaluate Sub Mesh related stage step action
  11656. */
  11657. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11658. /**
  11659. * Strong typing of a Active Mesh related stage step action
  11660. */
  11661. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11662. /**
  11663. * Strong typing of a Camera related stage step action
  11664. */
  11665. export type CameraStageAction = (camera: Camera) => void;
  11666. /**
  11667. * Strong typing of a Render Target related stage step action
  11668. */
  11669. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11670. /**
  11671. * Strong typing of a RenderingGroup related stage step action
  11672. */
  11673. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11674. /**
  11675. * Strong typing of a Mesh Render related stage step action
  11676. */
  11677. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11678. /**
  11679. * Strong typing of a simple stage step action
  11680. */
  11681. export type SimpleStageAction = () => void;
  11682. /**
  11683. * Strong typing of a render target action.
  11684. */
  11685. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11686. /**
  11687. * Strong typing of a pointer move action.
  11688. */
  11689. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11690. /**
  11691. * Strong typing of a pointer up/down action.
  11692. */
  11693. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11694. /**
  11695. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11696. * @hidden
  11697. */
  11698. export class Stage<T extends Function> extends Array<{
  11699. index: number;
  11700. component: ISceneComponent;
  11701. action: T;
  11702. }> {
  11703. /**
  11704. * Hide ctor from the rest of the world.
  11705. * @param items The items to add.
  11706. */
  11707. private constructor();
  11708. /**
  11709. * Creates a new Stage.
  11710. * @returns A new instance of a Stage
  11711. */
  11712. static Create<T extends Function>(): Stage<T>;
  11713. /**
  11714. * Registers a step in an ordered way in the targeted stage.
  11715. * @param index Defines the position to register the step in
  11716. * @param component Defines the component attached to the step
  11717. * @param action Defines the action to launch during the step
  11718. */
  11719. registerStep(index: number, component: ISceneComponent, action: T): void;
  11720. /**
  11721. * Clears all the steps from the stage.
  11722. */
  11723. clear(): void;
  11724. }
  11725. }
  11726. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11727. import { Nullable } from "babylonjs/types";
  11728. import { Observable } from "babylonjs/Misc/observable";
  11729. import { Scene } from "babylonjs/scene";
  11730. import { Sprite } from "babylonjs/Sprites/sprite";
  11731. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11732. import { Ray } from "babylonjs/Culling/ray";
  11733. import { Camera } from "babylonjs/Cameras/camera";
  11734. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11735. import { ISceneComponent } from "babylonjs/sceneComponent";
  11736. module "babylonjs/scene" {
  11737. interface Scene {
  11738. /** @hidden */
  11739. _pointerOverSprite: Nullable<Sprite>;
  11740. /** @hidden */
  11741. _pickedDownSprite: Nullable<Sprite>;
  11742. /** @hidden */
  11743. _tempSpritePickingRay: Nullable<Ray>;
  11744. /**
  11745. * All of the sprite managers added to this scene
  11746. * @see http://doc.babylonjs.com/babylon101/sprites
  11747. */
  11748. spriteManagers: Array<ISpriteManager>;
  11749. /**
  11750. * An event triggered when sprites rendering is about to start
  11751. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11752. */
  11753. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11754. /**
  11755. * An event triggered when sprites rendering is done
  11756. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11757. */
  11758. onAfterSpritesRenderingObservable: Observable<Scene>;
  11759. /** @hidden */
  11760. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11761. /** Launch a ray to try to pick a sprite in the scene
  11762. * @param x position on screen
  11763. * @param y position on screen
  11764. * @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
  11765. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11766. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11767. * @returns a PickingInfo
  11768. */
  11769. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11770. /** Use the given ray to pick a sprite in the scene
  11771. * @param ray The ray (in world space) to use to pick meshes
  11772. * @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
  11773. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11774. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11775. * @returns a PickingInfo
  11776. */
  11777. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11778. /**
  11779. * Force the sprite under the pointer
  11780. * @param sprite defines the sprite to use
  11781. */
  11782. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11783. /**
  11784. * Gets the sprite under the pointer
  11785. * @returns a Sprite or null if no sprite is under the pointer
  11786. */
  11787. getPointerOverSprite(): Nullable<Sprite>;
  11788. }
  11789. }
  11790. /**
  11791. * Defines the sprite scene component responsible to manage sprites
  11792. * in a given scene.
  11793. */
  11794. export class SpriteSceneComponent implements ISceneComponent {
  11795. /**
  11796. * The component name helpfull to identify the component in the list of scene components.
  11797. */
  11798. readonly name: string;
  11799. /**
  11800. * The scene the component belongs to.
  11801. */
  11802. scene: Scene;
  11803. /** @hidden */
  11804. private _spritePredicate;
  11805. /**
  11806. * Creates a new instance of the component for the given scene
  11807. * @param scene Defines the scene to register the component in
  11808. */
  11809. constructor(scene: Scene);
  11810. /**
  11811. * Registers the component in a given scene
  11812. */
  11813. register(): void;
  11814. /**
  11815. * Rebuilds the elements related to this component in case of
  11816. * context lost for instance.
  11817. */
  11818. rebuild(): void;
  11819. /**
  11820. * Disposes the component and the associated ressources.
  11821. */
  11822. dispose(): void;
  11823. private _pickSpriteButKeepRay;
  11824. private _pointerMove;
  11825. private _pointerDown;
  11826. private _pointerUp;
  11827. }
  11828. }
  11829. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11830. /** @hidden */
  11831. export var fogFragmentDeclaration: {
  11832. name: string;
  11833. shader: string;
  11834. };
  11835. }
  11836. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11837. /** @hidden */
  11838. export var fogFragment: {
  11839. name: string;
  11840. shader: string;
  11841. };
  11842. }
  11843. declare module "babylonjs/Shaders/sprites.fragment" {
  11844. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11845. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11846. /** @hidden */
  11847. export var spritesPixelShader: {
  11848. name: string;
  11849. shader: string;
  11850. };
  11851. }
  11852. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11853. /** @hidden */
  11854. export var fogVertexDeclaration: {
  11855. name: string;
  11856. shader: string;
  11857. };
  11858. }
  11859. declare module "babylonjs/Shaders/sprites.vertex" {
  11860. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11861. /** @hidden */
  11862. export var spritesVertexShader: {
  11863. name: string;
  11864. shader: string;
  11865. };
  11866. }
  11867. declare module "babylonjs/Sprites/spriteManager" {
  11868. import { IDisposable, Scene } from "babylonjs/scene";
  11869. import { Nullable } from "babylonjs/types";
  11870. import { Observable } from "babylonjs/Misc/observable";
  11871. import { Sprite } from "babylonjs/Sprites/sprite";
  11872. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11873. import { Camera } from "babylonjs/Cameras/camera";
  11874. import { Texture } from "babylonjs/Materials/Textures/texture";
  11875. import "babylonjs/Shaders/sprites.fragment";
  11876. import "babylonjs/Shaders/sprites.vertex";
  11877. import { Ray } from "babylonjs/Culling/ray";
  11878. /**
  11879. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11880. */
  11881. export interface ISpriteManager extends IDisposable {
  11882. /**
  11883. * Restricts the camera to viewing objects with the same layerMask.
  11884. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11885. */
  11886. layerMask: number;
  11887. /**
  11888. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11889. */
  11890. isPickable: boolean;
  11891. /**
  11892. * Specifies the rendering group id for this mesh (0 by default)
  11893. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11894. */
  11895. renderingGroupId: number;
  11896. /**
  11897. * Defines the list of sprites managed by the manager.
  11898. */
  11899. sprites: Array<Sprite>;
  11900. /**
  11901. * Tests the intersection of a sprite with a specific ray.
  11902. * @param ray The ray we are sending to test the collision
  11903. * @param camera The camera space we are sending rays in
  11904. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11905. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11906. * @returns picking info or null.
  11907. */
  11908. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11909. /**
  11910. * Renders the list of sprites on screen.
  11911. */
  11912. render(): void;
  11913. }
  11914. /**
  11915. * Class used to manage multiple sprites on the same spritesheet
  11916. * @see http://doc.babylonjs.com/babylon101/sprites
  11917. */
  11918. export class SpriteManager implements ISpriteManager {
  11919. /** defines the manager's name */
  11920. name: string;
  11921. /** Gets the list of sprites */
  11922. sprites: Sprite[];
  11923. /** Gets or sets the rendering group id (0 by default) */
  11924. renderingGroupId: number;
  11925. /** Gets or sets camera layer mask */
  11926. layerMask: number;
  11927. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11928. fogEnabled: boolean;
  11929. /** Gets or sets a boolean indicating if the sprites are pickable */
  11930. isPickable: boolean;
  11931. /** Defines the default width of a cell in the spritesheet */
  11932. cellWidth: number;
  11933. /** Defines the default height of a cell in the spritesheet */
  11934. cellHeight: number;
  11935. /**
  11936. * An event triggered when the manager is disposed.
  11937. */
  11938. onDisposeObservable: Observable<SpriteManager>;
  11939. private _onDisposeObserver;
  11940. /**
  11941. * Callback called when the manager is disposed
  11942. */
  11943. onDispose: () => void;
  11944. private _capacity;
  11945. private _spriteTexture;
  11946. private _epsilon;
  11947. private _scene;
  11948. private _vertexData;
  11949. private _buffer;
  11950. private _vertexBuffers;
  11951. private _indexBuffer;
  11952. private _effectBase;
  11953. private _effectFog;
  11954. /**
  11955. * Gets or sets the spritesheet texture
  11956. */
  11957. texture: Texture;
  11958. /**
  11959. * Creates a new sprite manager
  11960. * @param name defines the manager's name
  11961. * @param imgUrl defines the sprite sheet url
  11962. * @param capacity defines the maximum allowed number of sprites
  11963. * @param cellSize defines the size of a sprite cell
  11964. * @param scene defines the hosting scene
  11965. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11966. * @param samplingMode defines the smapling mode to use with spritesheet
  11967. */
  11968. constructor(
  11969. /** defines the manager's name */
  11970. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11971. private _appendSpriteVertex;
  11972. /**
  11973. * Intersects the sprites with a ray
  11974. * @param ray defines the ray to intersect with
  11975. * @param camera defines the current active camera
  11976. * @param predicate defines a predicate used to select candidate sprites
  11977. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11978. * @returns null if no hit or a PickingInfo
  11979. */
  11980. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11981. /**
  11982. * Render all child sprites
  11983. */
  11984. render(): void;
  11985. /**
  11986. * Release associated resources
  11987. */
  11988. dispose(): void;
  11989. }
  11990. }
  11991. declare module "babylonjs/Sprites/sprite" {
  11992. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11993. import { Nullable } from "babylonjs/types";
  11994. import { ActionManager } from "babylonjs/Actions/actionManager";
  11995. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11996. /**
  11997. * Class used to represent a sprite
  11998. * @see http://doc.babylonjs.com/babylon101/sprites
  11999. */
  12000. export class Sprite {
  12001. /** defines the name */
  12002. name: string;
  12003. /** Gets or sets the current world position */
  12004. position: Vector3;
  12005. /** Gets or sets the main color */
  12006. color: Color4;
  12007. /** Gets or sets the width */
  12008. width: number;
  12009. /** Gets or sets the height */
  12010. height: number;
  12011. /** Gets or sets rotation angle */
  12012. angle: number;
  12013. /** Gets or sets the cell index in the sprite sheet */
  12014. cellIndex: number;
  12015. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12016. invertU: number;
  12017. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12018. invertV: number;
  12019. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12020. disposeWhenFinishedAnimating: boolean;
  12021. /** Gets the list of attached animations */
  12022. animations: Animation[];
  12023. /** Gets or sets a boolean indicating if the sprite can be picked */
  12024. isPickable: boolean;
  12025. /**
  12026. * Gets or sets the associated action manager
  12027. */
  12028. actionManager: Nullable<ActionManager>;
  12029. private _animationStarted;
  12030. private _loopAnimation;
  12031. private _fromIndex;
  12032. private _toIndex;
  12033. private _delay;
  12034. private _direction;
  12035. private _manager;
  12036. private _time;
  12037. private _onAnimationEnd;
  12038. /**
  12039. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12040. */
  12041. isVisible: boolean;
  12042. /**
  12043. * Gets or sets the sprite size
  12044. */
  12045. size: number;
  12046. /**
  12047. * Creates a new Sprite
  12048. * @param name defines the name
  12049. * @param manager defines the manager
  12050. */
  12051. constructor(
  12052. /** defines the name */
  12053. name: string, manager: ISpriteManager);
  12054. /**
  12055. * Starts an animation
  12056. * @param from defines the initial key
  12057. * @param to defines the end key
  12058. * @param loop defines if the animation must loop
  12059. * @param delay defines the start delay (in ms)
  12060. * @param onAnimationEnd defines a callback to call when animation ends
  12061. */
  12062. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12063. /** Stops current animation (if any) */
  12064. stopAnimation(): void;
  12065. /** @hidden */
  12066. _animate(deltaTime: number): void;
  12067. /** Release associated resources */
  12068. dispose(): void;
  12069. }
  12070. }
  12071. declare module "babylonjs/Collisions/pickingInfo" {
  12072. import { Nullable } from "babylonjs/types";
  12073. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12075. import { Sprite } from "babylonjs/Sprites/sprite";
  12076. import { Ray } from "babylonjs/Culling/ray";
  12077. /**
  12078. * Information about the result of picking within a scene
  12079. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12080. */
  12081. export class PickingInfo {
  12082. /** @hidden */
  12083. _pickingUnavailable: boolean;
  12084. /**
  12085. * If the pick collided with an object
  12086. */
  12087. hit: boolean;
  12088. /**
  12089. * Distance away where the pick collided
  12090. */
  12091. distance: number;
  12092. /**
  12093. * The location of pick collision
  12094. */
  12095. pickedPoint: Nullable<Vector3>;
  12096. /**
  12097. * The mesh corresponding the the pick collision
  12098. */
  12099. pickedMesh: Nullable<AbstractMesh>;
  12100. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12101. bu: number;
  12102. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12103. bv: number;
  12104. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12105. faceId: number;
  12106. /** Id of the the submesh that was picked */
  12107. subMeshId: number;
  12108. /** If a sprite was picked, this will be the sprite the pick collided with */
  12109. pickedSprite: Nullable<Sprite>;
  12110. /**
  12111. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12112. */
  12113. originMesh: Nullable<AbstractMesh>;
  12114. /**
  12115. * The ray that was used to perform the picking.
  12116. */
  12117. ray: Nullable<Ray>;
  12118. /**
  12119. * Gets the normal correspodning to the face the pick collided with
  12120. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12121. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12122. * @returns The normal correspodning to the face the pick collided with
  12123. */
  12124. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12125. /**
  12126. * Gets the texture coordinates of where the pick occured
  12127. * @returns the vector containing the coordnates of the texture
  12128. */
  12129. getTextureCoordinates(): Nullable<Vector2>;
  12130. }
  12131. }
  12132. declare module "babylonjs/Events/pointerEvents" {
  12133. import { Nullable } from "babylonjs/types";
  12134. import { Vector2 } from "babylonjs/Maths/math";
  12135. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12136. import { Ray } from "babylonjs/Culling/ray";
  12137. /**
  12138. * Gather the list of pointer event types as constants.
  12139. */
  12140. export class PointerEventTypes {
  12141. /**
  12142. * 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.
  12143. */
  12144. static readonly POINTERDOWN: number;
  12145. /**
  12146. * The pointerup event is fired when a pointer is no longer active.
  12147. */
  12148. static readonly POINTERUP: number;
  12149. /**
  12150. * The pointermove event is fired when a pointer changes coordinates.
  12151. */
  12152. static readonly POINTERMOVE: number;
  12153. /**
  12154. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12155. */
  12156. static readonly POINTERWHEEL: number;
  12157. /**
  12158. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12159. */
  12160. static readonly POINTERPICK: number;
  12161. /**
  12162. * The pointertap event is fired when a the object has been touched and released without drag.
  12163. */
  12164. static readonly POINTERTAP: number;
  12165. /**
  12166. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12167. */
  12168. static readonly POINTERDOUBLETAP: number;
  12169. }
  12170. /**
  12171. * Base class of pointer info types.
  12172. */
  12173. export class PointerInfoBase {
  12174. /**
  12175. * Defines the type of event (PointerEventTypes)
  12176. */
  12177. type: number;
  12178. /**
  12179. * Defines the related dom event
  12180. */
  12181. event: PointerEvent | MouseWheelEvent;
  12182. /**
  12183. * Instantiates the base class of pointers info.
  12184. * @param type Defines the type of event (PointerEventTypes)
  12185. * @param event Defines the related dom event
  12186. */
  12187. constructor(
  12188. /**
  12189. * Defines the type of event (PointerEventTypes)
  12190. */
  12191. type: number,
  12192. /**
  12193. * Defines the related dom event
  12194. */
  12195. event: PointerEvent | MouseWheelEvent);
  12196. }
  12197. /**
  12198. * This class is used to store pointer related info for the onPrePointerObservable event.
  12199. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12200. */
  12201. export class PointerInfoPre extends PointerInfoBase {
  12202. /**
  12203. * Ray from a pointer if availible (eg. 6dof controller)
  12204. */
  12205. ray: Nullable<Ray>;
  12206. /**
  12207. * Defines the local position of the pointer on the canvas.
  12208. */
  12209. localPosition: Vector2;
  12210. /**
  12211. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12212. */
  12213. skipOnPointerObservable: boolean;
  12214. /**
  12215. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12216. * @param type Defines the type of event (PointerEventTypes)
  12217. * @param event Defines the related dom event
  12218. * @param localX Defines the local x coordinates of the pointer when the event occured
  12219. * @param localY Defines the local y coordinates of the pointer when the event occured
  12220. */
  12221. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12222. }
  12223. /**
  12224. * This type contains all the data related to a pointer event in Babylon.js.
  12225. * 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.
  12226. */
  12227. export class PointerInfo extends PointerInfoBase {
  12228. /**
  12229. * Defines the picking info associated to the info (if any)\
  12230. */
  12231. pickInfo: Nullable<PickingInfo>;
  12232. /**
  12233. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12234. * @param type Defines the type of event (PointerEventTypes)
  12235. * @param event Defines the related dom event
  12236. * @param pickInfo Defines the picking info associated to the info (if any)\
  12237. */
  12238. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12239. /**
  12240. * Defines the picking info associated to the info (if any)\
  12241. */
  12242. pickInfo: Nullable<PickingInfo>);
  12243. }
  12244. /**
  12245. * Data relating to a touch event on the screen.
  12246. */
  12247. export interface PointerTouch {
  12248. /**
  12249. * X coordinate of touch.
  12250. */
  12251. x: number;
  12252. /**
  12253. * Y coordinate of touch.
  12254. */
  12255. y: number;
  12256. /**
  12257. * Id of touch. Unique for each finger.
  12258. */
  12259. pointerId: number;
  12260. /**
  12261. * Event type passed from DOM.
  12262. */
  12263. type: any;
  12264. }
  12265. }
  12266. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12267. import { Observable } from "babylonjs/Misc/observable";
  12268. import { Nullable } from "babylonjs/types";
  12269. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12270. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12271. /**
  12272. * Manage the mouse inputs to control the movement of a free camera.
  12273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12274. */
  12275. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12276. /**
  12277. * Define if touch is enabled in the mouse input
  12278. */
  12279. touchEnabled: boolean;
  12280. /**
  12281. * Defines the camera the input is attached to.
  12282. */
  12283. camera: FreeCamera;
  12284. /**
  12285. * Defines the buttons associated with the input to handle camera move.
  12286. */
  12287. buttons: number[];
  12288. /**
  12289. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12290. */
  12291. angularSensibility: number;
  12292. private _pointerInput;
  12293. private _onMouseMove;
  12294. private _observer;
  12295. private previousPosition;
  12296. /**
  12297. * Observable for when a pointer move event occurs containing the move offset
  12298. */
  12299. onPointerMovedObservable: Observable<{
  12300. offsetX: number;
  12301. offsetY: number;
  12302. }>;
  12303. /**
  12304. * @hidden
  12305. * If the camera should be rotated automatically based on pointer movement
  12306. */
  12307. _allowCameraRotation: boolean;
  12308. /**
  12309. * Manage the mouse inputs to control the movement of a free camera.
  12310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12311. * @param touchEnabled Defines if touch is enabled or not
  12312. */
  12313. constructor(
  12314. /**
  12315. * Define if touch is enabled in the mouse input
  12316. */
  12317. touchEnabled?: boolean);
  12318. /**
  12319. * Attach the input controls to a specific dom element to get the input from.
  12320. * @param element Defines the element the controls should be listened from
  12321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12322. */
  12323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12324. /**
  12325. * Called on JS contextmenu event.
  12326. * Override this method to provide functionality.
  12327. */
  12328. protected onContextMenu(evt: PointerEvent): void;
  12329. /**
  12330. * Detach the current controls from the specified dom element.
  12331. * @param element Defines the element to stop listening the inputs from
  12332. */
  12333. detachControl(element: Nullable<HTMLElement>): void;
  12334. /**
  12335. * Gets the class name of the current intput.
  12336. * @returns the class name
  12337. */
  12338. getClassName(): string;
  12339. /**
  12340. * Get the friendly name associated with the input class.
  12341. * @returns the input friendly name
  12342. */
  12343. getSimpleName(): string;
  12344. }
  12345. }
  12346. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12347. import { Nullable } from "babylonjs/types";
  12348. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12349. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12350. /**
  12351. * Manage the touch inputs to control the movement of a free camera.
  12352. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12353. */
  12354. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12355. /**
  12356. * Defines the camera the input is attached to.
  12357. */
  12358. camera: FreeCamera;
  12359. /**
  12360. * Defines the touch sensibility for rotation.
  12361. * The higher the faster.
  12362. */
  12363. touchAngularSensibility: number;
  12364. /**
  12365. * Defines the touch sensibility for move.
  12366. * The higher the faster.
  12367. */
  12368. touchMoveSensibility: number;
  12369. private _offsetX;
  12370. private _offsetY;
  12371. private _pointerPressed;
  12372. private _pointerInput;
  12373. private _observer;
  12374. private _onLostFocus;
  12375. /**
  12376. * Attach the input controls to a specific dom element to get the input from.
  12377. * @param element Defines the element the controls should be listened from
  12378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12379. */
  12380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12381. /**
  12382. * Detach the current controls from the specified dom element.
  12383. * @param element Defines the element to stop listening the inputs from
  12384. */
  12385. detachControl(element: Nullable<HTMLElement>): void;
  12386. /**
  12387. * Update the current camera state depending on the inputs that have been used this frame.
  12388. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12389. */
  12390. checkInputs(): void;
  12391. /**
  12392. * Gets the class name of the current intput.
  12393. * @returns the class name
  12394. */
  12395. getClassName(): string;
  12396. /**
  12397. * Get the friendly name associated with the input class.
  12398. * @returns the input friendly name
  12399. */
  12400. getSimpleName(): string;
  12401. }
  12402. }
  12403. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12404. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12405. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12406. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12407. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12408. import { Nullable } from "babylonjs/types";
  12409. /**
  12410. * Default Inputs manager for the FreeCamera.
  12411. * It groups all the default supported inputs for ease of use.
  12412. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12413. */
  12414. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12415. /**
  12416. * @hidden
  12417. */
  12418. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12419. /**
  12420. * @hidden
  12421. */
  12422. _mouseInput: Nullable<FreeCameraMouseInput>;
  12423. /**
  12424. * Instantiates a new FreeCameraInputsManager.
  12425. * @param camera Defines the camera the inputs belong to
  12426. */
  12427. constructor(camera: FreeCamera);
  12428. /**
  12429. * Add keyboard input support to the input manager.
  12430. * @returns the current input manager
  12431. */
  12432. addKeyboard(): FreeCameraInputsManager;
  12433. /**
  12434. * Add mouse input support to the input manager.
  12435. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12436. * @returns the current input manager
  12437. */
  12438. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12439. /**
  12440. * Removes the mouse input support from the manager
  12441. * @returns the current input manager
  12442. */
  12443. removeMouse(): FreeCameraInputsManager;
  12444. /**
  12445. * Add touch input support to the input manager.
  12446. * @returns the current input manager
  12447. */
  12448. addTouch(): FreeCameraInputsManager;
  12449. }
  12450. }
  12451. declare module "babylonjs/Cameras/freeCamera" {
  12452. import { Vector3 } from "babylonjs/Maths/math";
  12453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12454. import { Scene } from "babylonjs/scene";
  12455. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12456. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12457. /**
  12458. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12459. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12460. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12461. */
  12462. export class FreeCamera extends TargetCamera {
  12463. /**
  12464. * Define the collision ellipsoid of the camera.
  12465. * This is helpful to simulate a camera body like the player body around the camera
  12466. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12467. */
  12468. ellipsoid: Vector3;
  12469. /**
  12470. * Define an offset for the position of the ellipsoid around the camera.
  12471. * This can be helpful to determine the center of the body near the gravity center of the body
  12472. * instead of its head.
  12473. */
  12474. ellipsoidOffset: Vector3;
  12475. /**
  12476. * Enable or disable collisions of the camera with the rest of the scene objects.
  12477. */
  12478. checkCollisions: boolean;
  12479. /**
  12480. * Enable or disable gravity on the camera.
  12481. */
  12482. applyGravity: boolean;
  12483. /**
  12484. * Define the input manager associated to the camera.
  12485. */
  12486. inputs: FreeCameraInputsManager;
  12487. /**
  12488. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12489. * Higher values reduce sensitivity.
  12490. */
  12491. /**
  12492. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12493. * Higher values reduce sensitivity.
  12494. */
  12495. angularSensibility: number;
  12496. /**
  12497. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12498. */
  12499. keysUp: number[];
  12500. /**
  12501. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12502. */
  12503. keysDown: number[];
  12504. /**
  12505. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12506. */
  12507. keysLeft: number[];
  12508. /**
  12509. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12510. */
  12511. keysRight: number[];
  12512. /**
  12513. * Event raised when the camera collide with a mesh in the scene.
  12514. */
  12515. onCollide: (collidedMesh: AbstractMesh) => void;
  12516. private _collider;
  12517. private _needMoveForGravity;
  12518. private _oldPosition;
  12519. private _diffPosition;
  12520. private _newPosition;
  12521. /** @hidden */
  12522. _localDirection: Vector3;
  12523. /** @hidden */
  12524. _transformedDirection: Vector3;
  12525. /**
  12526. * Instantiates a Free Camera.
  12527. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12528. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12529. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12530. * @param name Define the name of the camera in the scene
  12531. * @param position Define the start position of the camera in the scene
  12532. * @param scene Define the scene the camera belongs to
  12533. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12534. */
  12535. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12536. /**
  12537. * Attached controls to the current camera.
  12538. * @param element Defines the element the controls should be listened from
  12539. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12540. */
  12541. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12542. /**
  12543. * Detach the current controls from the camera.
  12544. * The camera will stop reacting to inputs.
  12545. * @param element Defines the element to stop listening the inputs from
  12546. */
  12547. detachControl(element: HTMLElement): void;
  12548. private _collisionMask;
  12549. /**
  12550. * Define a collision mask to limit the list of object the camera can collide with
  12551. */
  12552. collisionMask: number;
  12553. /** @hidden */
  12554. _collideWithWorld(displacement: Vector3): void;
  12555. private _onCollisionPositionChange;
  12556. /** @hidden */
  12557. _checkInputs(): void;
  12558. /** @hidden */
  12559. _decideIfNeedsToMove(): boolean;
  12560. /** @hidden */
  12561. _updatePosition(): void;
  12562. /**
  12563. * Destroy the camera and release the current resources hold by it.
  12564. */
  12565. dispose(): void;
  12566. /**
  12567. * Gets the current object class name.
  12568. * @return the class name
  12569. */
  12570. getClassName(): string;
  12571. }
  12572. }
  12573. declare module "babylonjs/Gamepads/gamepad" {
  12574. import { Observable } from "babylonjs/Misc/observable";
  12575. /**
  12576. * Represents a gamepad control stick position
  12577. */
  12578. export class StickValues {
  12579. /**
  12580. * The x component of the control stick
  12581. */
  12582. x: number;
  12583. /**
  12584. * The y component of the control stick
  12585. */
  12586. y: number;
  12587. /**
  12588. * Initializes the gamepad x and y control stick values
  12589. * @param x The x component of the gamepad control stick value
  12590. * @param y The y component of the gamepad control stick value
  12591. */
  12592. constructor(
  12593. /**
  12594. * The x component of the control stick
  12595. */
  12596. x: number,
  12597. /**
  12598. * The y component of the control stick
  12599. */
  12600. y: number);
  12601. }
  12602. /**
  12603. * An interface which manages callbacks for gamepad button changes
  12604. */
  12605. export interface GamepadButtonChanges {
  12606. /**
  12607. * Called when a gamepad has been changed
  12608. */
  12609. changed: boolean;
  12610. /**
  12611. * Called when a gamepad press event has been triggered
  12612. */
  12613. pressChanged: boolean;
  12614. /**
  12615. * Called when a touch event has been triggered
  12616. */
  12617. touchChanged: boolean;
  12618. /**
  12619. * Called when a value has changed
  12620. */
  12621. valueChanged: boolean;
  12622. }
  12623. /**
  12624. * Represents a gamepad
  12625. */
  12626. export class Gamepad {
  12627. /**
  12628. * The id of the gamepad
  12629. */
  12630. id: string;
  12631. /**
  12632. * The index of the gamepad
  12633. */
  12634. index: number;
  12635. /**
  12636. * The browser gamepad
  12637. */
  12638. browserGamepad: any;
  12639. /**
  12640. * Specifies what type of gamepad this represents
  12641. */
  12642. type: number;
  12643. private _leftStick;
  12644. private _rightStick;
  12645. /** @hidden */
  12646. _isConnected: boolean;
  12647. private _leftStickAxisX;
  12648. private _leftStickAxisY;
  12649. private _rightStickAxisX;
  12650. private _rightStickAxisY;
  12651. /**
  12652. * Triggered when the left control stick has been changed
  12653. */
  12654. private _onleftstickchanged;
  12655. /**
  12656. * Triggered when the right control stick has been changed
  12657. */
  12658. private _onrightstickchanged;
  12659. /**
  12660. * Represents a gamepad controller
  12661. */
  12662. static GAMEPAD: number;
  12663. /**
  12664. * Represents a generic controller
  12665. */
  12666. static GENERIC: number;
  12667. /**
  12668. * Represents an XBox controller
  12669. */
  12670. static XBOX: number;
  12671. /**
  12672. * Represents a pose-enabled controller
  12673. */
  12674. static POSE_ENABLED: number;
  12675. /**
  12676. * Specifies whether the left control stick should be Y-inverted
  12677. */
  12678. protected _invertLeftStickY: boolean;
  12679. /**
  12680. * Specifies if the gamepad has been connected
  12681. */
  12682. readonly isConnected: boolean;
  12683. /**
  12684. * Initializes the gamepad
  12685. * @param id The id of the gamepad
  12686. * @param index The index of the gamepad
  12687. * @param browserGamepad The browser gamepad
  12688. * @param leftStickX The x component of the left joystick
  12689. * @param leftStickY The y component of the left joystick
  12690. * @param rightStickX The x component of the right joystick
  12691. * @param rightStickY The y component of the right joystick
  12692. */
  12693. constructor(
  12694. /**
  12695. * The id of the gamepad
  12696. */
  12697. id: string,
  12698. /**
  12699. * The index of the gamepad
  12700. */
  12701. index: number,
  12702. /**
  12703. * The browser gamepad
  12704. */
  12705. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12706. /**
  12707. * Callback triggered when the left joystick has changed
  12708. * @param callback
  12709. */
  12710. onleftstickchanged(callback: (values: StickValues) => void): void;
  12711. /**
  12712. * Callback triggered when the right joystick has changed
  12713. * @param callback
  12714. */
  12715. onrightstickchanged(callback: (values: StickValues) => void): void;
  12716. /**
  12717. * Gets the left joystick
  12718. */
  12719. /**
  12720. * Sets the left joystick values
  12721. */
  12722. leftStick: StickValues;
  12723. /**
  12724. * Gets the right joystick
  12725. */
  12726. /**
  12727. * Sets the right joystick value
  12728. */
  12729. rightStick: StickValues;
  12730. /**
  12731. * Updates the gamepad joystick positions
  12732. */
  12733. update(): void;
  12734. /**
  12735. * Disposes the gamepad
  12736. */
  12737. dispose(): void;
  12738. }
  12739. /**
  12740. * Represents a generic gamepad
  12741. */
  12742. export class GenericPad extends Gamepad {
  12743. private _buttons;
  12744. private _onbuttondown;
  12745. private _onbuttonup;
  12746. /**
  12747. * Observable triggered when a button has been pressed
  12748. */
  12749. onButtonDownObservable: Observable<number>;
  12750. /**
  12751. * Observable triggered when a button has been released
  12752. */
  12753. onButtonUpObservable: Observable<number>;
  12754. /**
  12755. * Callback triggered when a button has been pressed
  12756. * @param callback Called when a button has been pressed
  12757. */
  12758. onbuttondown(callback: (buttonPressed: number) => void): void;
  12759. /**
  12760. * Callback triggered when a button has been released
  12761. * @param callback Called when a button has been released
  12762. */
  12763. onbuttonup(callback: (buttonReleased: number) => void): void;
  12764. /**
  12765. * Initializes the generic gamepad
  12766. * @param id The id of the generic gamepad
  12767. * @param index The index of the generic gamepad
  12768. * @param browserGamepad The browser gamepad
  12769. */
  12770. constructor(id: string, index: number, browserGamepad: any);
  12771. private _setButtonValue;
  12772. /**
  12773. * Updates the generic gamepad
  12774. */
  12775. update(): void;
  12776. /**
  12777. * Disposes the generic gamepad
  12778. */
  12779. dispose(): void;
  12780. }
  12781. }
  12782. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12783. import { Observable } from "babylonjs/Misc/observable";
  12784. import { Nullable } from "babylonjs/types";
  12785. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12786. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12788. import { Ray } from "babylonjs/Culling/ray";
  12789. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12790. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12791. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12792. /**
  12793. * Defines the types of pose enabled controllers that are supported
  12794. */
  12795. export enum PoseEnabledControllerType {
  12796. /**
  12797. * HTC Vive
  12798. */
  12799. VIVE = 0,
  12800. /**
  12801. * Oculus Rift
  12802. */
  12803. OCULUS = 1,
  12804. /**
  12805. * Windows mixed reality
  12806. */
  12807. WINDOWS = 2,
  12808. /**
  12809. * Samsung gear VR
  12810. */
  12811. GEAR_VR = 3,
  12812. /**
  12813. * Google Daydream
  12814. */
  12815. DAYDREAM = 4,
  12816. /**
  12817. * Generic
  12818. */
  12819. GENERIC = 5
  12820. }
  12821. /**
  12822. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12823. */
  12824. export interface MutableGamepadButton {
  12825. /**
  12826. * Value of the button/trigger
  12827. */
  12828. value: number;
  12829. /**
  12830. * If the button/trigger is currently touched
  12831. */
  12832. touched: boolean;
  12833. /**
  12834. * If the button/trigger is currently pressed
  12835. */
  12836. pressed: boolean;
  12837. }
  12838. /**
  12839. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12840. * @hidden
  12841. */
  12842. export interface ExtendedGamepadButton extends GamepadButton {
  12843. /**
  12844. * If the button/trigger is currently pressed
  12845. */
  12846. readonly pressed: boolean;
  12847. /**
  12848. * If the button/trigger is currently touched
  12849. */
  12850. readonly touched: boolean;
  12851. /**
  12852. * Value of the button/trigger
  12853. */
  12854. readonly value: number;
  12855. }
  12856. /** @hidden */
  12857. export interface _GamePadFactory {
  12858. /**
  12859. * Returns wether or not the current gamepad can be created for this type of controller.
  12860. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12861. * @returns true if it can be created, otherwise false
  12862. */
  12863. canCreate(gamepadInfo: any): boolean;
  12864. /**
  12865. * Creates a new instance of the Gamepad.
  12866. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12867. * @returns the new gamepad instance
  12868. */
  12869. create(gamepadInfo: any): Gamepad;
  12870. }
  12871. /**
  12872. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12873. */
  12874. export class PoseEnabledControllerHelper {
  12875. /** @hidden */
  12876. static _ControllerFactories: _GamePadFactory[];
  12877. /** @hidden */
  12878. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12879. /**
  12880. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12881. * @param vrGamepad the gamepad to initialized
  12882. * @returns a vr controller of the type the gamepad identified as
  12883. */
  12884. static InitiateController(vrGamepad: any): Gamepad;
  12885. }
  12886. /**
  12887. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12888. */
  12889. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12890. private _deviceRoomPosition;
  12891. private _deviceRoomRotationQuaternion;
  12892. /**
  12893. * The device position in babylon space
  12894. */
  12895. devicePosition: Vector3;
  12896. /**
  12897. * The device rotation in babylon space
  12898. */
  12899. deviceRotationQuaternion: Quaternion;
  12900. /**
  12901. * The scale factor of the device in babylon space
  12902. */
  12903. deviceScaleFactor: number;
  12904. /**
  12905. * (Likely devicePosition should be used instead) The device position in its room space
  12906. */
  12907. position: Vector3;
  12908. /**
  12909. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12910. */
  12911. rotationQuaternion: Quaternion;
  12912. /**
  12913. * The type of controller (Eg. Windows mixed reality)
  12914. */
  12915. controllerType: PoseEnabledControllerType;
  12916. protected _calculatedPosition: Vector3;
  12917. private _calculatedRotation;
  12918. /**
  12919. * The raw pose from the device
  12920. */
  12921. rawPose: DevicePose;
  12922. private _trackPosition;
  12923. private _maxRotationDistFromHeadset;
  12924. private _draggedRoomRotation;
  12925. /**
  12926. * @hidden
  12927. */
  12928. _disableTrackPosition(fixedPosition: Vector3): void;
  12929. /**
  12930. * Internal, the mesh attached to the controller
  12931. * @hidden
  12932. */
  12933. _mesh: Nullable<AbstractMesh>;
  12934. private _poseControlledCamera;
  12935. private _leftHandSystemQuaternion;
  12936. /**
  12937. * Internal, matrix used to convert room space to babylon space
  12938. * @hidden
  12939. */
  12940. _deviceToWorld: Matrix;
  12941. /**
  12942. * Node to be used when casting a ray from the controller
  12943. * @hidden
  12944. */
  12945. _pointingPoseNode: Nullable<TransformNode>;
  12946. /**
  12947. * Name of the child mesh that can be used to cast a ray from the controller
  12948. */
  12949. static readonly POINTING_POSE: string;
  12950. /**
  12951. * Creates a new PoseEnabledController from a gamepad
  12952. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12953. */
  12954. constructor(browserGamepad: any);
  12955. private _workingMatrix;
  12956. /**
  12957. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12958. */
  12959. update(): void;
  12960. /**
  12961. * Updates only the pose device and mesh without doing any button event checking
  12962. */
  12963. protected _updatePoseAndMesh(): void;
  12964. /**
  12965. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12966. * @param poseData raw pose fromthe device
  12967. */
  12968. updateFromDevice(poseData: DevicePose): void;
  12969. /**
  12970. * @hidden
  12971. */
  12972. _meshAttachedObservable: Observable<AbstractMesh>;
  12973. /**
  12974. * Attaches a mesh to the controller
  12975. * @param mesh the mesh to be attached
  12976. */
  12977. attachToMesh(mesh: AbstractMesh): void;
  12978. /**
  12979. * Attaches the controllers mesh to a camera
  12980. * @param camera the camera the mesh should be attached to
  12981. */
  12982. attachToPoseControlledCamera(camera: TargetCamera): void;
  12983. /**
  12984. * Disposes of the controller
  12985. */
  12986. dispose(): void;
  12987. /**
  12988. * The mesh that is attached to the controller
  12989. */
  12990. readonly mesh: Nullable<AbstractMesh>;
  12991. /**
  12992. * Gets the ray of the controller in the direction the controller is pointing
  12993. * @param length the length the resulting ray should be
  12994. * @returns a ray in the direction the controller is pointing
  12995. */
  12996. getForwardRay(length?: number): Ray;
  12997. }
  12998. }
  12999. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13000. import { Observable } from "babylonjs/Misc/observable";
  13001. import { Scene } from "babylonjs/scene";
  13002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13003. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13004. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13005. /**
  13006. * Defines the WebVRController object that represents controllers tracked in 3D space
  13007. */
  13008. export abstract class WebVRController extends PoseEnabledController {
  13009. /**
  13010. * Internal, the default controller model for the controller
  13011. */
  13012. protected _defaultModel: AbstractMesh;
  13013. /**
  13014. * Fired when the trigger state has changed
  13015. */
  13016. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13017. /**
  13018. * Fired when the main button state has changed
  13019. */
  13020. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13021. /**
  13022. * Fired when the secondary button state has changed
  13023. */
  13024. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13025. /**
  13026. * Fired when the pad state has changed
  13027. */
  13028. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13029. /**
  13030. * Fired when controllers stick values have changed
  13031. */
  13032. onPadValuesChangedObservable: Observable<StickValues>;
  13033. /**
  13034. * Array of button availible on the controller
  13035. */
  13036. protected _buttons: Array<MutableGamepadButton>;
  13037. private _onButtonStateChange;
  13038. /**
  13039. * Fired when a controller button's state has changed
  13040. * @param callback the callback containing the button that was modified
  13041. */
  13042. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13043. /**
  13044. * X and Y axis corrisponding to the controllers joystick
  13045. */
  13046. pad: StickValues;
  13047. /**
  13048. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13049. */
  13050. hand: string;
  13051. /**
  13052. * The default controller model for the controller
  13053. */
  13054. readonly defaultModel: AbstractMesh;
  13055. /**
  13056. * Creates a new WebVRController from a gamepad
  13057. * @param vrGamepad the gamepad that the WebVRController should be created from
  13058. */
  13059. constructor(vrGamepad: any);
  13060. /**
  13061. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13062. */
  13063. update(): void;
  13064. /**
  13065. * Function to be called when a button is modified
  13066. */
  13067. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13068. /**
  13069. * Loads a mesh and attaches it to the controller
  13070. * @param scene the scene the mesh should be added to
  13071. * @param meshLoaded callback for when the mesh has been loaded
  13072. */
  13073. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13074. private _setButtonValue;
  13075. private _changes;
  13076. private _checkChanges;
  13077. /**
  13078. * Disposes of th webVRCOntroller
  13079. */
  13080. dispose(): void;
  13081. }
  13082. }
  13083. declare module "babylonjs/Lights/hemisphericLight" {
  13084. import { Nullable } from "babylonjs/types";
  13085. import { Scene } from "babylonjs/scene";
  13086. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13087. import { Effect } from "babylonjs/Materials/effect";
  13088. import { Light } from "babylonjs/Lights/light";
  13089. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13090. /**
  13091. * The HemisphericLight simulates the ambient environment light,
  13092. * so the passed direction is the light reflection direction, not the incoming direction.
  13093. */
  13094. export class HemisphericLight extends Light {
  13095. /**
  13096. * The groundColor is the light in the opposite direction to the one specified during creation.
  13097. * 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.
  13098. */
  13099. groundColor: Color3;
  13100. /**
  13101. * The light reflection direction, not the incoming direction.
  13102. */
  13103. direction: Vector3;
  13104. /**
  13105. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13106. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13107. * The HemisphericLight can't cast shadows.
  13108. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13109. * @param name The friendly name of the light
  13110. * @param direction The direction of the light reflection
  13111. * @param scene The scene the light belongs to
  13112. */
  13113. constructor(name: string, direction: Vector3, scene: Scene);
  13114. protected _buildUniformLayout(): void;
  13115. /**
  13116. * Returns the string "HemisphericLight".
  13117. * @return The class name
  13118. */
  13119. getClassName(): string;
  13120. /**
  13121. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13122. * Returns the updated direction.
  13123. * @param target The target the direction should point to
  13124. * @return The computed direction
  13125. */
  13126. setDirectionToTarget(target: Vector3): Vector3;
  13127. /**
  13128. * Returns the shadow generator associated to the light.
  13129. * @returns Always null for hemispheric lights because it does not support shadows.
  13130. */
  13131. getShadowGenerator(): Nullable<IShadowGenerator>;
  13132. /**
  13133. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13134. * @param effect The effect to update
  13135. * @param lightIndex The index of the light in the effect to update
  13136. * @returns The hemispheric light
  13137. */
  13138. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13139. /**
  13140. * Computes the world matrix of the node
  13141. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13142. * @param useWasUpdatedFlag defines a reserved property
  13143. * @returns the world matrix
  13144. */
  13145. computeWorldMatrix(): Matrix;
  13146. /**
  13147. * Returns the integer 3.
  13148. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13149. */
  13150. getTypeID(): number;
  13151. /**
  13152. * Prepares the list of defines specific to the light type.
  13153. * @param defines the list of defines
  13154. * @param lightIndex defines the index of the light for the effect
  13155. */
  13156. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13157. }
  13158. }
  13159. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13160. /** @hidden */
  13161. export var vrMultiviewToSingleviewPixelShader: {
  13162. name: string;
  13163. shader: string;
  13164. };
  13165. }
  13166. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13167. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13168. import { Scene } from "babylonjs/scene";
  13169. /**
  13170. * Renders to multiple views with a single draw call
  13171. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13172. */
  13173. export class MultiviewRenderTarget extends RenderTargetTexture {
  13174. /**
  13175. * Creates a multiview render target
  13176. * @param scene scene used with the render target
  13177. * @param size the size of the render target (used for each view)
  13178. */
  13179. constructor(scene: Scene, size?: number | {
  13180. width: number;
  13181. height: number;
  13182. } | {
  13183. ratio: number;
  13184. });
  13185. /**
  13186. * @hidden
  13187. * @param faceIndex the face index, if its a cube texture
  13188. */
  13189. _bindFrameBuffer(faceIndex?: number): void;
  13190. /**
  13191. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13192. * @returns the view count
  13193. */
  13194. getViewCount(): number;
  13195. }
  13196. }
  13197. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13198. import { Camera } from "babylonjs/Cameras/camera";
  13199. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13200. import { Nullable } from "babylonjs/types";
  13201. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13202. import { Matrix } from "babylonjs/Maths/math";
  13203. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13204. module "babylonjs/Engines/engine" {
  13205. interface Engine {
  13206. /**
  13207. * Creates a new multiview render target
  13208. * @param width defines the width of the texture
  13209. * @param height defines the height of the texture
  13210. * @returns the created multiview texture
  13211. */
  13212. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13213. /**
  13214. * Binds a multiview framebuffer to be drawn to
  13215. * @param multiviewTexture texture to bind
  13216. */
  13217. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13218. }
  13219. }
  13220. module "babylonjs/Cameras/camera" {
  13221. interface Camera {
  13222. /**
  13223. * @hidden
  13224. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13225. */
  13226. _useMultiviewToSingleView: boolean;
  13227. /**
  13228. * @hidden
  13229. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13230. */
  13231. _multiviewTexture: Nullable<RenderTargetTexture>;
  13232. /**
  13233. * @hidden
  13234. * ensures the multiview texture of the camera exists and has the specified width/height
  13235. * @param width height to set on the multiview texture
  13236. * @param height width to set on the multiview texture
  13237. */
  13238. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13239. }
  13240. }
  13241. module "babylonjs/scene" {
  13242. interface Scene {
  13243. /** @hidden */
  13244. _transformMatrixR: Matrix;
  13245. /** @hidden */
  13246. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13247. /** @hidden */
  13248. _createMultiviewUbo(): void;
  13249. /** @hidden */
  13250. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13251. /** @hidden */
  13252. _renderMultiviewToSingleView(camera: Camera): void;
  13253. }
  13254. }
  13255. }
  13256. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13257. import { Camera } from "babylonjs/Cameras/camera";
  13258. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13259. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13260. import "babylonjs/Engines/Extensions/engine.multiview";
  13261. /**
  13262. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13263. * This will not be used for webXR as it supports displaying texture arrays directly
  13264. */
  13265. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13266. /**
  13267. * Initializes a VRMultiviewToSingleview
  13268. * @param name name of the post process
  13269. * @param camera camera to be applied to
  13270. * @param scaleFactor scaling factor to the size of the output texture
  13271. */
  13272. constructor(name: string, camera: Camera, scaleFactor: number);
  13273. }
  13274. }
  13275. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13276. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13277. import { Nullable } from "babylonjs/types";
  13278. import { Observable } from "babylonjs/Misc/observable";
  13279. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13280. import { Scene } from "babylonjs/scene";
  13281. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13282. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13283. import { Node } from "babylonjs/node";
  13284. import { Ray } from "babylonjs/Culling/ray";
  13285. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13286. /**
  13287. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13288. * IMPORTANT!! The data is right-hand data.
  13289. * @export
  13290. * @interface DevicePose
  13291. */
  13292. export interface DevicePose {
  13293. /**
  13294. * The position of the device, values in array are [x,y,z].
  13295. */
  13296. readonly position: Nullable<Float32Array>;
  13297. /**
  13298. * The linearVelocity of the device, values in array are [x,y,z].
  13299. */
  13300. readonly linearVelocity: Nullable<Float32Array>;
  13301. /**
  13302. * The linearAcceleration of the device, values in array are [x,y,z].
  13303. */
  13304. readonly linearAcceleration: Nullable<Float32Array>;
  13305. /**
  13306. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13307. */
  13308. readonly orientation: Nullable<Float32Array>;
  13309. /**
  13310. * The angularVelocity of the device, values in array are [x,y,z].
  13311. */
  13312. readonly angularVelocity: Nullable<Float32Array>;
  13313. /**
  13314. * The angularAcceleration of the device, values in array are [x,y,z].
  13315. */
  13316. readonly angularAcceleration: Nullable<Float32Array>;
  13317. }
  13318. /**
  13319. * Interface representing a pose controlled object in Babylon.
  13320. * A pose controlled object has both regular pose values as well as pose values
  13321. * from an external device such as a VR head mounted display
  13322. */
  13323. export interface PoseControlled {
  13324. /**
  13325. * The position of the object in babylon space.
  13326. */
  13327. position: Vector3;
  13328. /**
  13329. * The rotation quaternion of the object in babylon space.
  13330. */
  13331. rotationQuaternion: Quaternion;
  13332. /**
  13333. * The position of the device in babylon space.
  13334. */
  13335. devicePosition?: Vector3;
  13336. /**
  13337. * The rotation quaternion of the device in babylon space.
  13338. */
  13339. deviceRotationQuaternion: Quaternion;
  13340. /**
  13341. * The raw pose coming from the device.
  13342. */
  13343. rawPose: Nullable<DevicePose>;
  13344. /**
  13345. * The scale of the device to be used when translating from device space to babylon space.
  13346. */
  13347. deviceScaleFactor: number;
  13348. /**
  13349. * Updates the poseControlled values based on the input device pose.
  13350. * @param poseData the pose data to update the object with
  13351. */
  13352. updateFromDevice(poseData: DevicePose): void;
  13353. }
  13354. /**
  13355. * Set of options to customize the webVRCamera
  13356. */
  13357. export interface WebVROptions {
  13358. /**
  13359. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13360. */
  13361. trackPosition?: boolean;
  13362. /**
  13363. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13364. */
  13365. positionScale?: number;
  13366. /**
  13367. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13368. */
  13369. displayName?: string;
  13370. /**
  13371. * Should the native controller meshes be initialized. (default: true)
  13372. */
  13373. controllerMeshes?: boolean;
  13374. /**
  13375. * Creating a default HemiLight only on controllers. (default: true)
  13376. */
  13377. defaultLightingOnControllers?: boolean;
  13378. /**
  13379. * If you don't want to use the default VR button of the helper. (default: false)
  13380. */
  13381. useCustomVRButton?: boolean;
  13382. /**
  13383. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13384. */
  13385. customVRButton?: HTMLButtonElement;
  13386. /**
  13387. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13388. */
  13389. rayLength?: number;
  13390. /**
  13391. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13392. */
  13393. defaultHeight?: number;
  13394. /**
  13395. * If multiview should be used if availible (default: false)
  13396. */
  13397. useMultiview?: boolean;
  13398. }
  13399. /**
  13400. * This represents a WebVR camera.
  13401. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13402. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13403. */
  13404. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13405. private webVROptions;
  13406. /**
  13407. * @hidden
  13408. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13409. */
  13410. _vrDevice: any;
  13411. /**
  13412. * The rawPose of the vrDevice.
  13413. */
  13414. rawPose: Nullable<DevicePose>;
  13415. private _onVREnabled;
  13416. private _specsVersion;
  13417. private _attached;
  13418. private _frameData;
  13419. protected _descendants: Array<Node>;
  13420. private _deviceRoomPosition;
  13421. /** @hidden */
  13422. _deviceRoomRotationQuaternion: Quaternion;
  13423. private _standingMatrix;
  13424. /**
  13425. * Represents device position in babylon space.
  13426. */
  13427. devicePosition: Vector3;
  13428. /**
  13429. * Represents device rotation in babylon space.
  13430. */
  13431. deviceRotationQuaternion: Quaternion;
  13432. /**
  13433. * The scale of the device to be used when translating from device space to babylon space.
  13434. */
  13435. deviceScaleFactor: number;
  13436. private _deviceToWorld;
  13437. private _worldToDevice;
  13438. /**
  13439. * References to the webVR controllers for the vrDevice.
  13440. */
  13441. controllers: Array<WebVRController>;
  13442. /**
  13443. * Emits an event when a controller is attached.
  13444. */
  13445. onControllersAttachedObservable: Observable<WebVRController[]>;
  13446. /**
  13447. * Emits an event when a controller's mesh has been loaded;
  13448. */
  13449. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13450. /**
  13451. * Emits an event when the HMD's pose has been updated.
  13452. */
  13453. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13454. private _poseSet;
  13455. /**
  13456. * If the rig cameras be used as parent instead of this camera.
  13457. */
  13458. rigParenting: boolean;
  13459. private _lightOnControllers;
  13460. private _defaultHeight?;
  13461. /**
  13462. * Instantiates a WebVRFreeCamera.
  13463. * @param name The name of the WebVRFreeCamera
  13464. * @param position The starting anchor position for the camera
  13465. * @param scene The scene the camera belongs to
  13466. * @param webVROptions a set of customizable options for the webVRCamera
  13467. */
  13468. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13469. /**
  13470. * Gets the device distance from the ground in meters.
  13471. * @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.
  13472. */
  13473. deviceDistanceToRoomGround(): number;
  13474. /**
  13475. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13476. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13477. */
  13478. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13479. /**
  13480. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13481. * @returns A promise with a boolean set to if the standing matrix is supported.
  13482. */
  13483. useStandingMatrixAsync(): Promise<boolean>;
  13484. /**
  13485. * Disposes the camera
  13486. */
  13487. dispose(): void;
  13488. /**
  13489. * Gets a vrController by name.
  13490. * @param name The name of the controller to retreive
  13491. * @returns the controller matching the name specified or null if not found
  13492. */
  13493. getControllerByName(name: string): Nullable<WebVRController>;
  13494. private _leftController;
  13495. /**
  13496. * The controller corrisponding to the users left hand.
  13497. */
  13498. readonly leftController: Nullable<WebVRController>;
  13499. private _rightController;
  13500. /**
  13501. * The controller corrisponding to the users right hand.
  13502. */
  13503. readonly rightController: Nullable<WebVRController>;
  13504. /**
  13505. * Casts a ray forward from the vrCamera's gaze.
  13506. * @param length Length of the ray (default: 100)
  13507. * @returns the ray corrisponding to the gaze
  13508. */
  13509. getForwardRay(length?: number): Ray;
  13510. /**
  13511. * @hidden
  13512. * Updates the camera based on device's frame data
  13513. */
  13514. _checkInputs(): void;
  13515. /**
  13516. * Updates the poseControlled values based on the input device pose.
  13517. * @param poseData Pose coming from the device
  13518. */
  13519. updateFromDevice(poseData: DevicePose): void;
  13520. private _htmlElementAttached;
  13521. private _detachIfAttached;
  13522. /**
  13523. * WebVR's attach control will start broadcasting frames to the device.
  13524. * Note that in certain browsers (chrome for example) this function must be called
  13525. * within a user-interaction callback. Example:
  13526. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13527. *
  13528. * @param element html element to attach the vrDevice to
  13529. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13530. */
  13531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13532. /**
  13533. * Detaches the camera from the html element and disables VR
  13534. *
  13535. * @param element html element to detach from
  13536. */
  13537. detachControl(element: HTMLElement): void;
  13538. /**
  13539. * @returns the name of this class
  13540. */
  13541. getClassName(): string;
  13542. /**
  13543. * Calls resetPose on the vrDisplay
  13544. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13545. */
  13546. resetToCurrentRotation(): void;
  13547. /**
  13548. * @hidden
  13549. * Updates the rig cameras (left and right eye)
  13550. */
  13551. _updateRigCameras(): void;
  13552. private _workingVector;
  13553. private _oneVector;
  13554. private _workingMatrix;
  13555. private updateCacheCalled;
  13556. private _correctPositionIfNotTrackPosition;
  13557. /**
  13558. * @hidden
  13559. * Updates the cached values of the camera
  13560. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13561. */
  13562. _updateCache(ignoreParentClass?: boolean): void;
  13563. /**
  13564. * @hidden
  13565. * Get current device position in babylon world
  13566. */
  13567. _computeDevicePosition(): void;
  13568. /**
  13569. * Updates the current device position and rotation in the babylon world
  13570. */
  13571. update(): void;
  13572. /**
  13573. * @hidden
  13574. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13575. * @returns an identity matrix
  13576. */
  13577. _getViewMatrix(): Matrix;
  13578. private _tmpMatrix;
  13579. /**
  13580. * This function is called by the two RIG cameras.
  13581. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13582. * @hidden
  13583. */
  13584. _getWebVRViewMatrix(): Matrix;
  13585. /** @hidden */
  13586. _getWebVRProjectionMatrix(): Matrix;
  13587. private _onGamepadConnectedObserver;
  13588. private _onGamepadDisconnectedObserver;
  13589. private _updateCacheWhenTrackingDisabledObserver;
  13590. /**
  13591. * Initializes the controllers and their meshes
  13592. */
  13593. initControllers(): void;
  13594. }
  13595. }
  13596. declare module "babylonjs/PostProcesses/postProcess" {
  13597. import { Nullable } from "babylonjs/types";
  13598. import { SmartArray } from "babylonjs/Misc/smartArray";
  13599. import { Observable } from "babylonjs/Misc/observable";
  13600. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13601. import { Camera } from "babylonjs/Cameras/camera";
  13602. import { Effect } from "babylonjs/Materials/effect";
  13603. import "babylonjs/Shaders/postprocess.vertex";
  13604. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13605. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13606. import { Engine } from "babylonjs/Engines/engine";
  13607. /**
  13608. * Size options for a post process
  13609. */
  13610. export type PostProcessOptions = {
  13611. width: number;
  13612. height: number;
  13613. };
  13614. /**
  13615. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13616. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13617. */
  13618. export class PostProcess {
  13619. /** Name of the PostProcess. */
  13620. name: string;
  13621. /**
  13622. * Gets or sets the unique id of the post process
  13623. */
  13624. uniqueId: number;
  13625. /**
  13626. * Width of the texture to apply the post process on
  13627. */
  13628. width: number;
  13629. /**
  13630. * Height of the texture to apply the post process on
  13631. */
  13632. height: number;
  13633. /**
  13634. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13635. * @hidden
  13636. */
  13637. _outputTexture: Nullable<InternalTexture>;
  13638. /**
  13639. * Sampling mode used by the shader
  13640. * See https://doc.babylonjs.com/classes/3.1/texture
  13641. */
  13642. renderTargetSamplingMode: number;
  13643. /**
  13644. * Clear color to use when screen clearing
  13645. */
  13646. clearColor: Color4;
  13647. /**
  13648. * If the buffer needs to be cleared before applying the post process. (default: true)
  13649. * Should be set to false if shader will overwrite all previous pixels.
  13650. */
  13651. autoClear: boolean;
  13652. /**
  13653. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13654. */
  13655. alphaMode: number;
  13656. /**
  13657. * Sets the setAlphaBlendConstants of the babylon engine
  13658. */
  13659. alphaConstants: Color4;
  13660. /**
  13661. * Animations to be used for the post processing
  13662. */
  13663. animations: import("babylonjs/Animations/animation").Animation[];
  13664. /**
  13665. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13666. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13667. */
  13668. enablePixelPerfectMode: boolean;
  13669. /**
  13670. * Force the postprocess to be applied without taking in account viewport
  13671. */
  13672. forceFullscreenViewport: boolean;
  13673. /**
  13674. * List of inspectable custom properties (used by the Inspector)
  13675. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13676. */
  13677. inspectableCustomProperties: IInspectable[];
  13678. /**
  13679. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13680. *
  13681. * | Value | Type | Description |
  13682. * | ----- | ----------------------------------- | ----------- |
  13683. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13684. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13685. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13686. *
  13687. */
  13688. scaleMode: number;
  13689. /**
  13690. * Force textures to be a power of two (default: false)
  13691. */
  13692. alwaysForcePOT: boolean;
  13693. private _samples;
  13694. /**
  13695. * Number of sample textures (default: 1)
  13696. */
  13697. samples: number;
  13698. /**
  13699. * Modify the scale of the post process to be the same as the viewport (default: false)
  13700. */
  13701. adaptScaleToCurrentViewport: boolean;
  13702. private _camera;
  13703. private _scene;
  13704. private _engine;
  13705. private _options;
  13706. private _reusable;
  13707. private _textureType;
  13708. /**
  13709. * Smart array of input and output textures for the post process.
  13710. * @hidden
  13711. */
  13712. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13713. /**
  13714. * The index in _textures that corresponds to the output texture.
  13715. * @hidden
  13716. */
  13717. _currentRenderTextureInd: number;
  13718. private _effect;
  13719. private _samplers;
  13720. private _fragmentUrl;
  13721. private _vertexUrl;
  13722. private _parameters;
  13723. private _scaleRatio;
  13724. protected _indexParameters: any;
  13725. private _shareOutputWithPostProcess;
  13726. private _texelSize;
  13727. private _forcedOutputTexture;
  13728. /**
  13729. * Returns the fragment url or shader name used in the post process.
  13730. * @returns the fragment url or name in the shader store.
  13731. */
  13732. getEffectName(): string;
  13733. /**
  13734. * An event triggered when the postprocess is activated.
  13735. */
  13736. onActivateObservable: Observable<Camera>;
  13737. private _onActivateObserver;
  13738. /**
  13739. * A function that is added to the onActivateObservable
  13740. */
  13741. onActivate: Nullable<(camera: Camera) => void>;
  13742. /**
  13743. * An event triggered when the postprocess changes its size.
  13744. */
  13745. onSizeChangedObservable: Observable<PostProcess>;
  13746. private _onSizeChangedObserver;
  13747. /**
  13748. * A function that is added to the onSizeChangedObservable
  13749. */
  13750. onSizeChanged: (postProcess: PostProcess) => void;
  13751. /**
  13752. * An event triggered when the postprocess applies its effect.
  13753. */
  13754. onApplyObservable: Observable<Effect>;
  13755. private _onApplyObserver;
  13756. /**
  13757. * A function that is added to the onApplyObservable
  13758. */
  13759. onApply: (effect: Effect) => void;
  13760. /**
  13761. * An event triggered before rendering the postprocess
  13762. */
  13763. onBeforeRenderObservable: Observable<Effect>;
  13764. private _onBeforeRenderObserver;
  13765. /**
  13766. * A function that is added to the onBeforeRenderObservable
  13767. */
  13768. onBeforeRender: (effect: Effect) => void;
  13769. /**
  13770. * An event triggered after rendering the postprocess
  13771. */
  13772. onAfterRenderObservable: Observable<Effect>;
  13773. private _onAfterRenderObserver;
  13774. /**
  13775. * A function that is added to the onAfterRenderObservable
  13776. */
  13777. onAfterRender: (efect: Effect) => void;
  13778. /**
  13779. * 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
  13780. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13781. */
  13782. inputTexture: InternalTexture;
  13783. /**
  13784. * Gets the camera which post process is applied to.
  13785. * @returns The camera the post process is applied to.
  13786. */
  13787. getCamera(): Camera;
  13788. /**
  13789. * Gets the texel size of the postprocess.
  13790. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13791. */
  13792. readonly texelSize: Vector2;
  13793. /**
  13794. * Creates a new instance PostProcess
  13795. * @param name The name of the PostProcess.
  13796. * @param fragmentUrl The url of the fragment shader to be used.
  13797. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13798. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13799. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13800. * @param camera The camera to apply the render pass to.
  13801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13802. * @param engine The engine which the post process will be applied. (default: current engine)
  13803. * @param reusable If the post process can be reused on the same frame. (default: false)
  13804. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13805. * @param textureType Type of textures used when performing the post process. (default: 0)
  13806. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13807. * @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
  13808. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13809. */
  13810. constructor(
  13811. /** Name of the PostProcess. */
  13812. 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);
  13813. /**
  13814. * Gets a string idenfifying the name of the class
  13815. * @returns "PostProcess" string
  13816. */
  13817. getClassName(): string;
  13818. /**
  13819. * Gets the engine which this post process belongs to.
  13820. * @returns The engine the post process was enabled with.
  13821. */
  13822. getEngine(): Engine;
  13823. /**
  13824. * The effect that is created when initializing the post process.
  13825. * @returns The created effect corrisponding the the postprocess.
  13826. */
  13827. getEffect(): Effect;
  13828. /**
  13829. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13830. * @param postProcess The post process to share the output with.
  13831. * @returns This post process.
  13832. */
  13833. shareOutputWith(postProcess: PostProcess): PostProcess;
  13834. /**
  13835. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13836. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13837. */
  13838. useOwnOutput(): void;
  13839. /**
  13840. * Updates the effect with the current post process compile time values and recompiles the shader.
  13841. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13842. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13843. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13844. * @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
  13845. * @param onCompiled Called when the shader has been compiled.
  13846. * @param onError Called if there is an error when compiling a shader.
  13847. */
  13848. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13849. /**
  13850. * The post process is reusable if it can be used multiple times within one frame.
  13851. * @returns If the post process is reusable
  13852. */
  13853. isReusable(): boolean;
  13854. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13855. markTextureDirty(): void;
  13856. /**
  13857. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13858. * 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.
  13859. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13860. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13861. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13862. * @returns The target texture that was bound to be written to.
  13863. */
  13864. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13865. /**
  13866. * If the post process is supported.
  13867. */
  13868. readonly isSupported: boolean;
  13869. /**
  13870. * The aspect ratio of the output texture.
  13871. */
  13872. readonly aspectRatio: number;
  13873. /**
  13874. * Get a value indicating if the post-process is ready to be used
  13875. * @returns true if the post-process is ready (shader is compiled)
  13876. */
  13877. isReady(): boolean;
  13878. /**
  13879. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13880. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13881. */
  13882. apply(): Nullable<Effect>;
  13883. private _disposeTextures;
  13884. /**
  13885. * Disposes the post process.
  13886. * @param camera The camera to dispose the post process on.
  13887. */
  13888. dispose(camera?: Camera): void;
  13889. }
  13890. }
  13891. declare module "babylonjs/PostProcesses/postProcessManager" {
  13892. import { Nullable } from "babylonjs/types";
  13893. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13894. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13895. import { Scene } from "babylonjs/scene";
  13896. /**
  13897. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13898. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13899. */
  13900. export class PostProcessManager {
  13901. private _scene;
  13902. private _indexBuffer;
  13903. private _vertexBuffers;
  13904. /**
  13905. * Creates a new instance PostProcess
  13906. * @param scene The scene that the post process is associated with.
  13907. */
  13908. constructor(scene: Scene);
  13909. private _prepareBuffers;
  13910. private _buildIndexBuffer;
  13911. /**
  13912. * Rebuilds the vertex buffers of the manager.
  13913. * @hidden
  13914. */
  13915. _rebuild(): void;
  13916. /**
  13917. * Prepares a frame to be run through a post process.
  13918. * @param sourceTexture The input texture to the post procesess. (default: null)
  13919. * @param postProcesses An array of post processes to be run. (default: null)
  13920. * @returns True if the post processes were able to be run.
  13921. * @hidden
  13922. */
  13923. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13924. /**
  13925. * Manually render a set of post processes to a texture.
  13926. * @param postProcesses An array of post processes to be run.
  13927. * @param targetTexture The target texture to render to.
  13928. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13929. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13930. * @param lodLevel defines which lod of the texture to render to
  13931. */
  13932. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13933. /**
  13934. * Finalize the result of the output of the postprocesses.
  13935. * @param doNotPresent If true the result will not be displayed to the screen.
  13936. * @param targetTexture The target texture to render to.
  13937. * @param faceIndex The index of the face to bind the target texture to.
  13938. * @param postProcesses The array of post processes to render.
  13939. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13940. * @hidden
  13941. */
  13942. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13943. /**
  13944. * Disposes of the post process manager.
  13945. */
  13946. dispose(): void;
  13947. }
  13948. }
  13949. declare module "babylonjs/Layers/layerSceneComponent" {
  13950. import { Scene } from "babylonjs/scene";
  13951. import { ISceneComponent } from "babylonjs/sceneComponent";
  13952. import { Layer } from "babylonjs/Layers/layer";
  13953. module "babylonjs/abstractScene" {
  13954. interface AbstractScene {
  13955. /**
  13956. * The list of layers (background and foreground) of the scene
  13957. */
  13958. layers: Array<Layer>;
  13959. }
  13960. }
  13961. /**
  13962. * Defines the layer scene component responsible to manage any layers
  13963. * in a given scene.
  13964. */
  13965. export class LayerSceneComponent implements ISceneComponent {
  13966. /**
  13967. * The component name helpfull to identify the component in the list of scene components.
  13968. */
  13969. readonly name: string;
  13970. /**
  13971. * The scene the component belongs to.
  13972. */
  13973. scene: Scene;
  13974. private _engine;
  13975. /**
  13976. * Creates a new instance of the component for the given scene
  13977. * @param scene Defines the scene to register the component in
  13978. */
  13979. constructor(scene: Scene);
  13980. /**
  13981. * Registers the component in a given scene
  13982. */
  13983. register(): void;
  13984. /**
  13985. * Rebuilds the elements related to this component in case of
  13986. * context lost for instance.
  13987. */
  13988. rebuild(): void;
  13989. /**
  13990. * Disposes the component and the associated ressources.
  13991. */
  13992. dispose(): void;
  13993. private _draw;
  13994. private _drawCameraPredicate;
  13995. private _drawCameraBackground;
  13996. private _drawCameraForeground;
  13997. private _drawRenderTargetPredicate;
  13998. private _drawRenderTargetBackground;
  13999. private _drawRenderTargetForeground;
  14000. }
  14001. }
  14002. declare module "babylonjs/Shaders/layer.fragment" {
  14003. /** @hidden */
  14004. export var layerPixelShader: {
  14005. name: string;
  14006. shader: string;
  14007. };
  14008. }
  14009. declare module "babylonjs/Shaders/layer.vertex" {
  14010. /** @hidden */
  14011. export var layerVertexShader: {
  14012. name: string;
  14013. shader: string;
  14014. };
  14015. }
  14016. declare module "babylonjs/Layers/layer" {
  14017. import { Observable } from "babylonjs/Misc/observable";
  14018. import { Nullable } from "babylonjs/types";
  14019. import { Scene } from "babylonjs/scene";
  14020. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14021. import { Texture } from "babylonjs/Materials/Textures/texture";
  14022. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14023. import "babylonjs/Shaders/layer.fragment";
  14024. import "babylonjs/Shaders/layer.vertex";
  14025. /**
  14026. * This represents a full screen 2d layer.
  14027. * This can be useful to display a picture in the background of your scene for instance.
  14028. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14029. */
  14030. export class Layer {
  14031. /**
  14032. * Define the name of the layer.
  14033. */
  14034. name: string;
  14035. /**
  14036. * Define the texture the layer should display.
  14037. */
  14038. texture: Nullable<Texture>;
  14039. /**
  14040. * Is the layer in background or foreground.
  14041. */
  14042. isBackground: boolean;
  14043. /**
  14044. * Define the color of the layer (instead of texture).
  14045. */
  14046. color: Color4;
  14047. /**
  14048. * Define the scale of the layer in order to zoom in out of the texture.
  14049. */
  14050. scale: Vector2;
  14051. /**
  14052. * Define an offset for the layer in order to shift the texture.
  14053. */
  14054. offset: Vector2;
  14055. /**
  14056. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14057. */
  14058. alphaBlendingMode: number;
  14059. /**
  14060. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14061. * Alpha test will not mix with the background color in case of transparency.
  14062. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14063. */
  14064. alphaTest: boolean;
  14065. /**
  14066. * Define a mask to restrict the layer to only some of the scene cameras.
  14067. */
  14068. layerMask: number;
  14069. /**
  14070. * Define the list of render target the layer is visible into.
  14071. */
  14072. renderTargetTextures: RenderTargetTexture[];
  14073. /**
  14074. * Define if the layer is only used in renderTarget or if it also
  14075. * renders in the main frame buffer of the canvas.
  14076. */
  14077. renderOnlyInRenderTargetTextures: boolean;
  14078. private _scene;
  14079. private _vertexBuffers;
  14080. private _indexBuffer;
  14081. private _effect;
  14082. private _alphaTestEffect;
  14083. /**
  14084. * An event triggered when the layer is disposed.
  14085. */
  14086. onDisposeObservable: Observable<Layer>;
  14087. private _onDisposeObserver;
  14088. /**
  14089. * Back compatibility with callback before the onDisposeObservable existed.
  14090. * The set callback will be triggered when the layer has been disposed.
  14091. */
  14092. onDispose: () => void;
  14093. /**
  14094. * An event triggered before rendering the scene
  14095. */
  14096. onBeforeRenderObservable: Observable<Layer>;
  14097. private _onBeforeRenderObserver;
  14098. /**
  14099. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14100. * The set callback will be triggered just before rendering the layer.
  14101. */
  14102. onBeforeRender: () => void;
  14103. /**
  14104. * An event triggered after rendering the scene
  14105. */
  14106. onAfterRenderObservable: Observable<Layer>;
  14107. private _onAfterRenderObserver;
  14108. /**
  14109. * Back compatibility with callback before the onAfterRenderObservable existed.
  14110. * The set callback will be triggered just after rendering the layer.
  14111. */
  14112. onAfterRender: () => void;
  14113. /**
  14114. * Instantiates a new layer.
  14115. * This represents a full screen 2d layer.
  14116. * This can be useful to display a picture in the background of your scene for instance.
  14117. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14118. * @param name Define the name of the layer in the scene
  14119. * @param imgUrl Define the url of the texture to display in the layer
  14120. * @param scene Define the scene the layer belongs to
  14121. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14122. * @param color Defines a color for the layer
  14123. */
  14124. constructor(
  14125. /**
  14126. * Define the name of the layer.
  14127. */
  14128. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14129. private _createIndexBuffer;
  14130. /** @hidden */
  14131. _rebuild(): void;
  14132. /**
  14133. * Renders the layer in the scene.
  14134. */
  14135. render(): void;
  14136. /**
  14137. * Disposes and releases the associated ressources.
  14138. */
  14139. dispose(): void;
  14140. }
  14141. }
  14142. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14143. import { Scene } from "babylonjs/scene";
  14144. import { ISceneComponent } from "babylonjs/sceneComponent";
  14145. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14146. module "babylonjs/abstractScene" {
  14147. interface AbstractScene {
  14148. /**
  14149. * The list of procedural textures added to the scene
  14150. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14151. */
  14152. proceduralTextures: Array<ProceduralTexture>;
  14153. }
  14154. }
  14155. /**
  14156. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14157. * in a given scene.
  14158. */
  14159. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14160. /**
  14161. * The component name helpfull to identify the component in the list of scene components.
  14162. */
  14163. readonly name: string;
  14164. /**
  14165. * The scene the component belongs to.
  14166. */
  14167. scene: Scene;
  14168. /**
  14169. * Creates a new instance of the component for the given scene
  14170. * @param scene Defines the scene to register the component in
  14171. */
  14172. constructor(scene: Scene);
  14173. /**
  14174. * Registers the component in a given scene
  14175. */
  14176. register(): void;
  14177. /**
  14178. * Rebuilds the elements related to this component in case of
  14179. * context lost for instance.
  14180. */
  14181. rebuild(): void;
  14182. /**
  14183. * Disposes the component and the associated ressources.
  14184. */
  14185. dispose(): void;
  14186. private _beforeClear;
  14187. }
  14188. }
  14189. declare module "babylonjs/Shaders/procedural.vertex" {
  14190. /** @hidden */
  14191. export var proceduralVertexShader: {
  14192. name: string;
  14193. shader: string;
  14194. };
  14195. }
  14196. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14197. import { Observable } from "babylonjs/Misc/observable";
  14198. import { Nullable } from "babylonjs/types";
  14199. import { Scene } from "babylonjs/scene";
  14200. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14201. import { Effect } from "babylonjs/Materials/effect";
  14202. import { Texture } from "babylonjs/Materials/Textures/texture";
  14203. import "babylonjs/Shaders/procedural.vertex";
  14204. /**
  14205. * 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.
  14206. * This is the base class of any Procedural texture and contains most of the shareable code.
  14207. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14208. */
  14209. export class ProceduralTexture extends Texture {
  14210. isCube: boolean;
  14211. /**
  14212. * Define if the texture is enabled or not (disabled texture will not render)
  14213. */
  14214. isEnabled: boolean;
  14215. /**
  14216. * Define if the texture must be cleared before rendering (default is true)
  14217. */
  14218. autoClear: boolean;
  14219. /**
  14220. * Callback called when the texture is generated
  14221. */
  14222. onGenerated: () => void;
  14223. /**
  14224. * Event raised when the texture is generated
  14225. */
  14226. onGeneratedObservable: Observable<ProceduralTexture>;
  14227. /** @hidden */
  14228. _generateMipMaps: boolean;
  14229. /** @hidden **/
  14230. _effect: Effect;
  14231. /** @hidden */
  14232. _textures: {
  14233. [key: string]: Texture;
  14234. };
  14235. private _size;
  14236. private _currentRefreshId;
  14237. private _refreshRate;
  14238. private _vertexBuffers;
  14239. private _indexBuffer;
  14240. private _uniforms;
  14241. private _samplers;
  14242. private _fragment;
  14243. private _floats;
  14244. private _ints;
  14245. private _floatsArrays;
  14246. private _colors3;
  14247. private _colors4;
  14248. private _vectors2;
  14249. private _vectors3;
  14250. private _matrices;
  14251. private _fallbackTexture;
  14252. private _fallbackTextureUsed;
  14253. private _engine;
  14254. private _cachedDefines;
  14255. private _contentUpdateId;
  14256. private _contentData;
  14257. /**
  14258. * Instantiates a new procedural texture.
  14259. * 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.
  14260. * This is the base class of any Procedural texture and contains most of the shareable code.
  14261. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14262. * @param name Define the name of the texture
  14263. * @param size Define the size of the texture to create
  14264. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14265. * @param scene Define the scene the texture belongs to
  14266. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14267. * @param generateMipMaps Define if the texture should creates mip maps or not
  14268. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14269. */
  14270. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14271. /**
  14272. * The effect that is created when initializing the post process.
  14273. * @returns The created effect corrisponding the the postprocess.
  14274. */
  14275. getEffect(): Effect;
  14276. /**
  14277. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14278. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14279. */
  14280. getContent(): Nullable<ArrayBufferView>;
  14281. private _createIndexBuffer;
  14282. /** @hidden */
  14283. _rebuild(): void;
  14284. /**
  14285. * Resets the texture in order to recreate its associated resources.
  14286. * This can be called in case of context loss
  14287. */
  14288. reset(): void;
  14289. protected _getDefines(): string;
  14290. /**
  14291. * Is the texture ready to be used ? (rendered at least once)
  14292. * @returns true if ready, otherwise, false.
  14293. */
  14294. isReady(): boolean;
  14295. /**
  14296. * Resets the refresh counter of the texture and start bak from scratch.
  14297. * Could be useful to regenerate the texture if it is setup to render only once.
  14298. */
  14299. resetRefreshCounter(): void;
  14300. /**
  14301. * Set the fragment shader to use in order to render the texture.
  14302. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14303. */
  14304. setFragment(fragment: any): void;
  14305. /**
  14306. * Define the refresh rate of the texture or the rendering frequency.
  14307. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14308. */
  14309. refreshRate: number;
  14310. /** @hidden */
  14311. _shouldRender(): boolean;
  14312. /**
  14313. * Get the size the texture is rendering at.
  14314. * @returns the size (texture is always squared)
  14315. */
  14316. getRenderSize(): number;
  14317. /**
  14318. * Resize the texture to new value.
  14319. * @param size Define the new size the texture should have
  14320. * @param generateMipMaps Define whether the new texture should create mip maps
  14321. */
  14322. resize(size: number, generateMipMaps: boolean): void;
  14323. private _checkUniform;
  14324. /**
  14325. * Set a texture in the shader program used to render.
  14326. * @param name Define the name of the uniform samplers as defined in the shader
  14327. * @param texture Define the texture to bind to this sampler
  14328. * @return the texture itself allowing "fluent" like uniform updates
  14329. */
  14330. setTexture(name: string, texture: Texture): ProceduralTexture;
  14331. /**
  14332. * Set a float in the shader.
  14333. * @param name Define the name of the uniform as defined in the shader
  14334. * @param value Define the value to give to the uniform
  14335. * @return the texture itself allowing "fluent" like uniform updates
  14336. */
  14337. setFloat(name: string, value: number): ProceduralTexture;
  14338. /**
  14339. * Set a int in the shader.
  14340. * @param name Define the name of the uniform as defined in the shader
  14341. * @param value Define the value to give to the uniform
  14342. * @return the texture itself allowing "fluent" like uniform updates
  14343. */
  14344. setInt(name: string, value: number): ProceduralTexture;
  14345. /**
  14346. * Set an array of floats in the shader.
  14347. * @param name Define the name of the uniform as defined in the shader
  14348. * @param value Define the value to give to the uniform
  14349. * @return the texture itself allowing "fluent" like uniform updates
  14350. */
  14351. setFloats(name: string, value: number[]): ProceduralTexture;
  14352. /**
  14353. * Set a vec3 in the shader from a Color3.
  14354. * @param name Define the name of the uniform as defined in the shader
  14355. * @param value Define the value to give to the uniform
  14356. * @return the texture itself allowing "fluent" like uniform updates
  14357. */
  14358. setColor3(name: string, value: Color3): ProceduralTexture;
  14359. /**
  14360. * Set a vec4 in the shader from a Color4.
  14361. * @param name Define the name of the uniform as defined in the shader
  14362. * @param value Define the value to give to the uniform
  14363. * @return the texture itself allowing "fluent" like uniform updates
  14364. */
  14365. setColor4(name: string, value: Color4): ProceduralTexture;
  14366. /**
  14367. * Set a vec2 in the shader from a Vector2.
  14368. * @param name Define the name of the uniform as defined in the shader
  14369. * @param value Define the value to give to the uniform
  14370. * @return the texture itself allowing "fluent" like uniform updates
  14371. */
  14372. setVector2(name: string, value: Vector2): ProceduralTexture;
  14373. /**
  14374. * Set a vec3 in the shader from a Vector3.
  14375. * @param name Define the name of the uniform as defined in the shader
  14376. * @param value Define the value to give to the uniform
  14377. * @return the texture itself allowing "fluent" like uniform updates
  14378. */
  14379. setVector3(name: string, value: Vector3): ProceduralTexture;
  14380. /**
  14381. * Set a mat4 in the shader from a MAtrix.
  14382. * @param name Define the name of the uniform as defined in the shader
  14383. * @param value Define the value to give to the uniform
  14384. * @return the texture itself allowing "fluent" like uniform updates
  14385. */
  14386. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14387. /**
  14388. * Render the texture to its associated render target.
  14389. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14390. */
  14391. render(useCameraPostProcess?: boolean): void;
  14392. /**
  14393. * Clone the texture.
  14394. * @returns the cloned texture
  14395. */
  14396. clone(): ProceduralTexture;
  14397. /**
  14398. * Dispose the texture and release its asoociated resources.
  14399. */
  14400. dispose(): void;
  14401. }
  14402. }
  14403. declare module "babylonjs/Particles/baseParticleSystem" {
  14404. import { Nullable } from "babylonjs/types";
  14405. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14407. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14408. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14409. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14410. import { Scene } from "babylonjs/scene";
  14411. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14412. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14413. import { Texture } from "babylonjs/Materials/Textures/texture";
  14414. import { Animation } from "babylonjs/Animations/animation";
  14415. /**
  14416. * This represents the base class for particle system in Babylon.
  14417. * 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.
  14418. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14419. * @example https://doc.babylonjs.com/babylon101/particles
  14420. */
  14421. export class BaseParticleSystem {
  14422. /**
  14423. * Source color is added to the destination color without alpha affecting the result
  14424. */
  14425. static BLENDMODE_ONEONE: number;
  14426. /**
  14427. * Blend current color and particle color using particle’s alpha
  14428. */
  14429. static BLENDMODE_STANDARD: number;
  14430. /**
  14431. * Add current color and particle color multiplied by particle’s alpha
  14432. */
  14433. static BLENDMODE_ADD: number;
  14434. /**
  14435. * Multiply current color with particle color
  14436. */
  14437. static BLENDMODE_MULTIPLY: number;
  14438. /**
  14439. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14440. */
  14441. static BLENDMODE_MULTIPLYADD: number;
  14442. /**
  14443. * List of animations used by the particle system.
  14444. */
  14445. animations: Animation[];
  14446. /**
  14447. * The id of the Particle system.
  14448. */
  14449. id: string;
  14450. /**
  14451. * The friendly name of the Particle system.
  14452. */
  14453. name: string;
  14454. /**
  14455. * The rendering group used by the Particle system to chose when to render.
  14456. */
  14457. renderingGroupId: number;
  14458. /**
  14459. * The emitter represents the Mesh or position we are attaching the particle system to.
  14460. */
  14461. emitter: Nullable<AbstractMesh | Vector3>;
  14462. /**
  14463. * The maximum number of particles to emit per frame
  14464. */
  14465. emitRate: number;
  14466. /**
  14467. * If you want to launch only a few particles at once, that can be done, as well.
  14468. */
  14469. manualEmitCount: number;
  14470. /**
  14471. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14472. */
  14473. updateSpeed: number;
  14474. /**
  14475. * The amount of time the particle system is running (depends of the overall update speed).
  14476. */
  14477. targetStopDuration: number;
  14478. /**
  14479. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14480. */
  14481. disposeOnStop: boolean;
  14482. /**
  14483. * Minimum power of emitting particles.
  14484. */
  14485. minEmitPower: number;
  14486. /**
  14487. * Maximum power of emitting particles.
  14488. */
  14489. maxEmitPower: number;
  14490. /**
  14491. * Minimum life time of emitting particles.
  14492. */
  14493. minLifeTime: number;
  14494. /**
  14495. * Maximum life time of emitting particles.
  14496. */
  14497. maxLifeTime: number;
  14498. /**
  14499. * Minimum Size of emitting particles.
  14500. */
  14501. minSize: number;
  14502. /**
  14503. * Maximum Size of emitting particles.
  14504. */
  14505. maxSize: number;
  14506. /**
  14507. * Minimum scale of emitting particles on X axis.
  14508. */
  14509. minScaleX: number;
  14510. /**
  14511. * Maximum scale of emitting particles on X axis.
  14512. */
  14513. maxScaleX: number;
  14514. /**
  14515. * Minimum scale of emitting particles on Y axis.
  14516. */
  14517. minScaleY: number;
  14518. /**
  14519. * Maximum scale of emitting particles on Y axis.
  14520. */
  14521. maxScaleY: number;
  14522. /**
  14523. * Gets or sets the minimal initial rotation in radians.
  14524. */
  14525. minInitialRotation: number;
  14526. /**
  14527. * Gets or sets the maximal initial rotation in radians.
  14528. */
  14529. maxInitialRotation: number;
  14530. /**
  14531. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14532. */
  14533. minAngularSpeed: number;
  14534. /**
  14535. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14536. */
  14537. maxAngularSpeed: number;
  14538. /**
  14539. * The texture used to render each particle. (this can be a spritesheet)
  14540. */
  14541. particleTexture: Nullable<Texture>;
  14542. /**
  14543. * The layer mask we are rendering the particles through.
  14544. */
  14545. layerMask: number;
  14546. /**
  14547. * This can help using your own shader to render the particle system.
  14548. * The according effect will be created
  14549. */
  14550. customShader: any;
  14551. /**
  14552. * By default particle system starts as soon as they are created. This prevents the
  14553. * automatic start to happen and let you decide when to start emitting particles.
  14554. */
  14555. preventAutoStart: boolean;
  14556. private _noiseTexture;
  14557. /**
  14558. * Gets or sets a texture used to add random noise to particle positions
  14559. */
  14560. noiseTexture: Nullable<ProceduralTexture>;
  14561. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14562. noiseStrength: Vector3;
  14563. /**
  14564. * Callback triggered when the particle animation is ending.
  14565. */
  14566. onAnimationEnd: Nullable<() => void>;
  14567. /**
  14568. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14569. */
  14570. blendMode: number;
  14571. /**
  14572. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14573. * to override the particles.
  14574. */
  14575. forceDepthWrite: boolean;
  14576. /** 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 */
  14577. preWarmCycles: number;
  14578. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14579. preWarmStepOffset: number;
  14580. /**
  14581. * 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)
  14582. */
  14583. spriteCellChangeSpeed: number;
  14584. /**
  14585. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14586. */
  14587. startSpriteCellID: number;
  14588. /**
  14589. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14590. */
  14591. endSpriteCellID: number;
  14592. /**
  14593. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14594. */
  14595. spriteCellWidth: number;
  14596. /**
  14597. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14598. */
  14599. spriteCellHeight: number;
  14600. /**
  14601. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14602. */
  14603. spriteRandomStartCell: boolean;
  14604. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14605. translationPivot: Vector2;
  14606. /** @hidden */
  14607. protected _isAnimationSheetEnabled: boolean;
  14608. /**
  14609. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14610. */
  14611. beginAnimationOnStart: boolean;
  14612. /**
  14613. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14614. */
  14615. beginAnimationFrom: number;
  14616. /**
  14617. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14618. */
  14619. beginAnimationTo: number;
  14620. /**
  14621. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14622. */
  14623. beginAnimationLoop: boolean;
  14624. /**
  14625. * Gets or sets a world offset applied to all particles
  14626. */
  14627. worldOffset: Vector3;
  14628. /**
  14629. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14630. */
  14631. isAnimationSheetEnabled: boolean;
  14632. /**
  14633. * Get hosting scene
  14634. * @returns the scene
  14635. */
  14636. getScene(): Scene;
  14637. /**
  14638. * You can use gravity if you want to give an orientation to your particles.
  14639. */
  14640. gravity: Vector3;
  14641. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14642. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14643. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14644. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14645. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14646. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14647. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14648. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14649. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14650. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14651. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14652. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14653. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14654. /**
  14655. * Defines the delay in milliseconds before starting the system (0 by default)
  14656. */
  14657. startDelay: number;
  14658. /**
  14659. * Gets the current list of drag gradients.
  14660. * You must use addDragGradient and removeDragGradient to udpate this list
  14661. * @returns the list of drag gradients
  14662. */
  14663. getDragGradients(): Nullable<Array<FactorGradient>>;
  14664. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14665. limitVelocityDamping: number;
  14666. /**
  14667. * Gets the current list of limit velocity gradients.
  14668. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14669. * @returns the list of limit velocity gradients
  14670. */
  14671. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14672. /**
  14673. * Gets the current list of color gradients.
  14674. * You must use addColorGradient and removeColorGradient to udpate this list
  14675. * @returns the list of color gradients
  14676. */
  14677. getColorGradients(): Nullable<Array<ColorGradient>>;
  14678. /**
  14679. * Gets the current list of size gradients.
  14680. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14681. * @returns the list of size gradients
  14682. */
  14683. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14684. /**
  14685. * Gets the current list of color remap gradients.
  14686. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14687. * @returns the list of color remap gradients
  14688. */
  14689. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14690. /**
  14691. * Gets the current list of alpha remap gradients.
  14692. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14693. * @returns the list of alpha remap gradients
  14694. */
  14695. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14696. /**
  14697. * Gets the current list of life time gradients.
  14698. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14699. * @returns the list of life time gradients
  14700. */
  14701. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14702. /**
  14703. * Gets the current list of angular speed gradients.
  14704. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14705. * @returns the list of angular speed gradients
  14706. */
  14707. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14708. /**
  14709. * Gets the current list of velocity gradients.
  14710. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14711. * @returns the list of velocity gradients
  14712. */
  14713. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14714. /**
  14715. * Gets the current list of start size gradients.
  14716. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14717. * @returns the list of start size gradients
  14718. */
  14719. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14720. /**
  14721. * Gets the current list of emit rate gradients.
  14722. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14723. * @returns the list of emit rate gradients
  14724. */
  14725. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14726. /**
  14727. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14728. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14729. */
  14730. direction1: Vector3;
  14731. /**
  14732. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14733. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14734. */
  14735. direction2: Vector3;
  14736. /**
  14737. * 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.
  14738. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14739. */
  14740. minEmitBox: Vector3;
  14741. /**
  14742. * 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.
  14743. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14744. */
  14745. maxEmitBox: Vector3;
  14746. /**
  14747. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14748. */
  14749. color1: Color4;
  14750. /**
  14751. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14752. */
  14753. color2: Color4;
  14754. /**
  14755. * Color the particle will have at the end of its lifetime
  14756. */
  14757. colorDead: Color4;
  14758. /**
  14759. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14760. */
  14761. textureMask: Color4;
  14762. /**
  14763. * The particle emitter type defines the emitter used by the particle system.
  14764. * It can be for example box, sphere, or cone...
  14765. */
  14766. particleEmitterType: IParticleEmitterType;
  14767. /** @hidden */
  14768. _isSubEmitter: boolean;
  14769. /**
  14770. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14771. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14772. */
  14773. billboardMode: number;
  14774. protected _isBillboardBased: boolean;
  14775. /**
  14776. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14777. */
  14778. isBillboardBased: boolean;
  14779. /**
  14780. * The scene the particle system belongs to.
  14781. */
  14782. protected _scene: Scene;
  14783. /**
  14784. * Local cache of defines for image processing.
  14785. */
  14786. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14787. /**
  14788. * Default configuration related to image processing available in the standard Material.
  14789. */
  14790. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14791. /**
  14792. * Gets the image processing configuration used either in this material.
  14793. */
  14794. /**
  14795. * Sets the Default image processing configuration used either in the this material.
  14796. *
  14797. * If sets to null, the scene one is in use.
  14798. */
  14799. imageProcessingConfiguration: ImageProcessingConfiguration;
  14800. /**
  14801. * Attaches a new image processing configuration to the Standard Material.
  14802. * @param configuration
  14803. */
  14804. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14805. /** @hidden */
  14806. protected _reset(): void;
  14807. /** @hidden */
  14808. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14809. /**
  14810. * Instantiates a particle system.
  14811. * 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.
  14812. * @param name The name of the particle system
  14813. */
  14814. constructor(name: string);
  14815. /**
  14816. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14817. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14818. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14819. * @returns the emitter
  14820. */
  14821. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14822. /**
  14823. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14824. * @param radius The radius of the hemisphere to emit from
  14825. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14826. * @returns the emitter
  14827. */
  14828. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14829. /**
  14830. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14831. * @param radius The radius of the sphere to emit from
  14832. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14833. * @returns the emitter
  14834. */
  14835. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14836. /**
  14837. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14838. * @param radius The radius of the sphere to emit from
  14839. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14840. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14841. * @returns the emitter
  14842. */
  14843. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14844. /**
  14845. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14846. * @param radius The radius of the emission cylinder
  14847. * @param height The height of the emission cylinder
  14848. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14849. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14850. * @returns the emitter
  14851. */
  14852. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14853. /**
  14854. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14855. * @param radius The radius of the cylinder to emit from
  14856. * @param height The height of the emission cylinder
  14857. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14858. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14859. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14860. * @returns the emitter
  14861. */
  14862. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14863. /**
  14864. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14865. * @param radius The radius of the cone to emit from
  14866. * @param angle The base angle of the cone
  14867. * @returns the emitter
  14868. */
  14869. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14870. /**
  14871. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14872. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14873. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14874. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14875. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14876. * @returns the emitter
  14877. */
  14878. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14879. }
  14880. }
  14881. declare module "babylonjs/Particles/subEmitter" {
  14882. import { Scene } from "babylonjs/scene";
  14883. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14884. /**
  14885. * Type of sub emitter
  14886. */
  14887. export enum SubEmitterType {
  14888. /**
  14889. * Attached to the particle over it's lifetime
  14890. */
  14891. ATTACHED = 0,
  14892. /**
  14893. * Created when the particle dies
  14894. */
  14895. END = 1
  14896. }
  14897. /**
  14898. * Sub emitter class used to emit particles from an existing particle
  14899. */
  14900. export class SubEmitter {
  14901. /**
  14902. * the particle system to be used by the sub emitter
  14903. */
  14904. particleSystem: ParticleSystem;
  14905. /**
  14906. * Type of the submitter (Default: END)
  14907. */
  14908. type: SubEmitterType;
  14909. /**
  14910. * 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)
  14911. * Note: This only is supported when using an emitter of type Mesh
  14912. */
  14913. inheritDirection: boolean;
  14914. /**
  14915. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14916. */
  14917. inheritedVelocityAmount: number;
  14918. /**
  14919. * Creates a sub emitter
  14920. * @param particleSystem the particle system to be used by the sub emitter
  14921. */
  14922. constructor(
  14923. /**
  14924. * the particle system to be used by the sub emitter
  14925. */
  14926. particleSystem: ParticleSystem);
  14927. /**
  14928. * Clones the sub emitter
  14929. * @returns the cloned sub emitter
  14930. */
  14931. clone(): SubEmitter;
  14932. /**
  14933. * Serialize current object to a JSON object
  14934. * @returns the serialized object
  14935. */
  14936. serialize(): any;
  14937. /** @hidden */
  14938. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14939. /**
  14940. * Creates a new SubEmitter from a serialized JSON version
  14941. * @param serializationObject defines the JSON object to read from
  14942. * @param scene defines the hosting scene
  14943. * @param rootUrl defines the rootUrl for data loading
  14944. * @returns a new SubEmitter
  14945. */
  14946. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14947. /** Release associated resources */
  14948. dispose(): void;
  14949. }
  14950. }
  14951. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14952. /** @hidden */
  14953. export var clipPlaneFragmentDeclaration: {
  14954. name: string;
  14955. shader: string;
  14956. };
  14957. }
  14958. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14959. /** @hidden */
  14960. export var imageProcessingDeclaration: {
  14961. name: string;
  14962. shader: string;
  14963. };
  14964. }
  14965. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14966. /** @hidden */
  14967. export var imageProcessingFunctions: {
  14968. name: string;
  14969. shader: string;
  14970. };
  14971. }
  14972. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14973. /** @hidden */
  14974. export var clipPlaneFragment: {
  14975. name: string;
  14976. shader: string;
  14977. };
  14978. }
  14979. declare module "babylonjs/Shaders/particles.fragment" {
  14980. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14981. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14982. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14983. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14984. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14985. /** @hidden */
  14986. export var particlesPixelShader: {
  14987. name: string;
  14988. shader: string;
  14989. };
  14990. }
  14991. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14992. /** @hidden */
  14993. export var clipPlaneVertexDeclaration: {
  14994. name: string;
  14995. shader: string;
  14996. };
  14997. }
  14998. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14999. /** @hidden */
  15000. export var clipPlaneVertex: {
  15001. name: string;
  15002. shader: string;
  15003. };
  15004. }
  15005. declare module "babylonjs/Shaders/particles.vertex" {
  15006. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15007. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15008. /** @hidden */
  15009. export var particlesVertexShader: {
  15010. name: string;
  15011. shader: string;
  15012. };
  15013. }
  15014. declare module "babylonjs/Particles/particleSystem" {
  15015. import { Nullable } from "babylonjs/types";
  15016. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15017. import { Observable } from "babylonjs/Misc/observable";
  15018. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15019. import { Effect } from "babylonjs/Materials/effect";
  15020. import { Scene, IDisposable } from "babylonjs/scene";
  15021. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15022. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15023. import { Particle } from "babylonjs/Particles/particle";
  15024. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15025. import "babylonjs/Shaders/particles.fragment";
  15026. import "babylonjs/Shaders/particles.vertex";
  15027. /**
  15028. * This represents a particle system in Babylon.
  15029. * 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.
  15030. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15031. * @example https://doc.babylonjs.com/babylon101/particles
  15032. */
  15033. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15034. /**
  15035. * Billboard mode will only apply to Y axis
  15036. */
  15037. static readonly BILLBOARDMODE_Y: number;
  15038. /**
  15039. * Billboard mode will apply to all axes
  15040. */
  15041. static readonly BILLBOARDMODE_ALL: number;
  15042. /**
  15043. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15044. */
  15045. static readonly BILLBOARDMODE_STRETCHED: number;
  15046. /**
  15047. * This function can be defined to provide custom update for active particles.
  15048. * This function will be called instead of regular update (age, position, color, etc.).
  15049. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15050. */
  15051. updateFunction: (particles: Particle[]) => void;
  15052. private _emitterWorldMatrix;
  15053. /**
  15054. * This function can be defined to specify initial direction for every new particle.
  15055. * It by default use the emitterType defined function
  15056. */
  15057. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15058. /**
  15059. * This function can be defined to specify initial position for every new particle.
  15060. * It by default use the emitterType defined function
  15061. */
  15062. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15063. /**
  15064. * @hidden
  15065. */
  15066. _inheritedVelocityOffset: Vector3;
  15067. /**
  15068. * An event triggered when the system is disposed
  15069. */
  15070. onDisposeObservable: Observable<ParticleSystem>;
  15071. private _onDisposeObserver;
  15072. /**
  15073. * Sets a callback that will be triggered when the system is disposed
  15074. */
  15075. onDispose: () => void;
  15076. private _particles;
  15077. private _epsilon;
  15078. private _capacity;
  15079. private _stockParticles;
  15080. private _newPartsExcess;
  15081. private _vertexData;
  15082. private _vertexBuffer;
  15083. private _vertexBuffers;
  15084. private _spriteBuffer;
  15085. private _indexBuffer;
  15086. private _effect;
  15087. private _customEffect;
  15088. private _cachedDefines;
  15089. private _scaledColorStep;
  15090. private _colorDiff;
  15091. private _scaledDirection;
  15092. private _scaledGravity;
  15093. private _currentRenderId;
  15094. private _alive;
  15095. private _useInstancing;
  15096. private _started;
  15097. private _stopped;
  15098. private _actualFrame;
  15099. private _scaledUpdateSpeed;
  15100. private _vertexBufferSize;
  15101. /** @hidden */
  15102. _currentEmitRateGradient: Nullable<FactorGradient>;
  15103. /** @hidden */
  15104. _currentEmitRate1: number;
  15105. /** @hidden */
  15106. _currentEmitRate2: number;
  15107. /** @hidden */
  15108. _currentStartSizeGradient: Nullable<FactorGradient>;
  15109. /** @hidden */
  15110. _currentStartSize1: number;
  15111. /** @hidden */
  15112. _currentStartSize2: number;
  15113. private readonly _rawTextureWidth;
  15114. private _rampGradientsTexture;
  15115. private _useRampGradients;
  15116. /** Gets or sets a boolean indicating that ramp gradients must be used
  15117. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15118. */
  15119. useRampGradients: boolean;
  15120. /**
  15121. * 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.
  15122. * 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: [])
  15123. */
  15124. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15125. private _subEmitters;
  15126. /**
  15127. * @hidden
  15128. * If the particle systems emitter should be disposed when the particle system is disposed
  15129. */
  15130. _disposeEmitterOnDispose: boolean;
  15131. /**
  15132. * The current active Sub-systems, this property is used by the root particle system only.
  15133. */
  15134. activeSubSystems: Array<ParticleSystem>;
  15135. private _rootParticleSystem;
  15136. /**
  15137. * Gets the current list of active particles
  15138. */
  15139. readonly particles: Particle[];
  15140. /**
  15141. * Returns the string "ParticleSystem"
  15142. * @returns a string containing the class name
  15143. */
  15144. getClassName(): string;
  15145. /**
  15146. * Instantiates a particle system.
  15147. * 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.
  15148. * @param name The name of the particle system
  15149. * @param capacity The max number of particles alive at the same time
  15150. * @param scene The scene the particle system belongs to
  15151. * @param customEffect a custom effect used to change the way particles are rendered by default
  15152. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15153. * @param epsilon Offset used to render the particles
  15154. */
  15155. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15156. private _addFactorGradient;
  15157. private _removeFactorGradient;
  15158. /**
  15159. * Adds a new life time gradient
  15160. * @param gradient defines the gradient to use (between 0 and 1)
  15161. * @param factor defines the life time factor to affect to the specified gradient
  15162. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15163. * @returns the current particle system
  15164. */
  15165. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15166. /**
  15167. * Remove a specific life time gradient
  15168. * @param gradient defines the gradient to remove
  15169. * @returns the current particle system
  15170. */
  15171. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15172. /**
  15173. * Adds a new size gradient
  15174. * @param gradient defines the gradient to use (between 0 and 1)
  15175. * @param factor defines the size factor to affect to the specified gradient
  15176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15177. * @returns the current particle system
  15178. */
  15179. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15180. /**
  15181. * Remove a specific size gradient
  15182. * @param gradient defines the gradient to remove
  15183. * @returns the current particle system
  15184. */
  15185. removeSizeGradient(gradient: number): IParticleSystem;
  15186. /**
  15187. * Adds a new color remap gradient
  15188. * @param gradient defines the gradient to use (between 0 and 1)
  15189. * @param min defines the color remap minimal range
  15190. * @param max defines the color remap maximal range
  15191. * @returns the current particle system
  15192. */
  15193. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15194. /**
  15195. * Remove a specific color remap gradient
  15196. * @param gradient defines the gradient to remove
  15197. * @returns the current particle system
  15198. */
  15199. removeColorRemapGradient(gradient: number): IParticleSystem;
  15200. /**
  15201. * Adds a new alpha remap gradient
  15202. * @param gradient defines the gradient to use (between 0 and 1)
  15203. * @param min defines the alpha remap minimal range
  15204. * @param max defines the alpha remap maximal range
  15205. * @returns the current particle system
  15206. */
  15207. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15208. /**
  15209. * Remove a specific alpha remap gradient
  15210. * @param gradient defines the gradient to remove
  15211. * @returns the current particle system
  15212. */
  15213. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15214. /**
  15215. * Adds a new angular speed gradient
  15216. * @param gradient defines the gradient to use (between 0 and 1)
  15217. * @param factor defines the angular speed to affect to the specified gradient
  15218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15219. * @returns the current particle system
  15220. */
  15221. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15222. /**
  15223. * Remove a specific angular speed gradient
  15224. * @param gradient defines the gradient to remove
  15225. * @returns the current particle system
  15226. */
  15227. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15228. /**
  15229. * Adds a new velocity gradient
  15230. * @param gradient defines the gradient to use (between 0 and 1)
  15231. * @param factor defines the velocity to affect to the specified gradient
  15232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15233. * @returns the current particle system
  15234. */
  15235. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15236. /**
  15237. * Remove a specific velocity gradient
  15238. * @param gradient defines the gradient to remove
  15239. * @returns the current particle system
  15240. */
  15241. removeVelocityGradient(gradient: number): IParticleSystem;
  15242. /**
  15243. * Adds a new limit velocity gradient
  15244. * @param gradient defines the gradient to use (between 0 and 1)
  15245. * @param factor defines the limit velocity value to affect to the specified gradient
  15246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15247. * @returns the current particle system
  15248. */
  15249. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15250. /**
  15251. * Remove a specific limit velocity gradient
  15252. * @param gradient defines the gradient to remove
  15253. * @returns the current particle system
  15254. */
  15255. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15256. /**
  15257. * Adds a new drag gradient
  15258. * @param gradient defines the gradient to use (between 0 and 1)
  15259. * @param factor defines the drag value to affect to the specified gradient
  15260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15261. * @returns the current particle system
  15262. */
  15263. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15264. /**
  15265. * Remove a specific drag gradient
  15266. * @param gradient defines the gradient to remove
  15267. * @returns the current particle system
  15268. */
  15269. removeDragGradient(gradient: number): IParticleSystem;
  15270. /**
  15271. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15272. * @param gradient defines the gradient to use (between 0 and 1)
  15273. * @param factor defines the emit rate value to affect to the specified gradient
  15274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15275. * @returns the current particle system
  15276. */
  15277. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15278. /**
  15279. * Remove a specific emit rate gradient
  15280. * @param gradient defines the gradient to remove
  15281. * @returns the current particle system
  15282. */
  15283. removeEmitRateGradient(gradient: number): IParticleSystem;
  15284. /**
  15285. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15286. * @param gradient defines the gradient to use (between 0 and 1)
  15287. * @param factor defines the start size value to affect to the specified gradient
  15288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15289. * @returns the current particle system
  15290. */
  15291. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15292. /**
  15293. * Remove a specific start size gradient
  15294. * @param gradient defines the gradient to remove
  15295. * @returns the current particle system
  15296. */
  15297. removeStartSizeGradient(gradient: number): IParticleSystem;
  15298. private _createRampGradientTexture;
  15299. /**
  15300. * Gets the current list of ramp gradients.
  15301. * You must use addRampGradient and removeRampGradient to udpate this list
  15302. * @returns the list of ramp gradients
  15303. */
  15304. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15305. /**
  15306. * Adds a new ramp gradient used to remap particle colors
  15307. * @param gradient defines the gradient to use (between 0 and 1)
  15308. * @param color defines the color to affect to the specified gradient
  15309. * @returns the current particle system
  15310. */
  15311. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15312. /**
  15313. * Remove a specific ramp gradient
  15314. * @param gradient defines the gradient to remove
  15315. * @returns the current particle system
  15316. */
  15317. removeRampGradient(gradient: number): ParticleSystem;
  15318. /**
  15319. * Adds a new color gradient
  15320. * @param gradient defines the gradient to use (between 0 and 1)
  15321. * @param color1 defines the color to affect to the specified gradient
  15322. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15323. * @returns this particle system
  15324. */
  15325. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15326. /**
  15327. * Remove a specific color gradient
  15328. * @param gradient defines the gradient to remove
  15329. * @returns this particle system
  15330. */
  15331. removeColorGradient(gradient: number): IParticleSystem;
  15332. private _fetchR;
  15333. protected _reset(): void;
  15334. private _resetEffect;
  15335. private _createVertexBuffers;
  15336. private _createIndexBuffer;
  15337. /**
  15338. * Gets the maximum number of particles active at the same time.
  15339. * @returns The max number of active particles.
  15340. */
  15341. getCapacity(): number;
  15342. /**
  15343. * Gets whether there are still active particles in the system.
  15344. * @returns True if it is alive, otherwise false.
  15345. */
  15346. isAlive(): boolean;
  15347. /**
  15348. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15349. * @returns True if it has been started, otherwise false.
  15350. */
  15351. isStarted(): boolean;
  15352. private _prepareSubEmitterInternalArray;
  15353. /**
  15354. * Starts the particle system and begins to emit
  15355. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15356. */
  15357. start(delay?: number): void;
  15358. /**
  15359. * Stops the particle system.
  15360. * @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.
  15361. */
  15362. stop(stopSubEmitters?: boolean): void;
  15363. /**
  15364. * Remove all active particles
  15365. */
  15366. reset(): void;
  15367. /**
  15368. * @hidden (for internal use only)
  15369. */
  15370. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15371. /**
  15372. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15373. * Its lifetime will start back at 0.
  15374. */
  15375. recycleParticle: (particle: Particle) => void;
  15376. private _stopSubEmitters;
  15377. private _createParticle;
  15378. private _removeFromRoot;
  15379. private _emitFromParticle;
  15380. private _update;
  15381. /** @hidden */
  15382. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15383. /** @hidden */
  15384. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15385. /** @hidden */
  15386. private _getEffect;
  15387. /**
  15388. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15389. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15390. */
  15391. animate(preWarmOnly?: boolean): void;
  15392. private _appendParticleVertices;
  15393. /**
  15394. * Rebuilds the particle system.
  15395. */
  15396. rebuild(): void;
  15397. /**
  15398. * Is this system ready to be used/rendered
  15399. * @return true if the system is ready
  15400. */
  15401. isReady(): boolean;
  15402. private _render;
  15403. /**
  15404. * Renders the particle system in its current state.
  15405. * @returns the current number of particles
  15406. */
  15407. render(): number;
  15408. /**
  15409. * Disposes the particle system and free the associated resources
  15410. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15411. */
  15412. dispose(disposeTexture?: boolean): void;
  15413. /**
  15414. * Clones the particle system.
  15415. * @param name The name of the cloned object
  15416. * @param newEmitter The new emitter to use
  15417. * @returns the cloned particle system
  15418. */
  15419. clone(name: string, newEmitter: any): ParticleSystem;
  15420. /**
  15421. * Serializes the particle system to a JSON object.
  15422. * @returns the JSON object
  15423. */
  15424. serialize(): any;
  15425. /** @hidden */
  15426. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15427. /** @hidden */
  15428. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15429. /**
  15430. * Parses a JSON object to create a particle system.
  15431. * @param parsedParticleSystem The JSON object to parse
  15432. * @param scene The scene to create the particle system in
  15433. * @param rootUrl The root url to use to load external dependencies like texture
  15434. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15435. * @returns the Parsed particle system
  15436. */
  15437. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15438. }
  15439. }
  15440. declare module "babylonjs/Particles/particle" {
  15441. import { Nullable } from "babylonjs/types";
  15442. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15443. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15444. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15445. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15446. /**
  15447. * A particle represents one of the element emitted by a particle system.
  15448. * This is mainly define by its coordinates, direction, velocity and age.
  15449. */
  15450. export class Particle {
  15451. /**
  15452. * The particle system the particle belongs to.
  15453. */
  15454. particleSystem: ParticleSystem;
  15455. private static _Count;
  15456. /**
  15457. * Unique ID of the particle
  15458. */
  15459. id: number;
  15460. /**
  15461. * The world position of the particle in the scene.
  15462. */
  15463. position: Vector3;
  15464. /**
  15465. * The world direction of the particle in the scene.
  15466. */
  15467. direction: Vector3;
  15468. /**
  15469. * The color of the particle.
  15470. */
  15471. color: Color4;
  15472. /**
  15473. * The color change of the particle per step.
  15474. */
  15475. colorStep: Color4;
  15476. /**
  15477. * Defines how long will the life of the particle be.
  15478. */
  15479. lifeTime: number;
  15480. /**
  15481. * The current age of the particle.
  15482. */
  15483. age: number;
  15484. /**
  15485. * The current size of the particle.
  15486. */
  15487. size: number;
  15488. /**
  15489. * The current scale of the particle.
  15490. */
  15491. scale: Vector2;
  15492. /**
  15493. * The current angle of the particle.
  15494. */
  15495. angle: number;
  15496. /**
  15497. * Defines how fast is the angle changing.
  15498. */
  15499. angularSpeed: number;
  15500. /**
  15501. * Defines the cell index used by the particle to be rendered from a sprite.
  15502. */
  15503. cellIndex: number;
  15504. /**
  15505. * The information required to support color remapping
  15506. */
  15507. remapData: Vector4;
  15508. /** @hidden */
  15509. _randomCellOffset?: number;
  15510. /** @hidden */
  15511. _initialDirection: Nullable<Vector3>;
  15512. /** @hidden */
  15513. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15514. /** @hidden */
  15515. _initialStartSpriteCellID: number;
  15516. /** @hidden */
  15517. _initialEndSpriteCellID: number;
  15518. /** @hidden */
  15519. _currentColorGradient: Nullable<ColorGradient>;
  15520. /** @hidden */
  15521. _currentColor1: Color4;
  15522. /** @hidden */
  15523. _currentColor2: Color4;
  15524. /** @hidden */
  15525. _currentSizeGradient: Nullable<FactorGradient>;
  15526. /** @hidden */
  15527. _currentSize1: number;
  15528. /** @hidden */
  15529. _currentSize2: number;
  15530. /** @hidden */
  15531. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15532. /** @hidden */
  15533. _currentAngularSpeed1: number;
  15534. /** @hidden */
  15535. _currentAngularSpeed2: number;
  15536. /** @hidden */
  15537. _currentVelocityGradient: Nullable<FactorGradient>;
  15538. /** @hidden */
  15539. _currentVelocity1: number;
  15540. /** @hidden */
  15541. _currentVelocity2: number;
  15542. /** @hidden */
  15543. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15544. /** @hidden */
  15545. _currentLimitVelocity1: number;
  15546. /** @hidden */
  15547. _currentLimitVelocity2: number;
  15548. /** @hidden */
  15549. _currentDragGradient: Nullable<FactorGradient>;
  15550. /** @hidden */
  15551. _currentDrag1: number;
  15552. /** @hidden */
  15553. _currentDrag2: number;
  15554. /** @hidden */
  15555. _randomNoiseCoordinates1: Vector3;
  15556. /** @hidden */
  15557. _randomNoiseCoordinates2: Vector3;
  15558. /**
  15559. * Creates a new instance Particle
  15560. * @param particleSystem the particle system the particle belongs to
  15561. */
  15562. constructor(
  15563. /**
  15564. * The particle system the particle belongs to.
  15565. */
  15566. particleSystem: ParticleSystem);
  15567. private updateCellInfoFromSystem;
  15568. /**
  15569. * Defines how the sprite cell index is updated for the particle
  15570. */
  15571. updateCellIndex(): void;
  15572. /** @hidden */
  15573. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15574. /** @hidden */
  15575. _inheritParticleInfoToSubEmitters(): void;
  15576. /** @hidden */
  15577. _reset(): void;
  15578. /**
  15579. * Copy the properties of particle to another one.
  15580. * @param other the particle to copy the information to.
  15581. */
  15582. copyTo(other: Particle): void;
  15583. }
  15584. }
  15585. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15586. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15587. import { Effect } from "babylonjs/Materials/effect";
  15588. import { Particle } from "babylonjs/Particles/particle";
  15589. /**
  15590. * Particle emitter represents a volume emitting particles.
  15591. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15592. */
  15593. export interface IParticleEmitterType {
  15594. /**
  15595. * Called by the particle System when the direction is computed for the created particle.
  15596. * @param worldMatrix is the world matrix of the particle system
  15597. * @param directionToUpdate is the direction vector to update with the result
  15598. * @param particle is the particle we are computed the direction for
  15599. */
  15600. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15601. /**
  15602. * Called by the particle System when the position is computed for the created particle.
  15603. * @param worldMatrix is the world matrix of the particle system
  15604. * @param positionToUpdate is the position vector to update with the result
  15605. * @param particle is the particle we are computed the position for
  15606. */
  15607. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15608. /**
  15609. * Clones the current emitter and returns a copy of it
  15610. * @returns the new emitter
  15611. */
  15612. clone(): IParticleEmitterType;
  15613. /**
  15614. * Called by the GPUParticleSystem to setup the update shader
  15615. * @param effect defines the update shader
  15616. */
  15617. applyToShader(effect: Effect): void;
  15618. /**
  15619. * Returns a string to use to update the GPU particles update shader
  15620. * @returns the effect defines string
  15621. */
  15622. getEffectDefines(): string;
  15623. /**
  15624. * Returns a string representing the class name
  15625. * @returns a string containing the class name
  15626. */
  15627. getClassName(): string;
  15628. /**
  15629. * Serializes the particle system to a JSON object.
  15630. * @returns the JSON object
  15631. */
  15632. serialize(): any;
  15633. /**
  15634. * Parse properties from a JSON object
  15635. * @param serializationObject defines the JSON object
  15636. */
  15637. parse(serializationObject: any): void;
  15638. }
  15639. }
  15640. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15641. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15642. import { Effect } from "babylonjs/Materials/effect";
  15643. import { Particle } from "babylonjs/Particles/particle";
  15644. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15645. /**
  15646. * Particle emitter emitting particles from the inside of a box.
  15647. * It emits the particles randomly between 2 given directions.
  15648. */
  15649. export class BoxParticleEmitter implements IParticleEmitterType {
  15650. /**
  15651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15652. */
  15653. direction1: Vector3;
  15654. /**
  15655. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15656. */
  15657. direction2: Vector3;
  15658. /**
  15659. * 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.
  15660. */
  15661. minEmitBox: Vector3;
  15662. /**
  15663. * 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.
  15664. */
  15665. maxEmitBox: Vector3;
  15666. /**
  15667. * Creates a new instance BoxParticleEmitter
  15668. */
  15669. constructor();
  15670. /**
  15671. * Called by the particle System when the direction is computed for the created particle.
  15672. * @param worldMatrix is the world matrix of the particle system
  15673. * @param directionToUpdate is the direction vector to update with the result
  15674. * @param particle is the particle we are computed the direction for
  15675. */
  15676. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15677. /**
  15678. * Called by the particle System when the position is computed for the created particle.
  15679. * @param worldMatrix is the world matrix of the particle system
  15680. * @param positionToUpdate is the position vector to update with the result
  15681. * @param particle is the particle we are computed the position for
  15682. */
  15683. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15684. /**
  15685. * Clones the current emitter and returns a copy of it
  15686. * @returns the new emitter
  15687. */
  15688. clone(): BoxParticleEmitter;
  15689. /**
  15690. * Called by the GPUParticleSystem to setup the update shader
  15691. * @param effect defines the update shader
  15692. */
  15693. applyToShader(effect: Effect): void;
  15694. /**
  15695. * Returns a string to use to update the GPU particles update shader
  15696. * @returns a string containng the defines string
  15697. */
  15698. getEffectDefines(): string;
  15699. /**
  15700. * Returns the string "BoxParticleEmitter"
  15701. * @returns a string containing the class name
  15702. */
  15703. getClassName(): string;
  15704. /**
  15705. * Serializes the particle system to a JSON object.
  15706. * @returns the JSON object
  15707. */
  15708. serialize(): any;
  15709. /**
  15710. * Parse properties from a JSON object
  15711. * @param serializationObject defines the JSON object
  15712. */
  15713. parse(serializationObject: any): void;
  15714. }
  15715. }
  15716. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15717. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15718. import { Effect } from "babylonjs/Materials/effect";
  15719. import { Particle } from "babylonjs/Particles/particle";
  15720. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15721. /**
  15722. * Particle emitter emitting particles from the inside of a cone.
  15723. * It emits the particles alongside the cone volume from the base to the particle.
  15724. * The emission direction might be randomized.
  15725. */
  15726. export class ConeParticleEmitter implements IParticleEmitterType {
  15727. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15728. directionRandomizer: number;
  15729. private _radius;
  15730. private _angle;
  15731. private _height;
  15732. /**
  15733. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15734. */
  15735. radiusRange: number;
  15736. /**
  15737. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15738. */
  15739. heightRange: number;
  15740. /**
  15741. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15742. */
  15743. emitFromSpawnPointOnly: boolean;
  15744. /**
  15745. * Gets or sets the radius of the emission cone
  15746. */
  15747. radius: number;
  15748. /**
  15749. * Gets or sets the angle of the emission cone
  15750. */
  15751. angle: number;
  15752. private _buildHeight;
  15753. /**
  15754. * Creates a new instance ConeParticleEmitter
  15755. * @param radius the radius of the emission cone (1 by default)
  15756. * @param angle the cone base angle (PI by default)
  15757. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15758. */
  15759. constructor(radius?: number, angle?: number,
  15760. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15761. directionRandomizer?: number);
  15762. /**
  15763. * Called by the particle System when the direction is computed for the created particle.
  15764. * @param worldMatrix is the world matrix of the particle system
  15765. * @param directionToUpdate is the direction vector to update with the result
  15766. * @param particle is the particle we are computed the direction for
  15767. */
  15768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15769. /**
  15770. * Called by the particle System when the position is computed for the created particle.
  15771. * @param worldMatrix is the world matrix of the particle system
  15772. * @param positionToUpdate is the position vector to update with the result
  15773. * @param particle is the particle we are computed the position for
  15774. */
  15775. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15776. /**
  15777. * Clones the current emitter and returns a copy of it
  15778. * @returns the new emitter
  15779. */
  15780. clone(): ConeParticleEmitter;
  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 "ConeParticleEmitter"
  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/cylinderParticleEmitter" {
  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 cylinder.
  15815. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15816. */
  15817. export class CylinderParticleEmitter implements IParticleEmitterType {
  15818. /**
  15819. * The radius of the emission cylinder.
  15820. */
  15821. radius: number;
  15822. /**
  15823. * The height of the emission cylinder.
  15824. */
  15825. height: number;
  15826. /**
  15827. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15828. */
  15829. radiusRange: number;
  15830. /**
  15831. * How much to randomize the particle direction [0-1].
  15832. */
  15833. directionRandomizer: number;
  15834. /**
  15835. * Creates a new instance CylinderParticleEmitter
  15836. * @param radius the radius of the emission cylinder (1 by default)
  15837. * @param height the height of the emission cylinder (1 by default)
  15838. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15839. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15840. */
  15841. constructor(
  15842. /**
  15843. * The radius of the emission cylinder.
  15844. */
  15845. radius?: number,
  15846. /**
  15847. * The height of the emission cylinder.
  15848. */
  15849. height?: number,
  15850. /**
  15851. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15852. */
  15853. radiusRange?: number,
  15854. /**
  15855. * How much to randomize the particle direction [0-1].
  15856. */
  15857. directionRandomizer?: number);
  15858. /**
  15859. * Called by the particle System when the direction is computed for the created particle.
  15860. * @param worldMatrix is the world matrix of the particle system
  15861. * @param directionToUpdate is the direction vector to update with the result
  15862. * @param particle is the particle we are computed the direction for
  15863. */
  15864. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15865. /**
  15866. * Called by the particle System when the position is computed for the created particle.
  15867. * @param worldMatrix is the world matrix of the particle system
  15868. * @param positionToUpdate is the position vector to update with the result
  15869. * @param particle is the particle we are computed the position for
  15870. */
  15871. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15872. /**
  15873. * Clones the current emitter and returns a copy of it
  15874. * @returns the new emitter
  15875. */
  15876. clone(): CylinderParticleEmitter;
  15877. /**
  15878. * Called by the GPUParticleSystem to setup the update shader
  15879. * @param effect defines the update shader
  15880. */
  15881. applyToShader(effect: Effect): void;
  15882. /**
  15883. * Returns a string to use to update the GPU particles update shader
  15884. * @returns a string containng the defines string
  15885. */
  15886. getEffectDefines(): string;
  15887. /**
  15888. * Returns the string "CylinderParticleEmitter"
  15889. * @returns a string containing the class name
  15890. */
  15891. getClassName(): string;
  15892. /**
  15893. * Serializes the particle system to a JSON object.
  15894. * @returns the JSON object
  15895. */
  15896. serialize(): any;
  15897. /**
  15898. * Parse properties from a JSON object
  15899. * @param serializationObject defines the JSON object
  15900. */
  15901. parse(serializationObject: any): void;
  15902. }
  15903. /**
  15904. * Particle emitter emitting particles from the inside of a cylinder.
  15905. * It emits the particles randomly between two vectors.
  15906. */
  15907. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15908. /**
  15909. * The min limit of the emission direction.
  15910. */
  15911. direction1: Vector3;
  15912. /**
  15913. * The max limit of the emission direction.
  15914. */
  15915. direction2: Vector3;
  15916. /**
  15917. * Creates a new instance CylinderDirectedParticleEmitter
  15918. * @param radius the radius of the emission cylinder (1 by default)
  15919. * @param height the height of the emission cylinder (1 by default)
  15920. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15921. * @param direction1 the min limit of the emission direction (up vector by default)
  15922. * @param direction2 the max limit of the emission direction (up vector by default)
  15923. */
  15924. constructor(radius?: number, height?: number, radiusRange?: number,
  15925. /**
  15926. * The min limit of the emission direction.
  15927. */
  15928. direction1?: Vector3,
  15929. /**
  15930. * The max limit of the emission direction.
  15931. */
  15932. direction2?: Vector3);
  15933. /**
  15934. * Called by the particle System when the direction is computed for the created particle.
  15935. * @param worldMatrix is the world matrix of the particle system
  15936. * @param directionToUpdate is the direction vector to update with the result
  15937. * @param particle is the particle we are computed the direction for
  15938. */
  15939. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15940. /**
  15941. * Clones the current emitter and returns a copy of it
  15942. * @returns the new emitter
  15943. */
  15944. clone(): CylinderDirectedParticleEmitter;
  15945. /**
  15946. * Called by the GPUParticleSystem to setup the update shader
  15947. * @param effect defines the update shader
  15948. */
  15949. applyToShader(effect: Effect): void;
  15950. /**
  15951. * Returns a string to use to update the GPU particles update shader
  15952. * @returns a string containng the defines string
  15953. */
  15954. getEffectDefines(): string;
  15955. /**
  15956. * Returns the string "CylinderDirectedParticleEmitter"
  15957. * @returns a string containing the class name
  15958. */
  15959. getClassName(): string;
  15960. /**
  15961. * Serializes the particle system to a JSON object.
  15962. * @returns the JSON object
  15963. */
  15964. serialize(): any;
  15965. /**
  15966. * Parse properties from a JSON object
  15967. * @param serializationObject defines the JSON object
  15968. */
  15969. parse(serializationObject: any): void;
  15970. }
  15971. }
  15972. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15973. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15974. import { Effect } from "babylonjs/Materials/effect";
  15975. import { Particle } from "babylonjs/Particles/particle";
  15976. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15977. /**
  15978. * Particle emitter emitting particles from the inside of a hemisphere.
  15979. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15980. */
  15981. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15982. /**
  15983. * The radius of the emission hemisphere.
  15984. */
  15985. radius: number;
  15986. /**
  15987. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15988. */
  15989. radiusRange: number;
  15990. /**
  15991. * How much to randomize the particle direction [0-1].
  15992. */
  15993. directionRandomizer: number;
  15994. /**
  15995. * Creates a new instance HemisphericParticleEmitter
  15996. * @param radius the radius of the emission hemisphere (1 by default)
  15997. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15998. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15999. */
  16000. constructor(
  16001. /**
  16002. * The radius of the emission hemisphere.
  16003. */
  16004. radius?: number,
  16005. /**
  16006. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16007. */
  16008. radiusRange?: number,
  16009. /**
  16010. * How much to randomize the particle direction [0-1].
  16011. */
  16012. directionRandomizer?: number);
  16013. /**
  16014. * Called by the particle System when the direction is computed for the created particle.
  16015. * @param worldMatrix is the world matrix of the particle system
  16016. * @param directionToUpdate is the direction vector to update with the result
  16017. * @param particle is the particle we are computed the direction for
  16018. */
  16019. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16020. /**
  16021. * Called by the particle System when the position is computed for the created particle.
  16022. * @param worldMatrix is the world matrix of the particle system
  16023. * @param positionToUpdate is the position vector to update with the result
  16024. * @param particle is the particle we are computed the position for
  16025. */
  16026. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16027. /**
  16028. * Clones the current emitter and returns a copy of it
  16029. * @returns the new emitter
  16030. */
  16031. clone(): HemisphericParticleEmitter;
  16032. /**
  16033. * Called by the GPUParticleSystem to setup the update shader
  16034. * @param effect defines the update shader
  16035. */
  16036. applyToShader(effect: Effect): void;
  16037. /**
  16038. * Returns a string to use to update the GPU particles update shader
  16039. * @returns a string containng the defines string
  16040. */
  16041. getEffectDefines(): string;
  16042. /**
  16043. * Returns the string "HemisphericParticleEmitter"
  16044. * @returns a string containing the class name
  16045. */
  16046. getClassName(): string;
  16047. /**
  16048. * Serializes the particle system to a JSON object.
  16049. * @returns the JSON object
  16050. */
  16051. serialize(): any;
  16052. /**
  16053. * Parse properties from a JSON object
  16054. * @param serializationObject defines the JSON object
  16055. */
  16056. parse(serializationObject: any): void;
  16057. }
  16058. }
  16059. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16060. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16061. import { Effect } from "babylonjs/Materials/effect";
  16062. import { Particle } from "babylonjs/Particles/particle";
  16063. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16064. /**
  16065. * Particle emitter emitting particles from a point.
  16066. * It emits the particles randomly between 2 given directions.
  16067. */
  16068. export class PointParticleEmitter implements IParticleEmitterType {
  16069. /**
  16070. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16071. */
  16072. direction1: Vector3;
  16073. /**
  16074. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16075. */
  16076. direction2: Vector3;
  16077. /**
  16078. * Creates a new instance PointParticleEmitter
  16079. */
  16080. constructor();
  16081. /**
  16082. * Called by the particle System when the direction is computed for the created particle.
  16083. * @param worldMatrix is the world matrix of the particle system
  16084. * @param directionToUpdate is the direction vector to update with the result
  16085. * @param particle is the particle we are computed the direction for
  16086. */
  16087. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16088. /**
  16089. * Called by the particle System when the position is computed for the created particle.
  16090. * @param worldMatrix is the world matrix of the particle system
  16091. * @param positionToUpdate is the position vector to update with the result
  16092. * @param particle is the particle we are computed the position for
  16093. */
  16094. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16095. /**
  16096. * Clones the current emitter and returns a copy of it
  16097. * @returns the new emitter
  16098. */
  16099. clone(): PointParticleEmitter;
  16100. /**
  16101. * Called by the GPUParticleSystem to setup the update shader
  16102. * @param effect defines the update shader
  16103. */
  16104. applyToShader(effect: Effect): void;
  16105. /**
  16106. * Returns a string to use to update the GPU particles update shader
  16107. * @returns a string containng the defines string
  16108. */
  16109. getEffectDefines(): string;
  16110. /**
  16111. * Returns the string "PointParticleEmitter"
  16112. * @returns a string containing the class name
  16113. */
  16114. getClassName(): string;
  16115. /**
  16116. * Serializes the particle system to a JSON object.
  16117. * @returns the JSON object
  16118. */
  16119. serialize(): any;
  16120. /**
  16121. * Parse properties from a JSON object
  16122. * @param serializationObject defines the JSON object
  16123. */
  16124. parse(serializationObject: any): void;
  16125. }
  16126. }
  16127. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16128. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16129. import { Effect } from "babylonjs/Materials/effect";
  16130. import { Particle } from "babylonjs/Particles/particle";
  16131. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16132. /**
  16133. * Particle emitter emitting particles from the inside of a sphere.
  16134. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16135. */
  16136. export class SphereParticleEmitter implements IParticleEmitterType {
  16137. /**
  16138. * The radius of the emission sphere.
  16139. */
  16140. radius: number;
  16141. /**
  16142. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16143. */
  16144. radiusRange: number;
  16145. /**
  16146. * How much to randomize the particle direction [0-1].
  16147. */
  16148. directionRandomizer: number;
  16149. /**
  16150. * Creates a new instance SphereParticleEmitter
  16151. * @param radius the radius of the emission sphere (1 by default)
  16152. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16153. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16154. */
  16155. constructor(
  16156. /**
  16157. * The radius of the emission sphere.
  16158. */
  16159. radius?: number,
  16160. /**
  16161. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16162. */
  16163. radiusRange?: number,
  16164. /**
  16165. * How much to randomize the particle direction [0-1].
  16166. */
  16167. directionRandomizer?: number);
  16168. /**
  16169. * Called by the particle System when the direction is computed for the created particle.
  16170. * @param worldMatrix is the world matrix of the particle system
  16171. * @param directionToUpdate is the direction vector to update with the result
  16172. * @param particle is the particle we are computed the direction for
  16173. */
  16174. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16175. /**
  16176. * Called by the particle System when the position is computed for the created particle.
  16177. * @param worldMatrix is the world matrix of the particle system
  16178. * @param positionToUpdate is the position vector to update with the result
  16179. * @param particle is the particle we are computed the position for
  16180. */
  16181. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16182. /**
  16183. * Clones the current emitter and returns a copy of it
  16184. * @returns the new emitter
  16185. */
  16186. clone(): SphereParticleEmitter;
  16187. /**
  16188. * Called by the GPUParticleSystem to setup the update shader
  16189. * @param effect defines the update shader
  16190. */
  16191. applyToShader(effect: Effect): void;
  16192. /**
  16193. * Returns a string to use to update the GPU particles update shader
  16194. * @returns a string containng the defines string
  16195. */
  16196. getEffectDefines(): string;
  16197. /**
  16198. * Returns the string "SphereParticleEmitter"
  16199. * @returns a string containing the class name
  16200. */
  16201. getClassName(): string;
  16202. /**
  16203. * Serializes the particle system to a JSON object.
  16204. * @returns the JSON object
  16205. */
  16206. serialize(): any;
  16207. /**
  16208. * Parse properties from a JSON object
  16209. * @param serializationObject defines the JSON object
  16210. */
  16211. parse(serializationObject: any): void;
  16212. }
  16213. /**
  16214. * Particle emitter emitting particles from the inside of a sphere.
  16215. * It emits the particles randomly between two vectors.
  16216. */
  16217. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16218. /**
  16219. * The min limit of the emission direction.
  16220. */
  16221. direction1: Vector3;
  16222. /**
  16223. * The max limit of the emission direction.
  16224. */
  16225. direction2: Vector3;
  16226. /**
  16227. * Creates a new instance SphereDirectedParticleEmitter
  16228. * @param radius the radius of the emission sphere (1 by default)
  16229. * @param direction1 the min limit of the emission direction (up vector by default)
  16230. * @param direction2 the max limit of the emission direction (up vector by default)
  16231. */
  16232. constructor(radius?: number,
  16233. /**
  16234. * The min limit of the emission direction.
  16235. */
  16236. direction1?: Vector3,
  16237. /**
  16238. * The max limit of the emission direction.
  16239. */
  16240. direction2?: Vector3);
  16241. /**
  16242. * Called by the particle System when the direction is computed for the created particle.
  16243. * @param worldMatrix is the world matrix of the particle system
  16244. * @param directionToUpdate is the direction vector to update with the result
  16245. * @param particle is the particle we are computed the direction for
  16246. */
  16247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16248. /**
  16249. * Clones the current emitter and returns a copy of it
  16250. * @returns the new emitter
  16251. */
  16252. clone(): SphereDirectedParticleEmitter;
  16253. /**
  16254. * Called by the GPUParticleSystem to setup the update shader
  16255. * @param effect defines the update shader
  16256. */
  16257. applyToShader(effect: Effect): void;
  16258. /**
  16259. * Returns a string to use to update the GPU particles update shader
  16260. * @returns a string containng the defines string
  16261. */
  16262. getEffectDefines(): string;
  16263. /**
  16264. * Returns the string "SphereDirectedParticleEmitter"
  16265. * @returns a string containing the class name
  16266. */
  16267. getClassName(): string;
  16268. /**
  16269. * Serializes the particle system to a JSON object.
  16270. * @returns the JSON object
  16271. */
  16272. serialize(): any;
  16273. /**
  16274. * Parse properties from a JSON object
  16275. * @param serializationObject defines the JSON object
  16276. */
  16277. parse(serializationObject: any): void;
  16278. }
  16279. }
  16280. declare module "babylonjs/Particles/EmitterTypes/index" {
  16281. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16282. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16283. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16284. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16285. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16286. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16287. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16288. }
  16289. declare module "babylonjs/Particles/IParticleSystem" {
  16290. import { Nullable } from "babylonjs/types";
  16291. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16293. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16294. import { Texture } from "babylonjs/Materials/Textures/texture";
  16295. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16296. import { Scene } from "babylonjs/scene";
  16297. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16298. import { Animation } from "babylonjs/Animations/animation";
  16299. /**
  16300. * Interface representing a particle system in Babylon.js.
  16301. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16302. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16303. */
  16304. export interface IParticleSystem {
  16305. /**
  16306. * List of animations used by the particle system.
  16307. */
  16308. animations: Animation[];
  16309. /**
  16310. * The id of the Particle system.
  16311. */
  16312. id: string;
  16313. /**
  16314. * The name of the Particle system.
  16315. */
  16316. name: string;
  16317. /**
  16318. * The emitter represents the Mesh or position we are attaching the particle system to.
  16319. */
  16320. emitter: Nullable<AbstractMesh | Vector3>;
  16321. /**
  16322. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16323. */
  16324. isBillboardBased: boolean;
  16325. /**
  16326. * The rendering group used by the Particle system to chose when to render.
  16327. */
  16328. renderingGroupId: number;
  16329. /**
  16330. * The layer mask we are rendering the particles through.
  16331. */
  16332. layerMask: number;
  16333. /**
  16334. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16335. */
  16336. updateSpeed: number;
  16337. /**
  16338. * The amount of time the particle system is running (depends of the overall update speed).
  16339. */
  16340. targetStopDuration: number;
  16341. /**
  16342. * The texture used to render each particle. (this can be a spritesheet)
  16343. */
  16344. particleTexture: Nullable<Texture>;
  16345. /**
  16346. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16347. */
  16348. blendMode: number;
  16349. /**
  16350. * Minimum life time of emitting particles.
  16351. */
  16352. minLifeTime: number;
  16353. /**
  16354. * Maximum life time of emitting particles.
  16355. */
  16356. maxLifeTime: number;
  16357. /**
  16358. * Minimum Size of emitting particles.
  16359. */
  16360. minSize: number;
  16361. /**
  16362. * Maximum Size of emitting particles.
  16363. */
  16364. maxSize: number;
  16365. /**
  16366. * Minimum scale of emitting particles on X axis.
  16367. */
  16368. minScaleX: number;
  16369. /**
  16370. * Maximum scale of emitting particles on X axis.
  16371. */
  16372. maxScaleX: number;
  16373. /**
  16374. * Minimum scale of emitting particles on Y axis.
  16375. */
  16376. minScaleY: number;
  16377. /**
  16378. * Maximum scale of emitting particles on Y axis.
  16379. */
  16380. maxScaleY: number;
  16381. /**
  16382. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16383. */
  16384. color1: Color4;
  16385. /**
  16386. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16387. */
  16388. color2: Color4;
  16389. /**
  16390. * Color the particle will have at the end of its lifetime.
  16391. */
  16392. colorDead: Color4;
  16393. /**
  16394. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16395. */
  16396. emitRate: number;
  16397. /**
  16398. * You can use gravity if you want to give an orientation to your particles.
  16399. */
  16400. gravity: Vector3;
  16401. /**
  16402. * Minimum power of emitting particles.
  16403. */
  16404. minEmitPower: number;
  16405. /**
  16406. * Maximum power of emitting particles.
  16407. */
  16408. maxEmitPower: number;
  16409. /**
  16410. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16411. */
  16412. minAngularSpeed: number;
  16413. /**
  16414. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16415. */
  16416. maxAngularSpeed: number;
  16417. /**
  16418. * Gets or sets the minimal initial rotation in radians.
  16419. */
  16420. minInitialRotation: number;
  16421. /**
  16422. * Gets or sets the maximal initial rotation in radians.
  16423. */
  16424. maxInitialRotation: number;
  16425. /**
  16426. * The particle emitter type defines the emitter used by the particle system.
  16427. * It can be for example box, sphere, or cone...
  16428. */
  16429. particleEmitterType: Nullable<IParticleEmitterType>;
  16430. /**
  16431. * Defines the delay in milliseconds before starting the system (0 by default)
  16432. */
  16433. startDelay: number;
  16434. /**
  16435. * 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
  16436. */
  16437. preWarmCycles: number;
  16438. /**
  16439. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16440. */
  16441. preWarmStepOffset: number;
  16442. /**
  16443. * 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)
  16444. */
  16445. spriteCellChangeSpeed: number;
  16446. /**
  16447. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16448. */
  16449. startSpriteCellID: number;
  16450. /**
  16451. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16452. */
  16453. endSpriteCellID: number;
  16454. /**
  16455. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16456. */
  16457. spriteCellWidth: number;
  16458. /**
  16459. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16460. */
  16461. spriteCellHeight: number;
  16462. /**
  16463. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16464. */
  16465. spriteRandomStartCell: boolean;
  16466. /**
  16467. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16468. */
  16469. isAnimationSheetEnabled: boolean;
  16470. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16471. translationPivot: Vector2;
  16472. /**
  16473. * Gets or sets a texture used to add random noise to particle positions
  16474. */
  16475. noiseTexture: Nullable<BaseTexture>;
  16476. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16477. noiseStrength: Vector3;
  16478. /**
  16479. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16480. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16481. */
  16482. billboardMode: number;
  16483. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16484. limitVelocityDamping: number;
  16485. /**
  16486. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16487. */
  16488. beginAnimationOnStart: boolean;
  16489. /**
  16490. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16491. */
  16492. beginAnimationFrom: number;
  16493. /**
  16494. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16495. */
  16496. beginAnimationTo: number;
  16497. /**
  16498. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16499. */
  16500. beginAnimationLoop: boolean;
  16501. /**
  16502. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16503. */
  16504. disposeOnStop: boolean;
  16505. /**
  16506. * Gets the maximum number of particles active at the same time.
  16507. * @returns The max number of active particles.
  16508. */
  16509. getCapacity(): number;
  16510. /**
  16511. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16512. * @returns True if it has been started, otherwise false.
  16513. */
  16514. isStarted(): boolean;
  16515. /**
  16516. * Animates the particle system for this frame.
  16517. */
  16518. animate(): void;
  16519. /**
  16520. * Renders the particle system in its current state.
  16521. * @returns the current number of particles
  16522. */
  16523. render(): number;
  16524. /**
  16525. * Dispose the particle system and frees its associated resources.
  16526. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16527. */
  16528. dispose(disposeTexture?: boolean): void;
  16529. /**
  16530. * Clones the particle system.
  16531. * @param name The name of the cloned object
  16532. * @param newEmitter The new emitter to use
  16533. * @returns the cloned particle system
  16534. */
  16535. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16536. /**
  16537. * Serializes the particle system to a JSON object.
  16538. * @returns the JSON object
  16539. */
  16540. serialize(): any;
  16541. /**
  16542. * Rebuild the particle system
  16543. */
  16544. rebuild(): void;
  16545. /**
  16546. * Starts the particle system and begins to emit
  16547. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16548. */
  16549. start(delay?: number): void;
  16550. /**
  16551. * Stops the particle system.
  16552. */
  16553. stop(): void;
  16554. /**
  16555. * Remove all active particles
  16556. */
  16557. reset(): void;
  16558. /**
  16559. * Is this system ready to be used/rendered
  16560. * @return true if the system is ready
  16561. */
  16562. isReady(): boolean;
  16563. /**
  16564. * Adds a new color gradient
  16565. * @param gradient defines the gradient to use (between 0 and 1)
  16566. * @param color1 defines the color to affect to the specified gradient
  16567. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16568. * @returns the current particle system
  16569. */
  16570. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16571. /**
  16572. * Remove a specific color gradient
  16573. * @param gradient defines the gradient to remove
  16574. * @returns the current particle system
  16575. */
  16576. removeColorGradient(gradient: number): IParticleSystem;
  16577. /**
  16578. * Adds a new size gradient
  16579. * @param gradient defines the gradient to use (between 0 and 1)
  16580. * @param factor defines the size factor to affect to the specified gradient
  16581. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16582. * @returns the current particle system
  16583. */
  16584. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16585. /**
  16586. * Remove a specific size gradient
  16587. * @param gradient defines the gradient to remove
  16588. * @returns the current particle system
  16589. */
  16590. removeSizeGradient(gradient: number): IParticleSystem;
  16591. /**
  16592. * Gets the current list of color gradients.
  16593. * You must use addColorGradient and removeColorGradient to udpate this list
  16594. * @returns the list of color gradients
  16595. */
  16596. getColorGradients(): Nullable<Array<ColorGradient>>;
  16597. /**
  16598. * Gets the current list of size gradients.
  16599. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16600. * @returns the list of size gradients
  16601. */
  16602. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16603. /**
  16604. * Gets the current list of angular speed gradients.
  16605. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16606. * @returns the list of angular speed gradients
  16607. */
  16608. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16609. /**
  16610. * Adds a new angular speed gradient
  16611. * @param gradient defines the gradient to use (between 0 and 1)
  16612. * @param factor defines the angular speed to affect to the specified gradient
  16613. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16614. * @returns the current particle system
  16615. */
  16616. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16617. /**
  16618. * Remove a specific angular speed gradient
  16619. * @param gradient defines the gradient to remove
  16620. * @returns the current particle system
  16621. */
  16622. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16623. /**
  16624. * Gets the current list of velocity gradients.
  16625. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16626. * @returns the list of velocity gradients
  16627. */
  16628. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16629. /**
  16630. * Adds a new velocity gradient
  16631. * @param gradient defines the gradient to use (between 0 and 1)
  16632. * @param factor defines the velocity to affect to the specified gradient
  16633. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16634. * @returns the current particle system
  16635. */
  16636. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16637. /**
  16638. * Remove a specific velocity gradient
  16639. * @param gradient defines the gradient to remove
  16640. * @returns the current particle system
  16641. */
  16642. removeVelocityGradient(gradient: number): IParticleSystem;
  16643. /**
  16644. * Gets the current list of limit velocity gradients.
  16645. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16646. * @returns the list of limit velocity gradients
  16647. */
  16648. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16649. /**
  16650. * Adds a new limit velocity gradient
  16651. * @param gradient defines the gradient to use (between 0 and 1)
  16652. * @param factor defines the limit velocity to affect to the specified gradient
  16653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16654. * @returns the current particle system
  16655. */
  16656. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16657. /**
  16658. * Remove a specific limit velocity gradient
  16659. * @param gradient defines the gradient to remove
  16660. * @returns the current particle system
  16661. */
  16662. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16663. /**
  16664. * Adds a new drag gradient
  16665. * @param gradient defines the gradient to use (between 0 and 1)
  16666. * @param factor defines the drag to affect to the specified gradient
  16667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16668. * @returns the current particle system
  16669. */
  16670. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16671. /**
  16672. * Remove a specific drag gradient
  16673. * @param gradient defines the gradient to remove
  16674. * @returns the current particle system
  16675. */
  16676. removeDragGradient(gradient: number): IParticleSystem;
  16677. /**
  16678. * Gets the current list of drag gradients.
  16679. * You must use addDragGradient and removeDragGradient to udpate this list
  16680. * @returns the list of drag gradients
  16681. */
  16682. getDragGradients(): Nullable<Array<FactorGradient>>;
  16683. /**
  16684. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16685. * @param gradient defines the gradient to use (between 0 and 1)
  16686. * @param factor defines the emit rate to affect to the specified gradient
  16687. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16688. * @returns the current particle system
  16689. */
  16690. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16691. /**
  16692. * Remove a specific emit rate gradient
  16693. * @param gradient defines the gradient to remove
  16694. * @returns the current particle system
  16695. */
  16696. removeEmitRateGradient(gradient: number): IParticleSystem;
  16697. /**
  16698. * Gets the current list of emit rate gradients.
  16699. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16700. * @returns the list of emit rate gradients
  16701. */
  16702. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16703. /**
  16704. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16705. * @param gradient defines the gradient to use (between 0 and 1)
  16706. * @param factor defines the start size to affect to the specified gradient
  16707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16708. * @returns the current particle system
  16709. */
  16710. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16711. /**
  16712. * Remove a specific start size gradient
  16713. * @param gradient defines the gradient to remove
  16714. * @returns the current particle system
  16715. */
  16716. removeStartSizeGradient(gradient: number): IParticleSystem;
  16717. /**
  16718. * Gets the current list of start size gradients.
  16719. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16720. * @returns the list of start size gradients
  16721. */
  16722. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16723. /**
  16724. * Adds a new life time gradient
  16725. * @param gradient defines the gradient to use (between 0 and 1)
  16726. * @param factor defines the life time factor to affect to the specified gradient
  16727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16728. * @returns the current particle system
  16729. */
  16730. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16731. /**
  16732. * Remove a specific life time gradient
  16733. * @param gradient defines the gradient to remove
  16734. * @returns the current particle system
  16735. */
  16736. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16737. /**
  16738. * Gets the current list of life time gradients.
  16739. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16740. * @returns the list of life time gradients
  16741. */
  16742. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16743. /**
  16744. * Gets the current list of color gradients.
  16745. * You must use addColorGradient and removeColorGradient to udpate this list
  16746. * @returns the list of color gradients
  16747. */
  16748. getColorGradients(): Nullable<Array<ColorGradient>>;
  16749. /**
  16750. * Adds a new ramp gradient used to remap particle colors
  16751. * @param gradient defines the gradient to use (between 0 and 1)
  16752. * @param color defines the color to affect to the specified gradient
  16753. * @returns the current particle system
  16754. */
  16755. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16756. /**
  16757. * Gets the current list of ramp gradients.
  16758. * You must use addRampGradient and removeRampGradient to udpate this list
  16759. * @returns the list of ramp gradients
  16760. */
  16761. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16762. /** Gets or sets a boolean indicating that ramp gradients must be used
  16763. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16764. */
  16765. useRampGradients: boolean;
  16766. /**
  16767. * Adds a new color remap gradient
  16768. * @param gradient defines the gradient to use (between 0 and 1)
  16769. * @param min defines the color remap minimal range
  16770. * @param max defines the color remap maximal range
  16771. * @returns the current particle system
  16772. */
  16773. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16774. /**
  16775. * Gets the current list of color remap gradients.
  16776. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16777. * @returns the list of color remap gradients
  16778. */
  16779. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16780. /**
  16781. * Adds a new alpha remap gradient
  16782. * @param gradient defines the gradient to use (between 0 and 1)
  16783. * @param min defines the alpha remap minimal range
  16784. * @param max defines the alpha remap maximal range
  16785. * @returns the current particle system
  16786. */
  16787. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16788. /**
  16789. * Gets the current list of alpha remap gradients.
  16790. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16791. * @returns the list of alpha remap gradients
  16792. */
  16793. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16794. /**
  16795. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16796. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16797. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16798. * @returns the emitter
  16799. */
  16800. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16801. /**
  16802. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16803. * @param radius The radius of the hemisphere to emit from
  16804. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16805. * @returns the emitter
  16806. */
  16807. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16808. /**
  16809. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16810. * @param radius The radius of the sphere to emit from
  16811. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16812. * @returns the emitter
  16813. */
  16814. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16815. /**
  16816. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16817. * @param radius The radius of the sphere to emit from
  16818. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16819. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16820. * @returns the emitter
  16821. */
  16822. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16823. /**
  16824. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16825. * @param radius The radius of the emission cylinder
  16826. * @param height The height of the emission cylinder
  16827. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16828. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16829. * @returns the emitter
  16830. */
  16831. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16832. /**
  16833. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16834. * @param radius The radius of the cylinder to emit from
  16835. * @param height The height of the emission cylinder
  16836. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16837. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16838. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16839. * @returns the emitter
  16840. */
  16841. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16842. /**
  16843. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16844. * @param radius The radius of the cone to emit from
  16845. * @param angle The base angle of the cone
  16846. * @returns the emitter
  16847. */
  16848. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16849. /**
  16850. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16851. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16852. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16853. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16854. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16855. * @returns the emitter
  16856. */
  16857. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16858. /**
  16859. * Get hosting scene
  16860. * @returns the scene
  16861. */
  16862. getScene(): Scene;
  16863. }
  16864. }
  16865. declare module "babylonjs/Meshes/instancedMesh" {
  16866. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16867. import { Vector3 } from "babylonjs/Maths/math";
  16868. import { Camera } from "babylonjs/Cameras/camera";
  16869. import { Node } from "babylonjs/node";
  16870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16871. import { Mesh } from "babylonjs/Meshes/mesh";
  16872. import { Material } from "babylonjs/Materials/material";
  16873. import { Skeleton } from "babylonjs/Bones/skeleton";
  16874. /**
  16875. * Creates an instance based on a source mesh.
  16876. */
  16877. export class InstancedMesh extends AbstractMesh {
  16878. private _sourceMesh;
  16879. private _currentLOD;
  16880. /** @hidden */
  16881. _indexInSourceMeshInstanceArray: number;
  16882. constructor(name: string, source: Mesh);
  16883. /**
  16884. * Returns the string "InstancedMesh".
  16885. */
  16886. getClassName(): string;
  16887. /**
  16888. * If the source mesh receives shadows
  16889. */
  16890. readonly receiveShadows: boolean;
  16891. /**
  16892. * The material of the source mesh
  16893. */
  16894. readonly material: Nullable<Material>;
  16895. /**
  16896. * Visibility of the source mesh
  16897. */
  16898. readonly visibility: number;
  16899. /**
  16900. * Skeleton of the source mesh
  16901. */
  16902. readonly skeleton: Nullable<Skeleton>;
  16903. /**
  16904. * Rendering ground id of the source mesh
  16905. */
  16906. renderingGroupId: number;
  16907. /**
  16908. * Returns the total number of vertices (integer).
  16909. */
  16910. getTotalVertices(): number;
  16911. /**
  16912. * Returns a positive integer : the total number of indices in this mesh geometry.
  16913. * @returns the numner of indices or zero if the mesh has no geometry.
  16914. */
  16915. getTotalIndices(): number;
  16916. /**
  16917. * The source mesh of the instance
  16918. */
  16919. readonly sourceMesh: Mesh;
  16920. /**
  16921. * Is this node ready to be used/rendered
  16922. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16923. * @return {boolean} is it ready
  16924. */
  16925. isReady(completeCheck?: boolean): boolean;
  16926. /**
  16927. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16928. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16929. * @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.
  16930. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16931. */
  16932. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16933. /**
  16934. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16935. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16936. * The `data` are either a numeric array either a Float32Array.
  16937. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16938. * 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).
  16939. * Note that a new underlying VertexBuffer object is created each call.
  16940. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16941. *
  16942. * Possible `kind` values :
  16943. * - VertexBuffer.PositionKind
  16944. * - VertexBuffer.UVKind
  16945. * - VertexBuffer.UV2Kind
  16946. * - VertexBuffer.UV3Kind
  16947. * - VertexBuffer.UV4Kind
  16948. * - VertexBuffer.UV5Kind
  16949. * - VertexBuffer.UV6Kind
  16950. * - VertexBuffer.ColorKind
  16951. * - VertexBuffer.MatricesIndicesKind
  16952. * - VertexBuffer.MatricesIndicesExtraKind
  16953. * - VertexBuffer.MatricesWeightsKind
  16954. * - VertexBuffer.MatricesWeightsExtraKind
  16955. *
  16956. * Returns the Mesh.
  16957. */
  16958. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16959. /**
  16960. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16961. * If the mesh has no geometry, it is simply returned as it is.
  16962. * The `data` are either a numeric array either a Float32Array.
  16963. * No new underlying VertexBuffer object is created.
  16964. * 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.
  16965. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16966. *
  16967. * Possible `kind` values :
  16968. * - VertexBuffer.PositionKind
  16969. * - VertexBuffer.UVKind
  16970. * - VertexBuffer.UV2Kind
  16971. * - VertexBuffer.UV3Kind
  16972. * - VertexBuffer.UV4Kind
  16973. * - VertexBuffer.UV5Kind
  16974. * - VertexBuffer.UV6Kind
  16975. * - VertexBuffer.ColorKind
  16976. * - VertexBuffer.MatricesIndicesKind
  16977. * - VertexBuffer.MatricesIndicesExtraKind
  16978. * - VertexBuffer.MatricesWeightsKind
  16979. * - VertexBuffer.MatricesWeightsExtraKind
  16980. *
  16981. * Returns the Mesh.
  16982. */
  16983. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16984. /**
  16985. * Sets the mesh indices.
  16986. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16987. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16988. * This method creates a new index buffer each call.
  16989. * Returns the Mesh.
  16990. */
  16991. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16992. /**
  16993. * Boolean : True if the mesh owns the requested kind of data.
  16994. */
  16995. isVerticesDataPresent(kind: string): boolean;
  16996. /**
  16997. * Returns an array of indices (IndicesArray).
  16998. */
  16999. getIndices(): Nullable<IndicesArray>;
  17000. readonly _positions: Nullable<Vector3[]>;
  17001. /**
  17002. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17003. * This means the mesh underlying bounding box and sphere are recomputed.
  17004. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17005. * @returns the current mesh
  17006. */
  17007. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17008. /** @hidden */
  17009. _preActivate(): InstancedMesh;
  17010. /** @hidden */
  17011. _activate(renderId: number): InstancedMesh;
  17012. /**
  17013. * Returns the current associated LOD AbstractMesh.
  17014. */
  17015. getLOD(camera: Camera): AbstractMesh;
  17016. /** @hidden */
  17017. _syncSubMeshes(): InstancedMesh;
  17018. /** @hidden */
  17019. _generatePointsArray(): boolean;
  17020. /**
  17021. * Creates a new InstancedMesh from the current mesh.
  17022. * - name (string) : the cloned mesh name
  17023. * - newParent (optional Node) : the optional Node to parent the clone to.
  17024. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17025. *
  17026. * Returns the clone.
  17027. */
  17028. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17029. /**
  17030. * Disposes the InstancedMesh.
  17031. * Returns nothing.
  17032. */
  17033. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17034. }
  17035. }
  17036. declare module "babylonjs/Materials/shaderMaterial" {
  17037. import { Scene } from "babylonjs/scene";
  17038. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17040. import { Mesh } from "babylonjs/Meshes/mesh";
  17041. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17042. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17043. import { Texture } from "babylonjs/Materials/Textures/texture";
  17044. import { Material } from "babylonjs/Materials/material";
  17045. /**
  17046. * Defines the options associated with the creation of a shader material.
  17047. */
  17048. export interface IShaderMaterialOptions {
  17049. /**
  17050. * Does the material work in alpha blend mode
  17051. */
  17052. needAlphaBlending: boolean;
  17053. /**
  17054. * Does the material work in alpha test mode
  17055. */
  17056. needAlphaTesting: boolean;
  17057. /**
  17058. * The list of attribute names used in the shader
  17059. */
  17060. attributes: string[];
  17061. /**
  17062. * The list of unifrom names used in the shader
  17063. */
  17064. uniforms: string[];
  17065. /**
  17066. * The list of UBO names used in the shader
  17067. */
  17068. uniformBuffers: string[];
  17069. /**
  17070. * The list of sampler names used in the shader
  17071. */
  17072. samplers: string[];
  17073. /**
  17074. * The list of defines used in the shader
  17075. */
  17076. defines: string[];
  17077. }
  17078. /**
  17079. * 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.
  17080. *
  17081. * This returned material effects how the mesh will look based on the code in the shaders.
  17082. *
  17083. * @see http://doc.babylonjs.com/how_to/shader_material
  17084. */
  17085. export class ShaderMaterial extends Material {
  17086. private _shaderPath;
  17087. private _options;
  17088. private _textures;
  17089. private _textureArrays;
  17090. private _floats;
  17091. private _ints;
  17092. private _floatsArrays;
  17093. private _colors3;
  17094. private _colors3Arrays;
  17095. private _colors4;
  17096. private _vectors2;
  17097. private _vectors3;
  17098. private _vectors4;
  17099. private _matrices;
  17100. private _matrices3x3;
  17101. private _matrices2x2;
  17102. private _vectors2Arrays;
  17103. private _vectors3Arrays;
  17104. private _cachedWorldViewMatrix;
  17105. private _renderId;
  17106. /**
  17107. * Instantiate a new shader material.
  17108. * 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.
  17109. * This returned material effects how the mesh will look based on the code in the shaders.
  17110. * @see http://doc.babylonjs.com/how_to/shader_material
  17111. * @param name Define the name of the material in the scene
  17112. * @param scene Define the scene the material belongs to
  17113. * @param shaderPath Defines the route to the shader code in one of three ways:
  17114. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17115. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17116. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17117. * @param options Define the options used to create the shader
  17118. */
  17119. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17120. /**
  17121. * Gets the options used to compile the shader.
  17122. * They can be modified to trigger a new compilation
  17123. */
  17124. readonly options: IShaderMaterialOptions;
  17125. /**
  17126. * Gets the current class name of the material e.g. "ShaderMaterial"
  17127. * Mainly use in serialization.
  17128. * @returns the class name
  17129. */
  17130. getClassName(): string;
  17131. /**
  17132. * Specifies if the material will require alpha blending
  17133. * @returns a boolean specifying if alpha blending is needed
  17134. */
  17135. needAlphaBlending(): boolean;
  17136. /**
  17137. * Specifies if this material should be rendered in alpha test mode
  17138. * @returns a boolean specifying if an alpha test is needed.
  17139. */
  17140. needAlphaTesting(): boolean;
  17141. private _checkUniform;
  17142. /**
  17143. * Set a texture in the shader.
  17144. * @param name Define the name of the uniform samplers as defined in the shader
  17145. * @param texture Define the texture to bind to this sampler
  17146. * @return the material itself allowing "fluent" like uniform updates
  17147. */
  17148. setTexture(name: string, texture: Texture): ShaderMaterial;
  17149. /**
  17150. * Set a texture array in the shader.
  17151. * @param name Define the name of the uniform sampler array as defined in the shader
  17152. * @param textures Define the list of textures to bind to this sampler
  17153. * @return the material itself allowing "fluent" like uniform updates
  17154. */
  17155. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17156. /**
  17157. * Set a float in the shader.
  17158. * @param name Define the name of the uniform as defined in the shader
  17159. * @param value Define the value to give to the uniform
  17160. * @return the material itself allowing "fluent" like uniform updates
  17161. */
  17162. setFloat(name: string, value: number): ShaderMaterial;
  17163. /**
  17164. * Set a int in the shader.
  17165. * @param name Define the name of the uniform as defined in the shader
  17166. * @param value Define the value to give to the uniform
  17167. * @return the material itself allowing "fluent" like uniform updates
  17168. */
  17169. setInt(name: string, value: number): ShaderMaterial;
  17170. /**
  17171. * Set an array of floats in the shader.
  17172. * @param name Define the name of the uniform as defined in the shader
  17173. * @param value Define the value to give to the uniform
  17174. * @return the material itself allowing "fluent" like uniform updates
  17175. */
  17176. setFloats(name: string, value: number[]): ShaderMaterial;
  17177. /**
  17178. * Set a vec3 in the shader from a Color3.
  17179. * @param name Define the name of the uniform as defined in the shader
  17180. * @param value Define the value to give to the uniform
  17181. * @return the material itself allowing "fluent" like uniform updates
  17182. */
  17183. setColor3(name: string, value: Color3): ShaderMaterial;
  17184. /**
  17185. * Set a vec3 array in the shader from a Color3 array.
  17186. * @param name Define the name of the uniform as defined in the shader
  17187. * @param value Define the value to give to the uniform
  17188. * @return the material itself allowing "fluent" like uniform updates
  17189. */
  17190. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17191. /**
  17192. * Set a vec4 in the shader from a Color4.
  17193. * @param name Define the name of the uniform as defined in the shader
  17194. * @param value Define the value to give to the uniform
  17195. * @return the material itself allowing "fluent" like uniform updates
  17196. */
  17197. setColor4(name: string, value: Color4): ShaderMaterial;
  17198. /**
  17199. * Set a vec2 in the shader from a Vector2.
  17200. * @param name Define the name of the uniform as defined in the shader
  17201. * @param value Define the value to give to the uniform
  17202. * @return the material itself allowing "fluent" like uniform updates
  17203. */
  17204. setVector2(name: string, value: Vector2): ShaderMaterial;
  17205. /**
  17206. * Set a vec3 in the shader from a Vector3.
  17207. * @param name Define the name of the uniform as defined in the shader
  17208. * @param value Define the value to give to the uniform
  17209. * @return the material itself allowing "fluent" like uniform updates
  17210. */
  17211. setVector3(name: string, value: Vector3): ShaderMaterial;
  17212. /**
  17213. * Set a vec4 in the shader from a Vector4.
  17214. * @param name Define the name of the uniform as defined in the shader
  17215. * @param value Define the value to give to the uniform
  17216. * @return the material itself allowing "fluent" like uniform updates
  17217. */
  17218. setVector4(name: string, value: Vector4): ShaderMaterial;
  17219. /**
  17220. * Set a mat4 in the shader from a Matrix.
  17221. * @param name Define the name of the uniform as defined in the shader
  17222. * @param value Define the value to give to the uniform
  17223. * @return the material itself allowing "fluent" like uniform updates
  17224. */
  17225. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17226. /**
  17227. * Set a mat3 in the shader from a Float32Array.
  17228. * @param name Define the name of the uniform as defined in the shader
  17229. * @param value Define the value to give to the uniform
  17230. * @return the material itself allowing "fluent" like uniform updates
  17231. */
  17232. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17233. /**
  17234. * Set a mat2 in the shader from a Float32Array.
  17235. * @param name Define the name of the uniform as defined in the shader
  17236. * @param value Define the value to give to the uniform
  17237. * @return the material itself allowing "fluent" like uniform updates
  17238. */
  17239. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17240. /**
  17241. * Set a vec2 array in the shader from a number array.
  17242. * @param name Define the name of the uniform as defined in the shader
  17243. * @param value Define the value to give to the uniform
  17244. * @return the material itself allowing "fluent" like uniform updates
  17245. */
  17246. setArray2(name: string, value: number[]): ShaderMaterial;
  17247. /**
  17248. * Set a vec3 array in the shader from a number array.
  17249. * @param name Define the name of the uniform as defined in the shader
  17250. * @param value Define the value to give to the uniform
  17251. * @return the material itself allowing "fluent" like uniform updates
  17252. */
  17253. setArray3(name: string, value: number[]): ShaderMaterial;
  17254. private _checkCache;
  17255. /**
  17256. * Specifies that the submesh is ready to be used
  17257. * @param mesh defines the mesh to check
  17258. * @param subMesh defines which submesh to check
  17259. * @param useInstances specifies that instances should be used
  17260. * @returns a boolean indicating that the submesh is ready or not
  17261. */
  17262. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17263. /**
  17264. * Checks if the material is ready to render the requested mesh
  17265. * @param mesh Define the mesh to render
  17266. * @param useInstances Define whether or not the material is used with instances
  17267. * @returns true if ready, otherwise false
  17268. */
  17269. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17270. /**
  17271. * Binds the world matrix to the material
  17272. * @param world defines the world transformation matrix
  17273. */
  17274. bindOnlyWorldMatrix(world: Matrix): void;
  17275. /**
  17276. * Binds the material to the mesh
  17277. * @param world defines the world transformation matrix
  17278. * @param mesh defines the mesh to bind the material to
  17279. */
  17280. bind(world: Matrix, mesh?: Mesh): void;
  17281. /**
  17282. * Gets the active textures from the material
  17283. * @returns an array of textures
  17284. */
  17285. getActiveTextures(): BaseTexture[];
  17286. /**
  17287. * Specifies if the material uses a texture
  17288. * @param texture defines the texture to check against the material
  17289. * @returns a boolean specifying if the material uses the texture
  17290. */
  17291. hasTexture(texture: BaseTexture): boolean;
  17292. /**
  17293. * Makes a duplicate of the material, and gives it a new name
  17294. * @param name defines the new name for the duplicated material
  17295. * @returns the cloned material
  17296. */
  17297. clone(name: string): ShaderMaterial;
  17298. /**
  17299. * Disposes the material
  17300. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17301. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17302. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17303. */
  17304. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17305. /**
  17306. * Serializes this material in a JSON representation
  17307. * @returns the serialized material object
  17308. */
  17309. serialize(): any;
  17310. /**
  17311. * Creates a shader material from parsed shader material data
  17312. * @param source defines the JSON represnetation of the material
  17313. * @param scene defines the hosting scene
  17314. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17315. * @returns a new material
  17316. */
  17317. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17318. }
  17319. }
  17320. declare module "babylonjs/Shaders/color.fragment" {
  17321. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17322. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17323. /** @hidden */
  17324. export var colorPixelShader: {
  17325. name: string;
  17326. shader: string;
  17327. };
  17328. }
  17329. declare module "babylonjs/Shaders/color.vertex" {
  17330. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17331. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17332. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17333. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17334. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17335. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17336. /** @hidden */
  17337. export var colorVertexShader: {
  17338. name: string;
  17339. shader: string;
  17340. };
  17341. }
  17342. declare module "babylonjs/Meshes/linesMesh" {
  17343. import { Nullable } from "babylonjs/types";
  17344. import { Scene } from "babylonjs/scene";
  17345. import { Color3 } from "babylonjs/Maths/math";
  17346. import { Node } from "babylonjs/node";
  17347. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17348. import { Mesh } from "babylonjs/Meshes/mesh";
  17349. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17350. import { Effect } from "babylonjs/Materials/effect";
  17351. import { Material } from "babylonjs/Materials/material";
  17352. import "babylonjs/Shaders/color.fragment";
  17353. import "babylonjs/Shaders/color.vertex";
  17354. /**
  17355. * Line mesh
  17356. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17357. */
  17358. export class LinesMesh extends Mesh {
  17359. /**
  17360. * If vertex color should be applied to the mesh
  17361. */
  17362. useVertexColor?: boolean | undefined;
  17363. /**
  17364. * If vertex alpha should be applied to the mesh
  17365. */
  17366. useVertexAlpha?: boolean | undefined;
  17367. /**
  17368. * Color of the line (Default: White)
  17369. */
  17370. color: Color3;
  17371. /**
  17372. * Alpha of the line (Default: 1)
  17373. */
  17374. alpha: number;
  17375. /**
  17376. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17377. * This margin is expressed in world space coordinates, so its value may vary.
  17378. * Default value is 0.1
  17379. */
  17380. intersectionThreshold: number;
  17381. private _colorShader;
  17382. /**
  17383. * Creates a new LinesMesh
  17384. * @param name defines the name
  17385. * @param scene defines the hosting scene
  17386. * @param parent defines the parent mesh if any
  17387. * @param source defines the optional source LinesMesh used to clone data from
  17388. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17389. * When false, achieved by calling a clone(), also passing False.
  17390. * This will make creation of children, recursive.
  17391. * @param useVertexColor defines if this LinesMesh supports vertex color
  17392. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17393. */
  17394. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17395. /**
  17396. * If vertex color should be applied to the mesh
  17397. */
  17398. useVertexColor?: boolean | undefined,
  17399. /**
  17400. * If vertex alpha should be applied to the mesh
  17401. */
  17402. useVertexAlpha?: boolean | undefined);
  17403. private _addClipPlaneDefine;
  17404. private _removeClipPlaneDefine;
  17405. isReady(): boolean;
  17406. /**
  17407. * Returns the string "LineMesh"
  17408. */
  17409. getClassName(): string;
  17410. /**
  17411. * @hidden
  17412. */
  17413. /**
  17414. * @hidden
  17415. */
  17416. material: Material;
  17417. /**
  17418. * @hidden
  17419. */
  17420. readonly checkCollisions: boolean;
  17421. /** @hidden */
  17422. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17423. /** @hidden */
  17424. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17425. /**
  17426. * Disposes of the line mesh
  17427. * @param doNotRecurse If children should be disposed
  17428. */
  17429. dispose(doNotRecurse?: boolean): void;
  17430. /**
  17431. * Returns a new LineMesh object cloned from the current one.
  17432. */
  17433. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17434. /**
  17435. * Creates a new InstancedLinesMesh object from the mesh model.
  17436. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17437. * @param name defines the name of the new instance
  17438. * @returns a new InstancedLinesMesh
  17439. */
  17440. createInstance(name: string): InstancedLinesMesh;
  17441. }
  17442. /**
  17443. * Creates an instance based on a source LinesMesh
  17444. */
  17445. export class InstancedLinesMesh extends InstancedMesh {
  17446. /**
  17447. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17448. * This margin is expressed in world space coordinates, so its value may vary.
  17449. * Initilized with the intersectionThreshold value of the source LinesMesh
  17450. */
  17451. intersectionThreshold: number;
  17452. constructor(name: string, source: LinesMesh);
  17453. /**
  17454. * Returns the string "InstancedLinesMesh".
  17455. */
  17456. getClassName(): string;
  17457. }
  17458. }
  17459. declare module "babylonjs/Shaders/line.fragment" {
  17460. /** @hidden */
  17461. export var linePixelShader: {
  17462. name: string;
  17463. shader: string;
  17464. };
  17465. }
  17466. declare module "babylonjs/Shaders/line.vertex" {
  17467. /** @hidden */
  17468. export var lineVertexShader: {
  17469. name: string;
  17470. shader: string;
  17471. };
  17472. }
  17473. declare module "babylonjs/Rendering/edgesRenderer" {
  17474. import { Nullable } from "babylonjs/types";
  17475. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17477. import { Vector3 } from "babylonjs/Maths/math";
  17478. import { IDisposable } from "babylonjs/scene";
  17479. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17480. import "babylonjs/Shaders/line.fragment";
  17481. import "babylonjs/Shaders/line.vertex";
  17482. module "babylonjs/Meshes/abstractMesh" {
  17483. interface AbstractMesh {
  17484. /**
  17485. * Disables the mesh edge rendering mode
  17486. * @returns the currentAbstractMesh
  17487. */
  17488. disableEdgesRendering(): AbstractMesh;
  17489. /**
  17490. * Enables the edge rendering mode on the mesh.
  17491. * This mode makes the mesh edges visible
  17492. * @param epsilon defines the maximal distance between two angles to detect a face
  17493. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17494. * @returns the currentAbstractMesh
  17495. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17496. */
  17497. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17498. /**
  17499. * Gets the edgesRenderer associated with the mesh
  17500. */
  17501. edgesRenderer: Nullable<EdgesRenderer>;
  17502. }
  17503. }
  17504. module "babylonjs/Meshes/linesMesh" {
  17505. interface LinesMesh {
  17506. /**
  17507. * Enables the edge rendering mode on the mesh.
  17508. * This mode makes the mesh edges visible
  17509. * @param epsilon defines the maximal distance between two angles to detect a face
  17510. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17511. * @returns the currentAbstractMesh
  17512. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17513. */
  17514. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17515. }
  17516. }
  17517. module "babylonjs/Meshes/linesMesh" {
  17518. interface InstancedLinesMesh {
  17519. /**
  17520. * Enables the edge rendering mode on the mesh.
  17521. * This mode makes the mesh edges visible
  17522. * @param epsilon defines the maximal distance between two angles to detect a face
  17523. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17524. * @returns the current InstancedLinesMesh
  17525. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17526. */
  17527. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17528. }
  17529. }
  17530. /**
  17531. * Defines the minimum contract an Edges renderer should follow.
  17532. */
  17533. export interface IEdgesRenderer extends IDisposable {
  17534. /**
  17535. * Gets or sets a boolean indicating if the edgesRenderer is active
  17536. */
  17537. isEnabled: boolean;
  17538. /**
  17539. * Renders the edges of the attached mesh,
  17540. */
  17541. render(): void;
  17542. /**
  17543. * Checks wether or not the edges renderer is ready to render.
  17544. * @return true if ready, otherwise false.
  17545. */
  17546. isReady(): boolean;
  17547. }
  17548. /**
  17549. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17550. */
  17551. export class EdgesRenderer implements IEdgesRenderer {
  17552. /**
  17553. * Define the size of the edges with an orthographic camera
  17554. */
  17555. edgesWidthScalerForOrthographic: number;
  17556. /**
  17557. * Define the size of the edges with a perspective camera
  17558. */
  17559. edgesWidthScalerForPerspective: number;
  17560. protected _source: AbstractMesh;
  17561. protected _linesPositions: number[];
  17562. protected _linesNormals: number[];
  17563. protected _linesIndices: number[];
  17564. protected _epsilon: number;
  17565. protected _indicesCount: number;
  17566. protected _lineShader: ShaderMaterial;
  17567. protected _ib: WebGLBuffer;
  17568. protected _buffers: {
  17569. [key: string]: Nullable<VertexBuffer>;
  17570. };
  17571. protected _checkVerticesInsteadOfIndices: boolean;
  17572. private _meshRebuildObserver;
  17573. private _meshDisposeObserver;
  17574. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17575. isEnabled: boolean;
  17576. /**
  17577. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17578. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17579. * @param source Mesh used to create edges
  17580. * @param epsilon sum of angles in adjacency to check for edge
  17581. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17582. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17583. */
  17584. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17585. protected _prepareRessources(): void;
  17586. /** @hidden */
  17587. _rebuild(): void;
  17588. /**
  17589. * Releases the required resources for the edges renderer
  17590. */
  17591. dispose(): void;
  17592. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17593. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17594. /**
  17595. * Checks if the pair of p0 and p1 is en edge
  17596. * @param faceIndex
  17597. * @param edge
  17598. * @param faceNormals
  17599. * @param p0
  17600. * @param p1
  17601. * @private
  17602. */
  17603. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17604. /**
  17605. * push line into the position, normal and index buffer
  17606. * @protected
  17607. */
  17608. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17609. /**
  17610. * Generates lines edges from adjacencjes
  17611. * @private
  17612. */
  17613. _generateEdgesLines(): void;
  17614. /**
  17615. * Checks wether or not the edges renderer is ready to render.
  17616. * @return true if ready, otherwise false.
  17617. */
  17618. isReady(): boolean;
  17619. /**
  17620. * Renders the edges of the attached mesh,
  17621. */
  17622. render(): void;
  17623. }
  17624. /**
  17625. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17626. */
  17627. export class LineEdgesRenderer extends EdgesRenderer {
  17628. /**
  17629. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17630. * @param source LineMesh used to generate edges
  17631. * @param epsilon not important (specified angle for edge detection)
  17632. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17633. */
  17634. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17635. /**
  17636. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17637. */
  17638. _generateEdgesLines(): void;
  17639. }
  17640. }
  17641. declare module "babylonjs/Rendering/renderingGroup" {
  17642. import { SmartArray } from "babylonjs/Misc/smartArray";
  17643. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17645. import { Nullable } from "babylonjs/types";
  17646. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17647. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17648. import { Material } from "babylonjs/Materials/material";
  17649. import { Scene } from "babylonjs/scene";
  17650. /**
  17651. * This represents the object necessary to create a rendering group.
  17652. * This is exclusively used and created by the rendering manager.
  17653. * To modify the behavior, you use the available helpers in your scene or meshes.
  17654. * @hidden
  17655. */
  17656. export class RenderingGroup {
  17657. index: number;
  17658. private _scene;
  17659. private _opaqueSubMeshes;
  17660. private _transparentSubMeshes;
  17661. private _alphaTestSubMeshes;
  17662. private _depthOnlySubMeshes;
  17663. private _particleSystems;
  17664. private _spriteManagers;
  17665. private _opaqueSortCompareFn;
  17666. private _alphaTestSortCompareFn;
  17667. private _transparentSortCompareFn;
  17668. private _renderOpaque;
  17669. private _renderAlphaTest;
  17670. private _renderTransparent;
  17671. private _edgesRenderers;
  17672. onBeforeTransparentRendering: () => void;
  17673. /**
  17674. * Set the opaque sort comparison function.
  17675. * If null the sub meshes will be render in the order they were created
  17676. */
  17677. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17678. /**
  17679. * Set the alpha test sort comparison function.
  17680. * If null the sub meshes will be render in the order they were created
  17681. */
  17682. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17683. /**
  17684. * Set the transparent sort comparison function.
  17685. * If null the sub meshes will be render in the order they were created
  17686. */
  17687. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17688. /**
  17689. * Creates a new rendering group.
  17690. * @param index The rendering group index
  17691. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17692. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17693. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17694. */
  17695. 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>);
  17696. /**
  17697. * Render all the sub meshes contained in the group.
  17698. * @param customRenderFunction Used to override the default render behaviour of the group.
  17699. * @returns true if rendered some submeshes.
  17700. */
  17701. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17702. /**
  17703. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17704. * @param subMeshes The submeshes to render
  17705. */
  17706. private renderOpaqueSorted;
  17707. /**
  17708. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17709. * @param subMeshes The submeshes to render
  17710. */
  17711. private renderAlphaTestSorted;
  17712. /**
  17713. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17714. * @param subMeshes The submeshes to render
  17715. */
  17716. private renderTransparentSorted;
  17717. /**
  17718. * Renders the submeshes in a specified order.
  17719. * @param subMeshes The submeshes to sort before render
  17720. * @param sortCompareFn The comparison function use to sort
  17721. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17722. * @param transparent Specifies to activate blending if true
  17723. */
  17724. private static renderSorted;
  17725. /**
  17726. * Renders the submeshes in the order they were dispatched (no sort applied).
  17727. * @param subMeshes The submeshes to render
  17728. */
  17729. private static renderUnsorted;
  17730. /**
  17731. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17732. * are rendered back to front if in the same alpha index.
  17733. *
  17734. * @param a The first submesh
  17735. * @param b The second submesh
  17736. * @returns The result of the comparison
  17737. */
  17738. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17739. /**
  17740. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17741. * are rendered back to front.
  17742. *
  17743. * @param a The first submesh
  17744. * @param b The second submesh
  17745. * @returns The result of the comparison
  17746. */
  17747. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17748. /**
  17749. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17750. * are rendered front to back (prevent overdraw).
  17751. *
  17752. * @param a The first submesh
  17753. * @param b The second submesh
  17754. * @returns The result of the comparison
  17755. */
  17756. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17757. /**
  17758. * Resets the different lists of submeshes to prepare a new frame.
  17759. */
  17760. prepare(): void;
  17761. dispose(): void;
  17762. /**
  17763. * Inserts the submesh in its correct queue depending on its material.
  17764. * @param subMesh The submesh to dispatch
  17765. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17766. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17767. */
  17768. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17769. dispatchSprites(spriteManager: ISpriteManager): void;
  17770. dispatchParticles(particleSystem: IParticleSystem): void;
  17771. private _renderParticles;
  17772. private _renderSprites;
  17773. }
  17774. }
  17775. declare module "babylonjs/Rendering/renderingManager" {
  17776. import { Nullable } from "babylonjs/types";
  17777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17778. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17779. import { SmartArray } from "babylonjs/Misc/smartArray";
  17780. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17781. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17782. import { Material } from "babylonjs/Materials/material";
  17783. import { Scene } from "babylonjs/scene";
  17784. import { Camera } from "babylonjs/Cameras/camera";
  17785. /**
  17786. * Interface describing the different options available in the rendering manager
  17787. * regarding Auto Clear between groups.
  17788. */
  17789. export interface IRenderingManagerAutoClearSetup {
  17790. /**
  17791. * Defines whether or not autoclear is enable.
  17792. */
  17793. autoClear: boolean;
  17794. /**
  17795. * Defines whether or not to autoclear the depth buffer.
  17796. */
  17797. depth: boolean;
  17798. /**
  17799. * Defines whether or not to autoclear the stencil buffer.
  17800. */
  17801. stencil: boolean;
  17802. }
  17803. /**
  17804. * This class is used by the onRenderingGroupObservable
  17805. */
  17806. export class RenderingGroupInfo {
  17807. /**
  17808. * The Scene that being rendered
  17809. */
  17810. scene: Scene;
  17811. /**
  17812. * The camera currently used for the rendering pass
  17813. */
  17814. camera: Nullable<Camera>;
  17815. /**
  17816. * The ID of the renderingGroup being processed
  17817. */
  17818. renderingGroupId: number;
  17819. }
  17820. /**
  17821. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17822. * It is enable to manage the different groups as well as the different necessary sort functions.
  17823. * This should not be used directly aside of the few static configurations
  17824. */
  17825. export class RenderingManager {
  17826. /**
  17827. * The max id used for rendering groups (not included)
  17828. */
  17829. static MAX_RENDERINGGROUPS: number;
  17830. /**
  17831. * The min id used for rendering groups (included)
  17832. */
  17833. static MIN_RENDERINGGROUPS: number;
  17834. /**
  17835. * Used to globally prevent autoclearing scenes.
  17836. */
  17837. static AUTOCLEAR: boolean;
  17838. /**
  17839. * @hidden
  17840. */
  17841. _useSceneAutoClearSetup: boolean;
  17842. private _scene;
  17843. private _renderingGroups;
  17844. private _depthStencilBufferAlreadyCleaned;
  17845. private _autoClearDepthStencil;
  17846. private _customOpaqueSortCompareFn;
  17847. private _customAlphaTestSortCompareFn;
  17848. private _customTransparentSortCompareFn;
  17849. private _renderingGroupInfo;
  17850. /**
  17851. * Instantiates a new rendering group for a particular scene
  17852. * @param scene Defines the scene the groups belongs to
  17853. */
  17854. constructor(scene: Scene);
  17855. private _clearDepthStencilBuffer;
  17856. /**
  17857. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17858. * @hidden
  17859. */
  17860. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17861. /**
  17862. * Resets the different information of the group to prepare a new frame
  17863. * @hidden
  17864. */
  17865. reset(): void;
  17866. /**
  17867. * Dispose and release the group and its associated resources.
  17868. * @hidden
  17869. */
  17870. dispose(): void;
  17871. /**
  17872. * Clear the info related to rendering groups preventing retention points during dispose.
  17873. */
  17874. freeRenderingGroups(): void;
  17875. private _prepareRenderingGroup;
  17876. /**
  17877. * Add a sprite manager to the rendering manager in order to render it this frame.
  17878. * @param spriteManager Define the sprite manager to render
  17879. */
  17880. dispatchSprites(spriteManager: ISpriteManager): void;
  17881. /**
  17882. * Add a particle system to the rendering manager in order to render it this frame.
  17883. * @param particleSystem Define the particle system to render
  17884. */
  17885. dispatchParticles(particleSystem: IParticleSystem): void;
  17886. /**
  17887. * Add a submesh to the manager in order to render it this frame
  17888. * @param subMesh The submesh to dispatch
  17889. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17890. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17891. */
  17892. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17893. /**
  17894. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17895. * This allowed control for front to back rendering or reversly depending of the special needs.
  17896. *
  17897. * @param renderingGroupId The rendering group id corresponding to its index
  17898. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17899. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17900. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17901. */
  17902. 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;
  17903. /**
  17904. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17905. *
  17906. * @param renderingGroupId The rendering group id corresponding to its index
  17907. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17908. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17909. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17910. */
  17911. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17912. /**
  17913. * Gets the current auto clear configuration for one rendering group of the rendering
  17914. * manager.
  17915. * @param index the rendering group index to get the information for
  17916. * @returns The auto clear setup for the requested rendering group
  17917. */
  17918. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17919. }
  17920. }
  17921. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17922. import { Observable } from "babylonjs/Misc/observable";
  17923. import { SmartArray } from "babylonjs/Misc/smartArray";
  17924. import { Nullable } from "babylonjs/types";
  17925. import { Camera } from "babylonjs/Cameras/camera";
  17926. import { Scene } from "babylonjs/scene";
  17927. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17928. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17931. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17932. import { Texture } from "babylonjs/Materials/Textures/texture";
  17933. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17934. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17935. import { Engine } from "babylonjs/Engines/engine";
  17936. /**
  17937. * This Helps creating a texture that will be created from a camera in your scene.
  17938. * It is basically a dynamic texture that could be used to create special effects for instance.
  17939. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17940. */
  17941. export class RenderTargetTexture extends Texture {
  17942. isCube: boolean;
  17943. /**
  17944. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17945. */
  17946. static readonly REFRESHRATE_RENDER_ONCE: number;
  17947. /**
  17948. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17949. */
  17950. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17951. /**
  17952. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17953. * the central point of your effect and can save a lot of performances.
  17954. */
  17955. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17956. /**
  17957. * Use this predicate to dynamically define the list of mesh you want to render.
  17958. * If set, the renderList property will be overwritten.
  17959. */
  17960. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17961. private _renderList;
  17962. /**
  17963. * Use this list to define the list of mesh you want to render.
  17964. */
  17965. renderList: Nullable<Array<AbstractMesh>>;
  17966. private _hookArray;
  17967. /**
  17968. * Define if particles should be rendered in your texture.
  17969. */
  17970. renderParticles: boolean;
  17971. /**
  17972. * Define if sprites should be rendered in your texture.
  17973. */
  17974. renderSprites: boolean;
  17975. /**
  17976. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17977. */
  17978. coordinatesMode: number;
  17979. /**
  17980. * Define the camera used to render the texture.
  17981. */
  17982. activeCamera: Nullable<Camera>;
  17983. /**
  17984. * Override the render function of the texture with your own one.
  17985. */
  17986. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17987. /**
  17988. * Define if camera post processes should be use while rendering the texture.
  17989. */
  17990. useCameraPostProcesses: boolean;
  17991. /**
  17992. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17993. */
  17994. ignoreCameraViewport: boolean;
  17995. private _postProcessManager;
  17996. private _postProcesses;
  17997. private _resizeObserver;
  17998. /**
  17999. * An event triggered when the texture is unbind.
  18000. */
  18001. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18002. /**
  18003. * An event triggered when the texture is unbind.
  18004. */
  18005. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18006. private _onAfterUnbindObserver;
  18007. /**
  18008. * Set a after unbind callback in the texture.
  18009. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18010. */
  18011. onAfterUnbind: () => void;
  18012. /**
  18013. * An event triggered before rendering the texture
  18014. */
  18015. onBeforeRenderObservable: Observable<number>;
  18016. private _onBeforeRenderObserver;
  18017. /**
  18018. * Set a before render callback in the texture.
  18019. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18020. */
  18021. onBeforeRender: (faceIndex: number) => void;
  18022. /**
  18023. * An event triggered after rendering the texture
  18024. */
  18025. onAfterRenderObservable: Observable<number>;
  18026. private _onAfterRenderObserver;
  18027. /**
  18028. * Set a after render callback in the texture.
  18029. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18030. */
  18031. onAfterRender: (faceIndex: number) => void;
  18032. /**
  18033. * An event triggered after the texture clear
  18034. */
  18035. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18036. private _onClearObserver;
  18037. /**
  18038. * Set a clear callback in the texture.
  18039. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18040. */
  18041. onClear: (Engine: Engine) => void;
  18042. /**
  18043. * Define the clear color of the Render Target if it should be different from the scene.
  18044. */
  18045. clearColor: Color4;
  18046. protected _size: number | {
  18047. width: number;
  18048. height: number;
  18049. };
  18050. protected _initialSizeParameter: number | {
  18051. width: number;
  18052. height: number;
  18053. } | {
  18054. ratio: number;
  18055. };
  18056. protected _sizeRatio: Nullable<number>;
  18057. /** @hidden */
  18058. _generateMipMaps: boolean;
  18059. protected _renderingManager: RenderingManager;
  18060. /** @hidden */
  18061. _waitingRenderList: string[];
  18062. protected _doNotChangeAspectRatio: boolean;
  18063. protected _currentRefreshId: number;
  18064. protected _refreshRate: number;
  18065. protected _textureMatrix: Matrix;
  18066. protected _samples: number;
  18067. protected _renderTargetOptions: RenderTargetCreationOptions;
  18068. /**
  18069. * Gets render target creation options that were used.
  18070. */
  18071. readonly renderTargetOptions: RenderTargetCreationOptions;
  18072. protected _engine: Engine;
  18073. protected _onRatioRescale(): void;
  18074. /**
  18075. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18076. * It must define where the camera used to render the texture is set
  18077. */
  18078. boundingBoxPosition: Vector3;
  18079. private _boundingBoxSize;
  18080. /**
  18081. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18082. * When defined, the cubemap will switch to local mode
  18083. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18084. * @example https://www.babylonjs-playground.com/#RNASML
  18085. */
  18086. boundingBoxSize: Vector3;
  18087. /**
  18088. * In case the RTT has been created with a depth texture, get the associated
  18089. * depth texture.
  18090. * Otherwise, return null.
  18091. */
  18092. depthStencilTexture: Nullable<InternalTexture>;
  18093. /**
  18094. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18095. * or used a shadow, depth texture...
  18096. * @param name The friendly name of the texture
  18097. * @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)
  18098. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18099. * @param generateMipMaps True if mip maps need to be generated after render.
  18100. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18101. * @param type The type of the buffer in the RTT (int, half float, float...)
  18102. * @param isCube True if a cube texture needs to be created
  18103. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18104. * @param generateDepthBuffer True to generate a depth buffer
  18105. * @param generateStencilBuffer True to generate a stencil buffer
  18106. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18107. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18108. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18109. */
  18110. constructor(name: string, size: number | {
  18111. width: number;
  18112. height: number;
  18113. } | {
  18114. ratio: number;
  18115. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18116. /**
  18117. * Creates a depth stencil texture.
  18118. * This is only available in WebGL 2 or with the depth texture extension available.
  18119. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18120. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18121. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18122. */
  18123. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18124. private _processSizeParameter;
  18125. /**
  18126. * Define the number of samples to use in case of MSAA.
  18127. * It defaults to one meaning no MSAA has been enabled.
  18128. */
  18129. samples: number;
  18130. /**
  18131. * Resets the refresh counter of the texture and start bak from scratch.
  18132. * Could be useful to regenerate the texture if it is setup to render only once.
  18133. */
  18134. resetRefreshCounter(): void;
  18135. /**
  18136. * Define the refresh rate of the texture or the rendering frequency.
  18137. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18138. */
  18139. refreshRate: number;
  18140. /**
  18141. * Adds a post process to the render target rendering passes.
  18142. * @param postProcess define the post process to add
  18143. */
  18144. addPostProcess(postProcess: PostProcess): void;
  18145. /**
  18146. * Clear all the post processes attached to the render target
  18147. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18148. */
  18149. clearPostProcesses(dispose?: boolean): void;
  18150. /**
  18151. * Remove one of the post process from the list of attached post processes to the texture
  18152. * @param postProcess define the post process to remove from the list
  18153. */
  18154. removePostProcess(postProcess: PostProcess): void;
  18155. /** @hidden */
  18156. _shouldRender(): boolean;
  18157. /**
  18158. * Gets the actual render size of the texture.
  18159. * @returns the width of the render size
  18160. */
  18161. getRenderSize(): number;
  18162. /**
  18163. * Gets the actual render width of the texture.
  18164. * @returns the width of the render size
  18165. */
  18166. getRenderWidth(): number;
  18167. /**
  18168. * Gets the actual render height of the texture.
  18169. * @returns the height of the render size
  18170. */
  18171. getRenderHeight(): number;
  18172. /**
  18173. * Get if the texture can be rescaled or not.
  18174. */
  18175. readonly canRescale: boolean;
  18176. /**
  18177. * Resize the texture using a ratio.
  18178. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18179. */
  18180. scale(ratio: number): void;
  18181. /**
  18182. * Get the texture reflection matrix used to rotate/transform the reflection.
  18183. * @returns the reflection matrix
  18184. */
  18185. getReflectionTextureMatrix(): Matrix;
  18186. /**
  18187. * Resize the texture to a new desired size.
  18188. * Be carrefull as it will recreate all the data in the new texture.
  18189. * @param size Define the new size. It can be:
  18190. * - a number for squared texture,
  18191. * - an object containing { width: number, height: number }
  18192. * - or an object containing a ratio { ratio: number }
  18193. */
  18194. resize(size: number | {
  18195. width: number;
  18196. height: number;
  18197. } | {
  18198. ratio: number;
  18199. }): void;
  18200. /**
  18201. * Renders all the objects from the render list into the texture.
  18202. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18203. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18204. */
  18205. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18206. private _bestReflectionRenderTargetDimension;
  18207. /**
  18208. * @hidden
  18209. * @param faceIndex face index to bind to if this is a cubetexture
  18210. */
  18211. _bindFrameBuffer(faceIndex?: number): void;
  18212. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18213. private renderToTarget;
  18214. /**
  18215. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18216. * This allowed control for front to back rendering or reversly depending of the special needs.
  18217. *
  18218. * @param renderingGroupId The rendering group id corresponding to its index
  18219. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18220. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18221. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18222. */
  18223. 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;
  18224. /**
  18225. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18226. *
  18227. * @param renderingGroupId The rendering group id corresponding to its index
  18228. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18229. */
  18230. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18231. /**
  18232. * Clones the texture.
  18233. * @returns the cloned texture
  18234. */
  18235. clone(): RenderTargetTexture;
  18236. /**
  18237. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18238. * @returns The JSON representation of the texture
  18239. */
  18240. serialize(): any;
  18241. /**
  18242. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18243. */
  18244. disposeFramebufferObjects(): void;
  18245. /**
  18246. * Dispose the texture and release its associated resources.
  18247. */
  18248. dispose(): void;
  18249. /** @hidden */
  18250. _rebuild(): void;
  18251. /**
  18252. * Clear the info related to rendering groups preventing retention point in material dispose.
  18253. */
  18254. freeRenderingGroups(): void;
  18255. /**
  18256. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18257. * @returns the view count
  18258. */
  18259. getViewCount(): number;
  18260. }
  18261. }
  18262. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18263. import { Scene } from "babylonjs/scene";
  18264. import { Plane } from "babylonjs/Maths/math";
  18265. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18266. /**
  18267. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18268. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18269. * You can then easily use it as a reflectionTexture on a flat surface.
  18270. * In case the surface is not a plane, please consider relying on reflection probes.
  18271. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18272. */
  18273. export class MirrorTexture extends RenderTargetTexture {
  18274. private scene;
  18275. /**
  18276. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18277. * 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.
  18278. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18279. */
  18280. mirrorPlane: Plane;
  18281. /**
  18282. * Define the blur ratio used to blur the reflection if needed.
  18283. */
  18284. blurRatio: number;
  18285. /**
  18286. * Define the adaptive blur kernel used to blur the reflection if needed.
  18287. * This will autocompute the closest best match for the `blurKernel`
  18288. */
  18289. adaptiveBlurKernel: number;
  18290. /**
  18291. * Define the blur kernel used to blur the reflection if needed.
  18292. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18293. */
  18294. blurKernel: number;
  18295. /**
  18296. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18297. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18298. */
  18299. blurKernelX: number;
  18300. /**
  18301. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18302. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18303. */
  18304. blurKernelY: number;
  18305. private _autoComputeBlurKernel;
  18306. protected _onRatioRescale(): void;
  18307. private _updateGammaSpace;
  18308. private _imageProcessingConfigChangeObserver;
  18309. private _transformMatrix;
  18310. private _mirrorMatrix;
  18311. private _savedViewMatrix;
  18312. private _blurX;
  18313. private _blurY;
  18314. private _adaptiveBlurKernel;
  18315. private _blurKernelX;
  18316. private _blurKernelY;
  18317. private _blurRatio;
  18318. /**
  18319. * Instantiates a Mirror Texture.
  18320. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18321. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18322. * You can then easily use it as a reflectionTexture on a flat surface.
  18323. * In case the surface is not a plane, please consider relying on reflection probes.
  18324. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18325. * @param name
  18326. * @param size
  18327. * @param scene
  18328. * @param generateMipMaps
  18329. * @param type
  18330. * @param samplingMode
  18331. * @param generateDepthBuffer
  18332. */
  18333. constructor(name: string, size: number | {
  18334. width: number;
  18335. height: number;
  18336. } | {
  18337. ratio: number;
  18338. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18339. private _preparePostProcesses;
  18340. /**
  18341. * Clone the mirror texture.
  18342. * @returns the cloned texture
  18343. */
  18344. clone(): MirrorTexture;
  18345. /**
  18346. * Serialize the texture to a JSON representation you could use in Parse later on
  18347. * @returns the serialized JSON representation
  18348. */
  18349. serialize(): any;
  18350. /**
  18351. * Dispose the texture and release its associated resources.
  18352. */
  18353. dispose(): void;
  18354. }
  18355. }
  18356. declare module "babylonjs/Materials/Textures/texture" {
  18357. import { Observable } from "babylonjs/Misc/observable";
  18358. import { Nullable } from "babylonjs/types";
  18359. import { Scene } from "babylonjs/scene";
  18360. import { Matrix } from "babylonjs/Maths/math";
  18361. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18362. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18363. /**
  18364. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18365. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18366. */
  18367. export class Texture extends BaseTexture {
  18368. /** @hidden */
  18369. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18370. /** @hidden */
  18371. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18372. /** @hidden */
  18373. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18374. /** nearest is mag = nearest and min = nearest and mip = linear */
  18375. static readonly NEAREST_SAMPLINGMODE: number;
  18376. /** nearest is mag = nearest and min = nearest and mip = linear */
  18377. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18378. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18379. static readonly BILINEAR_SAMPLINGMODE: number;
  18380. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18381. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18382. /** Trilinear is mag = linear and min = linear and mip = linear */
  18383. static readonly TRILINEAR_SAMPLINGMODE: number;
  18384. /** Trilinear is mag = linear and min = linear and mip = linear */
  18385. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18386. /** mag = nearest and min = nearest and mip = nearest */
  18387. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18388. /** mag = nearest and min = linear and mip = nearest */
  18389. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18390. /** mag = nearest and min = linear and mip = linear */
  18391. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18392. /** mag = nearest and min = linear and mip = none */
  18393. static readonly NEAREST_LINEAR: number;
  18394. /** mag = nearest and min = nearest and mip = none */
  18395. static readonly NEAREST_NEAREST: number;
  18396. /** mag = linear and min = nearest and mip = nearest */
  18397. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18398. /** mag = linear and min = nearest and mip = linear */
  18399. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18400. /** mag = linear and min = linear and mip = none */
  18401. static readonly LINEAR_LINEAR: number;
  18402. /** mag = linear and min = nearest and mip = none */
  18403. static readonly LINEAR_NEAREST: number;
  18404. /** Explicit coordinates mode */
  18405. static readonly EXPLICIT_MODE: number;
  18406. /** Spherical coordinates mode */
  18407. static readonly SPHERICAL_MODE: number;
  18408. /** Planar coordinates mode */
  18409. static readonly PLANAR_MODE: number;
  18410. /** Cubic coordinates mode */
  18411. static readonly CUBIC_MODE: number;
  18412. /** Projection coordinates mode */
  18413. static readonly PROJECTION_MODE: number;
  18414. /** Inverse Cubic coordinates mode */
  18415. static readonly SKYBOX_MODE: number;
  18416. /** Inverse Cubic coordinates mode */
  18417. static readonly INVCUBIC_MODE: number;
  18418. /** Equirectangular coordinates mode */
  18419. static readonly EQUIRECTANGULAR_MODE: number;
  18420. /** Equirectangular Fixed coordinates mode */
  18421. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18422. /** Equirectangular Fixed Mirrored coordinates mode */
  18423. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18424. /** Texture is not repeating outside of 0..1 UVs */
  18425. static readonly CLAMP_ADDRESSMODE: number;
  18426. /** Texture is repeating outside of 0..1 UVs */
  18427. static readonly WRAP_ADDRESSMODE: number;
  18428. /** Texture is repeating and mirrored */
  18429. static readonly MIRROR_ADDRESSMODE: number;
  18430. /**
  18431. * 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
  18432. */
  18433. static UseSerializedUrlIfAny: boolean;
  18434. /**
  18435. * Define the url of the texture.
  18436. */
  18437. url: Nullable<string>;
  18438. /**
  18439. * Define an offset on the texture to offset the u coordinates of the UVs
  18440. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18441. */
  18442. uOffset: number;
  18443. /**
  18444. * Define an offset on the texture to offset the v coordinates of the UVs
  18445. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18446. */
  18447. vOffset: number;
  18448. /**
  18449. * Define an offset on the texture to scale the u coordinates of the UVs
  18450. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18451. */
  18452. uScale: number;
  18453. /**
  18454. * Define an offset on the texture to scale the v coordinates of the UVs
  18455. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18456. */
  18457. vScale: number;
  18458. /**
  18459. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18460. * @see http://doc.babylonjs.com/how_to/more_materials
  18461. */
  18462. uAng: number;
  18463. /**
  18464. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18465. * @see http://doc.babylonjs.com/how_to/more_materials
  18466. */
  18467. vAng: number;
  18468. /**
  18469. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18470. * @see http://doc.babylonjs.com/how_to/more_materials
  18471. */
  18472. wAng: number;
  18473. /**
  18474. * Defines the center of rotation (U)
  18475. */
  18476. uRotationCenter: number;
  18477. /**
  18478. * Defines the center of rotation (V)
  18479. */
  18480. vRotationCenter: number;
  18481. /**
  18482. * Defines the center of rotation (W)
  18483. */
  18484. wRotationCenter: number;
  18485. /**
  18486. * Are mip maps generated for this texture or not.
  18487. */
  18488. readonly noMipmap: boolean;
  18489. /**
  18490. * List of inspectable custom properties (used by the Inspector)
  18491. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18492. */
  18493. inspectableCustomProperties: IInspectable[];
  18494. private _noMipmap;
  18495. /** @hidden */
  18496. _invertY: boolean;
  18497. private _rowGenerationMatrix;
  18498. private _cachedTextureMatrix;
  18499. private _projectionModeMatrix;
  18500. private _t0;
  18501. private _t1;
  18502. private _t2;
  18503. private _cachedUOffset;
  18504. private _cachedVOffset;
  18505. private _cachedUScale;
  18506. private _cachedVScale;
  18507. private _cachedUAng;
  18508. private _cachedVAng;
  18509. private _cachedWAng;
  18510. private _cachedProjectionMatrixId;
  18511. private _cachedCoordinatesMode;
  18512. /** @hidden */
  18513. protected _initialSamplingMode: number;
  18514. /** @hidden */
  18515. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18516. private _deleteBuffer;
  18517. protected _format: Nullable<number>;
  18518. private _delayedOnLoad;
  18519. private _delayedOnError;
  18520. /**
  18521. * Observable triggered once the texture has been loaded.
  18522. */
  18523. onLoadObservable: Observable<Texture>;
  18524. protected _isBlocking: boolean;
  18525. /**
  18526. * Is the texture preventing material to render while loading.
  18527. * If false, a default texture will be used instead of the loading one during the preparation step.
  18528. */
  18529. isBlocking: boolean;
  18530. /**
  18531. * Get the current sampling mode associated with the texture.
  18532. */
  18533. readonly samplingMode: number;
  18534. /**
  18535. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18536. */
  18537. readonly invertY: boolean;
  18538. /**
  18539. * Instantiates a new texture.
  18540. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18541. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18542. * @param url define the url of the picture to load as a texture
  18543. * @param scene define the scene the texture will belong to
  18544. * @param noMipmap define if the texture will require mip maps or not
  18545. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18546. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18547. * @param onLoad define a callback triggered when the texture has been loaded
  18548. * @param onError define a callback triggered when an error occurred during the loading session
  18549. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18550. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18551. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18552. */
  18553. 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);
  18554. /**
  18555. * Update the url (and optional buffer) of this texture if url was null during construction.
  18556. * @param url the url of the texture
  18557. * @param buffer the buffer of the texture (defaults to null)
  18558. * @param onLoad callback called when the texture is loaded (defaults to null)
  18559. */
  18560. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18561. /**
  18562. * Finish the loading sequence of a texture flagged as delayed load.
  18563. * @hidden
  18564. */
  18565. delayLoad(): void;
  18566. private _prepareRowForTextureGeneration;
  18567. /**
  18568. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18569. * @returns the transform matrix of the texture.
  18570. */
  18571. getTextureMatrix(): Matrix;
  18572. /**
  18573. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18574. * @returns The reflection texture transform
  18575. */
  18576. getReflectionTextureMatrix(): Matrix;
  18577. /**
  18578. * Clones the texture.
  18579. * @returns the cloned texture
  18580. */
  18581. clone(): Texture;
  18582. /**
  18583. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18584. * @returns The JSON representation of the texture
  18585. */
  18586. serialize(): any;
  18587. /**
  18588. * Get the current class name of the texture useful for serialization or dynamic coding.
  18589. * @returns "Texture"
  18590. */
  18591. getClassName(): string;
  18592. /**
  18593. * Dispose the texture and release its associated resources.
  18594. */
  18595. dispose(): void;
  18596. /**
  18597. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18598. * @param parsedTexture Define the JSON representation of the texture
  18599. * @param scene Define the scene the parsed texture should be instantiated in
  18600. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18601. * @returns The parsed texture if successful
  18602. */
  18603. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18604. /**
  18605. * Creates a texture from its base 64 representation.
  18606. * @param data Define the base64 payload without the data: prefix
  18607. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18608. * @param scene Define the scene the texture should belong to
  18609. * @param noMipmap Forces the texture to not create mip map information if true
  18610. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18611. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18612. * @param onLoad define a callback triggered when the texture has been loaded
  18613. * @param onError define a callback triggered when an error occurred during the loading session
  18614. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18615. * @returns the created texture
  18616. */
  18617. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18618. /**
  18619. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18620. * @param data Define the base64 payload without the data: prefix
  18621. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18622. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18623. * @param scene Define the scene the texture should belong to
  18624. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18625. * @param noMipmap Forces the texture to not create mip map information if true
  18626. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18627. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18628. * @param onLoad define a callback triggered when the texture has been loaded
  18629. * @param onError define a callback triggered when an error occurred during the loading session
  18630. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18631. * @returns the created texture
  18632. */
  18633. 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;
  18634. }
  18635. }
  18636. declare module "babylonjs/Materials/Textures/rawTexture" {
  18637. import { Scene } from "babylonjs/scene";
  18638. import { Texture } from "babylonjs/Materials/Textures/texture";
  18639. /**
  18640. * Raw texture can help creating a texture directly from an array of data.
  18641. * This can be super useful if you either get the data from an uncompressed source or
  18642. * if you wish to create your texture pixel by pixel.
  18643. */
  18644. export class RawTexture extends Texture {
  18645. /**
  18646. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18647. */
  18648. format: number;
  18649. private _engine;
  18650. /**
  18651. * Instantiates a new RawTexture.
  18652. * Raw texture can help creating a texture directly from an array of data.
  18653. * This can be super useful if you either get the data from an uncompressed source or
  18654. * if you wish to create your texture pixel by pixel.
  18655. * @param data define the array of data to use to create the texture
  18656. * @param width define the width of the texture
  18657. * @param height define the height of the texture
  18658. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18659. * @param scene define the scene the texture belongs to
  18660. * @param generateMipMaps define whether mip maps should be generated or not
  18661. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18662. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18663. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18664. */
  18665. constructor(data: ArrayBufferView, width: number, height: number,
  18666. /**
  18667. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18668. */
  18669. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18670. /**
  18671. * Updates the texture underlying data.
  18672. * @param data Define the new data of the texture
  18673. */
  18674. update(data: ArrayBufferView): void;
  18675. /**
  18676. * Creates a luminance texture from some data.
  18677. * @param data Define the texture data
  18678. * @param width Define the width of the texture
  18679. * @param height Define the height of the texture
  18680. * @param scene Define the scene the texture belongs to
  18681. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18682. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18683. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18684. * @returns the luminance texture
  18685. */
  18686. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18687. /**
  18688. * Creates a luminance alpha texture from some data.
  18689. * @param data Define the texture data
  18690. * @param width Define the width of the texture
  18691. * @param height Define the height of the texture
  18692. * @param scene Define the scene the texture belongs to
  18693. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18694. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18695. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18696. * @returns the luminance alpha texture
  18697. */
  18698. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18699. /**
  18700. * Creates an alpha texture from some data.
  18701. * @param data Define the texture data
  18702. * @param width Define the width of the texture
  18703. * @param height Define the height of the texture
  18704. * @param scene Define the scene the texture belongs to
  18705. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18706. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18707. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18708. * @returns the alpha texture
  18709. */
  18710. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18711. /**
  18712. * Creates a RGB texture from some data.
  18713. * @param data Define the texture data
  18714. * @param width Define the width of the texture
  18715. * @param height Define the height of the texture
  18716. * @param scene Define the scene the texture belongs to
  18717. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18718. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18719. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18720. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18721. * @returns the RGB alpha texture
  18722. */
  18723. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18724. /**
  18725. * Creates a RGBA texture from some data.
  18726. * @param data Define the texture data
  18727. * @param width Define the width of the texture
  18728. * @param height Define the height of the texture
  18729. * @param scene Define the scene the texture belongs to
  18730. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18731. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18732. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18733. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18734. * @returns the RGBA texture
  18735. */
  18736. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18737. /**
  18738. * Creates a R texture from some data.
  18739. * @param data Define the texture data
  18740. * @param width Define the width of the texture
  18741. * @param height Define the height of the texture
  18742. * @param scene Define the scene the texture belongs to
  18743. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18744. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18745. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18746. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18747. * @returns the R texture
  18748. */
  18749. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18750. }
  18751. }
  18752. declare module "babylonjs/Animations/runtimeAnimation" {
  18753. import { Animation } from "babylonjs/Animations/animation";
  18754. import { Animatable } from "babylonjs/Animations/animatable";
  18755. import { Scene } from "babylonjs/scene";
  18756. /**
  18757. * Defines a runtime animation
  18758. */
  18759. export class RuntimeAnimation {
  18760. private _events;
  18761. /**
  18762. * The current frame of the runtime animation
  18763. */
  18764. private _currentFrame;
  18765. /**
  18766. * The animation used by the runtime animation
  18767. */
  18768. private _animation;
  18769. /**
  18770. * The target of the runtime animation
  18771. */
  18772. private _target;
  18773. /**
  18774. * The initiating animatable
  18775. */
  18776. private _host;
  18777. /**
  18778. * The original value of the runtime animation
  18779. */
  18780. private _originalValue;
  18781. /**
  18782. * The original blend value of the runtime animation
  18783. */
  18784. private _originalBlendValue;
  18785. /**
  18786. * The offsets cache of the runtime animation
  18787. */
  18788. private _offsetsCache;
  18789. /**
  18790. * The high limits cache of the runtime animation
  18791. */
  18792. private _highLimitsCache;
  18793. /**
  18794. * Specifies if the runtime animation has been stopped
  18795. */
  18796. private _stopped;
  18797. /**
  18798. * The blending factor of the runtime animation
  18799. */
  18800. private _blendingFactor;
  18801. /**
  18802. * The BabylonJS scene
  18803. */
  18804. private _scene;
  18805. /**
  18806. * The current value of the runtime animation
  18807. */
  18808. private _currentValue;
  18809. /** @hidden */
  18810. _workValue: any;
  18811. /**
  18812. * The active target of the runtime animation
  18813. */
  18814. private _activeTarget;
  18815. /**
  18816. * The target path of the runtime animation
  18817. */
  18818. private _targetPath;
  18819. /**
  18820. * The weight of the runtime animation
  18821. */
  18822. private _weight;
  18823. /**
  18824. * The ratio offset of the runtime animation
  18825. */
  18826. private _ratioOffset;
  18827. /**
  18828. * The previous delay of the runtime animation
  18829. */
  18830. private _previousDelay;
  18831. /**
  18832. * The previous ratio of the runtime animation
  18833. */
  18834. private _previousRatio;
  18835. /**
  18836. * Gets the current frame of the runtime animation
  18837. */
  18838. readonly currentFrame: number;
  18839. /**
  18840. * Gets the weight of the runtime animation
  18841. */
  18842. readonly weight: number;
  18843. /**
  18844. * Gets the current value of the runtime animation
  18845. */
  18846. readonly currentValue: any;
  18847. /**
  18848. * Gets the target path of the runtime animation
  18849. */
  18850. readonly targetPath: string;
  18851. /**
  18852. * Gets the actual target of the runtime animation
  18853. */
  18854. readonly target: any;
  18855. /**
  18856. * Create a new RuntimeAnimation object
  18857. * @param target defines the target of the animation
  18858. * @param animation defines the source animation object
  18859. * @param scene defines the hosting scene
  18860. * @param host defines the initiating Animatable
  18861. */
  18862. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18863. /**
  18864. * Gets the animation from the runtime animation
  18865. */
  18866. readonly animation: Animation;
  18867. /**
  18868. * Resets the runtime animation to the beginning
  18869. * @param restoreOriginal defines whether to restore the target property to the original value
  18870. */
  18871. reset(restoreOriginal?: boolean): void;
  18872. /**
  18873. * Specifies if the runtime animation is stopped
  18874. * @returns Boolean specifying if the runtime animation is stopped
  18875. */
  18876. isStopped(): boolean;
  18877. /**
  18878. * Disposes of the runtime animation
  18879. */
  18880. dispose(): void;
  18881. /**
  18882. * Interpolates the animation from the current frame
  18883. * @param currentFrame The frame to interpolate the animation to
  18884. * @param repeatCount The number of times that the animation should loop
  18885. * @param loopMode The type of looping mode to use
  18886. * @param offsetValue Animation offset value
  18887. * @param highLimitValue The high limit value
  18888. * @returns The interpolated value
  18889. */
  18890. private _interpolate;
  18891. /**
  18892. * Apply the interpolated value to the target
  18893. * @param currentValue defines the value computed by the animation
  18894. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18895. */
  18896. setValue(currentValue: any, weight?: number): void;
  18897. private _setValue;
  18898. /**
  18899. * Gets the loop pmode of the runtime animation
  18900. * @returns Loop Mode
  18901. */
  18902. private _getCorrectLoopMode;
  18903. /**
  18904. * Move the current animation to a given frame
  18905. * @param frame defines the frame to move to
  18906. */
  18907. goToFrame(frame: number): void;
  18908. /**
  18909. * @hidden Internal use only
  18910. */
  18911. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18912. /**
  18913. * Execute the current animation
  18914. * @param delay defines the delay to add to the current frame
  18915. * @param from defines the lower bound of the animation range
  18916. * @param to defines the upper bound of the animation range
  18917. * @param loop defines if the current animation must loop
  18918. * @param speedRatio defines the current speed ratio
  18919. * @param weight defines the weight of the animation (default is -1 so no weight)
  18920. * @param onLoop optional callback called when animation loops
  18921. * @returns a boolean indicating if the animation is running
  18922. */
  18923. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18924. }
  18925. }
  18926. declare module "babylonjs/Animations/animatable" {
  18927. import { Animation } from "babylonjs/Animations/animation";
  18928. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18929. import { Nullable } from "babylonjs/types";
  18930. import { Observable } from "babylonjs/Misc/observable";
  18931. import { Scene } from "babylonjs/scene";
  18932. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18933. import { Node } from "babylonjs/node";
  18934. /**
  18935. * Class used to store an actual running animation
  18936. */
  18937. export class Animatable {
  18938. /** defines the target object */
  18939. target: any;
  18940. /** defines the starting frame number (default is 0) */
  18941. fromFrame: number;
  18942. /** defines the ending frame number (default is 100) */
  18943. toFrame: number;
  18944. /** defines if the animation must loop (default is false) */
  18945. loopAnimation: boolean;
  18946. /** defines a callback to call when animation ends if it is not looping */
  18947. onAnimationEnd?: (() => void) | null | undefined;
  18948. /** defines a callback to call when animation loops */
  18949. onAnimationLoop?: (() => void) | null | undefined;
  18950. private _localDelayOffset;
  18951. private _pausedDelay;
  18952. private _runtimeAnimations;
  18953. private _paused;
  18954. private _scene;
  18955. private _speedRatio;
  18956. private _weight;
  18957. private _syncRoot;
  18958. /**
  18959. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18960. * This will only apply for non looping animation (default is true)
  18961. */
  18962. disposeOnEnd: boolean;
  18963. /**
  18964. * Gets a boolean indicating if the animation has started
  18965. */
  18966. animationStarted: boolean;
  18967. /**
  18968. * Observer raised when the animation ends
  18969. */
  18970. onAnimationEndObservable: Observable<Animatable>;
  18971. /**
  18972. * Observer raised when the animation loops
  18973. */
  18974. onAnimationLoopObservable: Observable<Animatable>;
  18975. /**
  18976. * Gets the root Animatable used to synchronize and normalize animations
  18977. */
  18978. readonly syncRoot: Animatable;
  18979. /**
  18980. * Gets the current frame of the first RuntimeAnimation
  18981. * Used to synchronize Animatables
  18982. */
  18983. readonly masterFrame: number;
  18984. /**
  18985. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18986. */
  18987. weight: number;
  18988. /**
  18989. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18990. */
  18991. speedRatio: number;
  18992. /**
  18993. * Creates a new Animatable
  18994. * @param scene defines the hosting scene
  18995. * @param target defines the target object
  18996. * @param fromFrame defines the starting frame number (default is 0)
  18997. * @param toFrame defines the ending frame number (default is 100)
  18998. * @param loopAnimation defines if the animation must loop (default is false)
  18999. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19000. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19001. * @param animations defines a group of animation to add to the new Animatable
  19002. * @param onAnimationLoop defines a callback to call when animation loops
  19003. */
  19004. constructor(scene: Scene,
  19005. /** defines the target object */
  19006. target: any,
  19007. /** defines the starting frame number (default is 0) */
  19008. fromFrame?: number,
  19009. /** defines the ending frame number (default is 100) */
  19010. toFrame?: number,
  19011. /** defines if the animation must loop (default is false) */
  19012. loopAnimation?: boolean, speedRatio?: number,
  19013. /** defines a callback to call when animation ends if it is not looping */
  19014. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19015. /** defines a callback to call when animation loops */
  19016. onAnimationLoop?: (() => void) | null | undefined);
  19017. /**
  19018. * Synchronize and normalize current Animatable with a source Animatable
  19019. * This is useful when using animation weights and when animations are not of the same length
  19020. * @param root defines the root Animatable to synchronize with
  19021. * @returns the current Animatable
  19022. */
  19023. syncWith(root: Animatable): Animatable;
  19024. /**
  19025. * Gets the list of runtime animations
  19026. * @returns an array of RuntimeAnimation
  19027. */
  19028. getAnimations(): RuntimeAnimation[];
  19029. /**
  19030. * Adds more animations to the current animatable
  19031. * @param target defines the target of the animations
  19032. * @param animations defines the new animations to add
  19033. */
  19034. appendAnimations(target: any, animations: Animation[]): void;
  19035. /**
  19036. * Gets the source animation for a specific property
  19037. * @param property defines the propertyu to look for
  19038. * @returns null or the source animation for the given property
  19039. */
  19040. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19041. /**
  19042. * Gets the runtime animation for a specific property
  19043. * @param property defines the propertyu to look for
  19044. * @returns null or the runtime animation for the given property
  19045. */
  19046. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19047. /**
  19048. * Resets the animatable to its original state
  19049. */
  19050. reset(): void;
  19051. /**
  19052. * Allows the animatable to blend with current running animations
  19053. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19054. * @param blendingSpeed defines the blending speed to use
  19055. */
  19056. enableBlending(blendingSpeed: number): void;
  19057. /**
  19058. * Disable animation blending
  19059. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19060. */
  19061. disableBlending(): void;
  19062. /**
  19063. * Jump directly to a given frame
  19064. * @param frame defines the frame to jump to
  19065. */
  19066. goToFrame(frame: number): void;
  19067. /**
  19068. * Pause the animation
  19069. */
  19070. pause(): void;
  19071. /**
  19072. * Restart the animation
  19073. */
  19074. restart(): void;
  19075. private _raiseOnAnimationEnd;
  19076. /**
  19077. * Stop and delete the current animation
  19078. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19079. * @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)
  19080. */
  19081. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19082. /**
  19083. * Wait asynchronously for the animation to end
  19084. * @returns a promise which will be fullfilled when the animation ends
  19085. */
  19086. waitAsync(): Promise<Animatable>;
  19087. /** @hidden */
  19088. _animate(delay: number): boolean;
  19089. }
  19090. module "babylonjs/scene" {
  19091. interface Scene {
  19092. /** @hidden */
  19093. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19094. /** @hidden */
  19095. _processLateAnimationBindingsForMatrices(holder: {
  19096. totalWeight: number;
  19097. animations: RuntimeAnimation[];
  19098. originalValue: Matrix;
  19099. }): any;
  19100. /** @hidden */
  19101. _processLateAnimationBindingsForQuaternions(holder: {
  19102. totalWeight: number;
  19103. animations: RuntimeAnimation[];
  19104. originalValue: Quaternion;
  19105. }, refQuaternion: Quaternion): Quaternion;
  19106. /** @hidden */
  19107. _processLateAnimationBindings(): void;
  19108. /**
  19109. * Will start the animation sequence of a given target
  19110. * @param target defines the target
  19111. * @param from defines from which frame should animation start
  19112. * @param to defines until which frame should animation run.
  19113. * @param weight defines the weight to apply to the animation (1.0 by default)
  19114. * @param loop defines if the animation loops
  19115. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19116. * @param onAnimationEnd defines the function to be executed when the animation ends
  19117. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19118. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19119. * @param onAnimationLoop defines the callback to call when an animation loops
  19120. * @returns the animatable object created for this animation
  19121. */
  19122. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19123. /**
  19124. * Will start the animation sequence of a given target
  19125. * @param target defines the target
  19126. * @param from defines from which frame should animation start
  19127. * @param to defines until which frame should animation run.
  19128. * @param loop defines if the animation loops
  19129. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19130. * @param onAnimationEnd defines the function to be executed when the animation ends
  19131. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19132. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19133. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19134. * @param onAnimationLoop defines the callback to call when an animation loops
  19135. * @returns the animatable object created for this animation
  19136. */
  19137. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19138. /**
  19139. * Will start the animation sequence of a given target and its hierarchy
  19140. * @param target defines the target
  19141. * @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.
  19142. * @param from defines from which frame should animation start
  19143. * @param to defines until which frame should animation run.
  19144. * @param loop defines if the animation loops
  19145. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19146. * @param onAnimationEnd defines the function to be executed when the animation ends
  19147. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19148. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19149. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19150. * @param onAnimationLoop defines the callback to call when an animation loops
  19151. * @returns the list of created animatables
  19152. */
  19153. 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[];
  19154. /**
  19155. * Begin a new animation on a given node
  19156. * @param target defines the target where the animation will take place
  19157. * @param animations defines the list of animations to start
  19158. * @param from defines the initial value
  19159. * @param to defines the final value
  19160. * @param loop defines if you want animation to loop (off by default)
  19161. * @param speedRatio defines the speed ratio to apply to all animations
  19162. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19163. * @param onAnimationLoop defines the callback to call when an animation loops
  19164. * @returns the list of created animatables
  19165. */
  19166. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19167. /**
  19168. * Begin a new animation on a given node and its hierarchy
  19169. * @param target defines the root node where the animation will take place
  19170. * @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.
  19171. * @param animations defines the list of animations to start
  19172. * @param from defines the initial value
  19173. * @param to defines the final value
  19174. * @param loop defines if you want animation to loop (off by default)
  19175. * @param speedRatio defines the speed ratio to apply to all animations
  19176. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19177. * @param onAnimationLoop defines the callback to call when an animation loops
  19178. * @returns the list of animatables created for all nodes
  19179. */
  19180. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19181. /**
  19182. * Gets the animatable associated with a specific target
  19183. * @param target defines the target of the animatable
  19184. * @returns the required animatable if found
  19185. */
  19186. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19187. /**
  19188. * Gets all animatables associated with a given target
  19189. * @param target defines the target to look animatables for
  19190. * @returns an array of Animatables
  19191. */
  19192. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19193. /**
  19194. * Will stop the animation of the given target
  19195. * @param target - the target
  19196. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19197. * @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)
  19198. */
  19199. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19200. /**
  19201. * Stops and removes all animations that have been applied to the scene
  19202. */
  19203. stopAllAnimations(): void;
  19204. }
  19205. }
  19206. module "babylonjs/Bones/bone" {
  19207. interface Bone {
  19208. /**
  19209. * Copy an animation range from another bone
  19210. * @param source defines the source bone
  19211. * @param rangeName defines the range name to copy
  19212. * @param frameOffset defines the frame offset
  19213. * @param rescaleAsRequired defines if rescaling must be applied if required
  19214. * @param skelDimensionsRatio defines the scaling ratio
  19215. * @returns true if operation was successful
  19216. */
  19217. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19218. }
  19219. }
  19220. }
  19221. declare module "babylonjs/Bones/skeleton" {
  19222. import { Bone } from "babylonjs/Bones/bone";
  19223. import { IAnimatable } from "babylonjs/Misc/tools";
  19224. import { Observable } from "babylonjs/Misc/observable";
  19225. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19226. import { Scene } from "babylonjs/scene";
  19227. import { Nullable } from "babylonjs/types";
  19228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19229. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19230. import { Animatable } from "babylonjs/Animations/animatable";
  19231. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19232. import { Animation } from "babylonjs/Animations/animation";
  19233. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19234. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19235. /**
  19236. * Class used to handle skinning animations
  19237. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19238. */
  19239. export class Skeleton implements IAnimatable {
  19240. /** defines the skeleton name */
  19241. name: string;
  19242. /** defines the skeleton Id */
  19243. id: string;
  19244. /**
  19245. * Defines the list of child bones
  19246. */
  19247. bones: Bone[];
  19248. /**
  19249. * Defines an estimate of the dimension of the skeleton at rest
  19250. */
  19251. dimensionsAtRest: Vector3;
  19252. /**
  19253. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19254. */
  19255. needInitialSkinMatrix: boolean;
  19256. /**
  19257. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19258. */
  19259. overrideMesh: Nullable<AbstractMesh>;
  19260. /**
  19261. * Gets the list of animations attached to this skeleton
  19262. */
  19263. animations: Array<Animation>;
  19264. private _scene;
  19265. private _isDirty;
  19266. private _transformMatrices;
  19267. private _transformMatrixTexture;
  19268. private _meshesWithPoseMatrix;
  19269. private _animatables;
  19270. private _identity;
  19271. private _synchronizedWithMesh;
  19272. private _ranges;
  19273. private _lastAbsoluteTransformsUpdateId;
  19274. private _canUseTextureForBones;
  19275. private _uniqueId;
  19276. /** @hidden */
  19277. _numBonesWithLinkedTransformNode: number;
  19278. /**
  19279. * Specifies if the skeleton should be serialized
  19280. */
  19281. doNotSerialize: boolean;
  19282. private _useTextureToStoreBoneMatrices;
  19283. /**
  19284. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19285. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19286. */
  19287. useTextureToStoreBoneMatrices: boolean;
  19288. private _animationPropertiesOverride;
  19289. /**
  19290. * Gets or sets the animation properties override
  19291. */
  19292. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19293. /**
  19294. * List of inspectable custom properties (used by the Inspector)
  19295. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19296. */
  19297. inspectableCustomProperties: IInspectable[];
  19298. /**
  19299. * An observable triggered before computing the skeleton's matrices
  19300. */
  19301. onBeforeComputeObservable: Observable<Skeleton>;
  19302. /**
  19303. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19304. */
  19305. readonly isUsingTextureForMatrices: boolean;
  19306. /**
  19307. * Gets the unique ID of this skeleton
  19308. */
  19309. readonly uniqueId: number;
  19310. /**
  19311. * Creates a new skeleton
  19312. * @param name defines the skeleton name
  19313. * @param id defines the skeleton Id
  19314. * @param scene defines the hosting scene
  19315. */
  19316. constructor(
  19317. /** defines the skeleton name */
  19318. name: string,
  19319. /** defines the skeleton Id */
  19320. id: string, scene: Scene);
  19321. /**
  19322. * Gets the current object class name.
  19323. * @return the class name
  19324. */
  19325. getClassName(): string;
  19326. /**
  19327. * Returns an array containing the root bones
  19328. * @returns an array containing the root bones
  19329. */
  19330. getChildren(): Array<Bone>;
  19331. /**
  19332. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19333. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19334. * @returns a Float32Array containing matrices data
  19335. */
  19336. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19337. /**
  19338. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19339. * @returns a raw texture containing the data
  19340. */
  19341. getTransformMatrixTexture(): Nullable<RawTexture>;
  19342. /**
  19343. * Gets the current hosting scene
  19344. * @returns a scene object
  19345. */
  19346. getScene(): Scene;
  19347. /**
  19348. * Gets a string representing the current skeleton data
  19349. * @param fullDetails defines a boolean indicating if we want a verbose version
  19350. * @returns a string representing the current skeleton data
  19351. */
  19352. toString(fullDetails?: boolean): string;
  19353. /**
  19354. * Get bone's index searching by name
  19355. * @param name defines bone's name to search for
  19356. * @return the indice of the bone. Returns -1 if not found
  19357. */
  19358. getBoneIndexByName(name: string): number;
  19359. /**
  19360. * Creater a new animation range
  19361. * @param name defines the name of the range
  19362. * @param from defines the start key
  19363. * @param to defines the end key
  19364. */
  19365. createAnimationRange(name: string, from: number, to: number): void;
  19366. /**
  19367. * Delete a specific animation range
  19368. * @param name defines the name of the range
  19369. * @param deleteFrames defines if frames must be removed as well
  19370. */
  19371. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19372. /**
  19373. * Gets a specific animation range
  19374. * @param name defines the name of the range to look for
  19375. * @returns the requested animation range or null if not found
  19376. */
  19377. getAnimationRange(name: string): Nullable<AnimationRange>;
  19378. /**
  19379. * Gets the list of all animation ranges defined on this skeleton
  19380. * @returns an array
  19381. */
  19382. getAnimationRanges(): Nullable<AnimationRange>[];
  19383. /**
  19384. * Copy animation range from a source skeleton.
  19385. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19386. * @param source defines the source skeleton
  19387. * @param name defines the name of the range to copy
  19388. * @param rescaleAsRequired defines if rescaling must be applied if required
  19389. * @returns true if operation was successful
  19390. */
  19391. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19392. /**
  19393. * Forces the skeleton to go to rest pose
  19394. */
  19395. returnToRest(): void;
  19396. private _getHighestAnimationFrame;
  19397. /**
  19398. * Begin a specific animation range
  19399. * @param name defines the name of the range to start
  19400. * @param loop defines if looping must be turned on (false by default)
  19401. * @param speedRatio defines the speed ratio to apply (1 by default)
  19402. * @param onAnimationEnd defines a callback which will be called when animation will end
  19403. * @returns a new animatable
  19404. */
  19405. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19406. /** @hidden */
  19407. _markAsDirty(): void;
  19408. /** @hidden */
  19409. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19410. /** @hidden */
  19411. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19412. private _computeTransformMatrices;
  19413. /**
  19414. * Build all resources required to render a skeleton
  19415. */
  19416. prepare(): void;
  19417. /**
  19418. * Gets the list of animatables currently running for this skeleton
  19419. * @returns an array of animatables
  19420. */
  19421. getAnimatables(): IAnimatable[];
  19422. /**
  19423. * Clone the current skeleton
  19424. * @param name defines the name of the new skeleton
  19425. * @param id defines the id of the enw skeleton
  19426. * @returns the new skeleton
  19427. */
  19428. clone(name: string, id: string): Skeleton;
  19429. /**
  19430. * Enable animation blending for this skeleton
  19431. * @param blendingSpeed defines the blending speed to apply
  19432. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19433. */
  19434. enableBlending(blendingSpeed?: number): void;
  19435. /**
  19436. * Releases all resources associated with the current skeleton
  19437. */
  19438. dispose(): void;
  19439. /**
  19440. * Serialize the skeleton in a JSON object
  19441. * @returns a JSON object
  19442. */
  19443. serialize(): any;
  19444. /**
  19445. * Creates a new skeleton from serialized data
  19446. * @param parsedSkeleton defines the serialized data
  19447. * @param scene defines the hosting scene
  19448. * @returns a new skeleton
  19449. */
  19450. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19451. /**
  19452. * Compute all node absolute transforms
  19453. * @param forceUpdate defines if computation must be done even if cache is up to date
  19454. */
  19455. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19456. /**
  19457. * Gets the root pose matrix
  19458. * @returns a matrix
  19459. */
  19460. getPoseMatrix(): Nullable<Matrix>;
  19461. /**
  19462. * Sorts bones per internal index
  19463. */
  19464. sortBones(): void;
  19465. private _sortBones;
  19466. }
  19467. }
  19468. declare module "babylonjs/Morph/morphTarget" {
  19469. import { IAnimatable } from "babylonjs/Misc/tools";
  19470. import { Observable } from "babylonjs/Misc/observable";
  19471. import { Nullable, FloatArray } from "babylonjs/types";
  19472. import { Scene } from "babylonjs/scene";
  19473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19474. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19475. /**
  19476. * Defines a target to use with MorphTargetManager
  19477. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19478. */
  19479. export class MorphTarget implements IAnimatable {
  19480. /** defines the name of the target */
  19481. name: string;
  19482. /**
  19483. * Gets or sets the list of animations
  19484. */
  19485. animations: import("babylonjs/Animations/animation").Animation[];
  19486. private _scene;
  19487. private _positions;
  19488. private _normals;
  19489. private _tangents;
  19490. private _influence;
  19491. /**
  19492. * Observable raised when the influence changes
  19493. */
  19494. onInfluenceChanged: Observable<boolean>;
  19495. /** @hidden */
  19496. _onDataLayoutChanged: Observable<void>;
  19497. /**
  19498. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19499. */
  19500. influence: number;
  19501. /**
  19502. * Gets or sets the id of the morph Target
  19503. */
  19504. id: string;
  19505. private _animationPropertiesOverride;
  19506. /**
  19507. * Gets or sets the animation properties override
  19508. */
  19509. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19510. /**
  19511. * Creates a new MorphTarget
  19512. * @param name defines the name of the target
  19513. * @param influence defines the influence to use
  19514. * @param scene defines the scene the morphtarget belongs to
  19515. */
  19516. constructor(
  19517. /** defines the name of the target */
  19518. name: string, influence?: number, scene?: Nullable<Scene>);
  19519. /**
  19520. * Gets a boolean defining if the target contains position data
  19521. */
  19522. readonly hasPositions: boolean;
  19523. /**
  19524. * Gets a boolean defining if the target contains normal data
  19525. */
  19526. readonly hasNormals: boolean;
  19527. /**
  19528. * Gets a boolean defining if the target contains tangent data
  19529. */
  19530. readonly hasTangents: boolean;
  19531. /**
  19532. * Affects position data to this target
  19533. * @param data defines the position data to use
  19534. */
  19535. setPositions(data: Nullable<FloatArray>): void;
  19536. /**
  19537. * Gets the position data stored in this target
  19538. * @returns a FloatArray containing the position data (or null if not present)
  19539. */
  19540. getPositions(): Nullable<FloatArray>;
  19541. /**
  19542. * Affects normal data to this target
  19543. * @param data defines the normal data to use
  19544. */
  19545. setNormals(data: Nullable<FloatArray>): void;
  19546. /**
  19547. * Gets the normal data stored in this target
  19548. * @returns a FloatArray containing the normal data (or null if not present)
  19549. */
  19550. getNormals(): Nullable<FloatArray>;
  19551. /**
  19552. * Affects tangent data to this target
  19553. * @param data defines the tangent data to use
  19554. */
  19555. setTangents(data: Nullable<FloatArray>): void;
  19556. /**
  19557. * Gets the tangent data stored in this target
  19558. * @returns a FloatArray containing the tangent data (or null if not present)
  19559. */
  19560. getTangents(): Nullable<FloatArray>;
  19561. /**
  19562. * Serializes the current target into a Serialization object
  19563. * @returns the serialized object
  19564. */
  19565. serialize(): any;
  19566. /**
  19567. * Returns the string "MorphTarget"
  19568. * @returns "MorphTarget"
  19569. */
  19570. getClassName(): string;
  19571. /**
  19572. * Creates a new target from serialized data
  19573. * @param serializationObject defines the serialized data to use
  19574. * @returns a new MorphTarget
  19575. */
  19576. static Parse(serializationObject: any): MorphTarget;
  19577. /**
  19578. * Creates a MorphTarget from mesh data
  19579. * @param mesh defines the source mesh
  19580. * @param name defines the name to use for the new target
  19581. * @param influence defines the influence to attach to the target
  19582. * @returns a new MorphTarget
  19583. */
  19584. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19585. }
  19586. }
  19587. declare module "babylonjs/Morph/morphTargetManager" {
  19588. import { Nullable } from "babylonjs/types";
  19589. import { Scene } from "babylonjs/scene";
  19590. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19591. /**
  19592. * This class is used to deform meshes using morphing between different targets
  19593. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19594. */
  19595. export class MorphTargetManager {
  19596. private _targets;
  19597. private _targetInfluenceChangedObservers;
  19598. private _targetDataLayoutChangedObservers;
  19599. private _activeTargets;
  19600. private _scene;
  19601. private _influences;
  19602. private _supportsNormals;
  19603. private _supportsTangents;
  19604. private _vertexCount;
  19605. private _uniqueId;
  19606. private _tempInfluences;
  19607. /**
  19608. * Creates a new MorphTargetManager
  19609. * @param scene defines the current scene
  19610. */
  19611. constructor(scene?: Nullable<Scene>);
  19612. /**
  19613. * Gets the unique ID of this manager
  19614. */
  19615. readonly uniqueId: number;
  19616. /**
  19617. * Gets the number of vertices handled by this manager
  19618. */
  19619. readonly vertexCount: number;
  19620. /**
  19621. * Gets a boolean indicating if this manager supports morphing of normals
  19622. */
  19623. readonly supportsNormals: boolean;
  19624. /**
  19625. * Gets a boolean indicating if this manager supports morphing of tangents
  19626. */
  19627. readonly supportsTangents: boolean;
  19628. /**
  19629. * Gets the number of targets stored in this manager
  19630. */
  19631. readonly numTargets: number;
  19632. /**
  19633. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19634. */
  19635. readonly numInfluencers: number;
  19636. /**
  19637. * Gets the list of influences (one per target)
  19638. */
  19639. readonly influences: Float32Array;
  19640. /**
  19641. * Gets the active target at specified index. An active target is a target with an influence > 0
  19642. * @param index defines the index to check
  19643. * @returns the requested target
  19644. */
  19645. getActiveTarget(index: number): MorphTarget;
  19646. /**
  19647. * Gets the target at specified index
  19648. * @param index defines the index to check
  19649. * @returns the requested target
  19650. */
  19651. getTarget(index: number): MorphTarget;
  19652. /**
  19653. * Add a new target to this manager
  19654. * @param target defines the target to add
  19655. */
  19656. addTarget(target: MorphTarget): void;
  19657. /**
  19658. * Removes a target from the manager
  19659. * @param target defines the target to remove
  19660. */
  19661. removeTarget(target: MorphTarget): void;
  19662. /**
  19663. * Serializes the current manager into a Serialization object
  19664. * @returns the serialized object
  19665. */
  19666. serialize(): any;
  19667. private _syncActiveTargets;
  19668. /**
  19669. * Syncrhonize the targets with all the meshes using this morph target manager
  19670. */
  19671. synchronize(): void;
  19672. /**
  19673. * Creates a new MorphTargetManager from serialized data
  19674. * @param serializationObject defines the serialized data
  19675. * @param scene defines the hosting scene
  19676. * @returns the new MorphTargetManager
  19677. */
  19678. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19679. }
  19680. }
  19681. declare module "babylonjs/Meshes/groundMesh" {
  19682. import { Scene } from "babylonjs/scene";
  19683. import { Vector3 } from "babylonjs/Maths/math";
  19684. import { Mesh } from "babylonjs/Meshes/mesh";
  19685. /**
  19686. * Mesh representing the gorund
  19687. */
  19688. export class GroundMesh extends Mesh {
  19689. /** If octree should be generated */
  19690. generateOctree: boolean;
  19691. private _heightQuads;
  19692. /** @hidden */
  19693. _subdivisionsX: number;
  19694. /** @hidden */
  19695. _subdivisionsY: number;
  19696. /** @hidden */
  19697. _width: number;
  19698. /** @hidden */
  19699. _height: number;
  19700. /** @hidden */
  19701. _minX: number;
  19702. /** @hidden */
  19703. _maxX: number;
  19704. /** @hidden */
  19705. _minZ: number;
  19706. /** @hidden */
  19707. _maxZ: number;
  19708. constructor(name: string, scene: Scene);
  19709. /**
  19710. * "GroundMesh"
  19711. * @returns "GroundMesh"
  19712. */
  19713. getClassName(): string;
  19714. /**
  19715. * The minimum of x and y subdivisions
  19716. */
  19717. readonly subdivisions: number;
  19718. /**
  19719. * X subdivisions
  19720. */
  19721. readonly subdivisionsX: number;
  19722. /**
  19723. * Y subdivisions
  19724. */
  19725. readonly subdivisionsY: number;
  19726. /**
  19727. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19728. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19729. * @param chunksCount the number of subdivisions for x and y
  19730. * @param octreeBlocksSize (Default: 32)
  19731. */
  19732. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19733. /**
  19734. * Returns a height (y) value in the Worl system :
  19735. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19736. * @param x x coordinate
  19737. * @param z z coordinate
  19738. * @returns the ground y position if (x, z) are outside the ground surface.
  19739. */
  19740. getHeightAtCoordinates(x: number, z: number): number;
  19741. /**
  19742. * Returns a normalized vector (Vector3) orthogonal to the ground
  19743. * at the ground coordinates (x, z) expressed in the World system.
  19744. * @param x x coordinate
  19745. * @param z z coordinate
  19746. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19747. */
  19748. getNormalAtCoordinates(x: number, z: number): Vector3;
  19749. /**
  19750. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19751. * at the ground coordinates (x, z) expressed in the World system.
  19752. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19753. * @param x x coordinate
  19754. * @param z z coordinate
  19755. * @param ref vector to store the result
  19756. * @returns the GroundMesh.
  19757. */
  19758. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19759. /**
  19760. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19761. * if the ground has been updated.
  19762. * This can be used in the render loop.
  19763. * @returns the GroundMesh.
  19764. */
  19765. updateCoordinateHeights(): GroundMesh;
  19766. private _getFacetAt;
  19767. private _initHeightQuads;
  19768. private _computeHeightQuads;
  19769. /**
  19770. * Serializes this ground mesh
  19771. * @param serializationObject object to write serialization to
  19772. */
  19773. serialize(serializationObject: any): void;
  19774. /**
  19775. * Parses a serialized ground mesh
  19776. * @param parsedMesh the serialized mesh
  19777. * @param scene the scene to create the ground mesh in
  19778. * @returns the created ground mesh
  19779. */
  19780. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19781. }
  19782. }
  19783. declare module "babylonjs/Physics/physicsJoint" {
  19784. import { Vector3 } from "babylonjs/Maths/math";
  19785. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19786. /**
  19787. * Interface for Physics-Joint data
  19788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19789. */
  19790. export interface PhysicsJointData {
  19791. /**
  19792. * The main pivot of the joint
  19793. */
  19794. mainPivot?: Vector3;
  19795. /**
  19796. * The connected pivot of the joint
  19797. */
  19798. connectedPivot?: Vector3;
  19799. /**
  19800. * The main axis of the joint
  19801. */
  19802. mainAxis?: Vector3;
  19803. /**
  19804. * The connected axis of the joint
  19805. */
  19806. connectedAxis?: Vector3;
  19807. /**
  19808. * The collision of the joint
  19809. */
  19810. collision?: boolean;
  19811. /**
  19812. * Native Oimo/Cannon/Energy data
  19813. */
  19814. nativeParams?: any;
  19815. }
  19816. /**
  19817. * This is a holder class for the physics joint created by the physics plugin
  19818. * It holds a set of functions to control the underlying joint
  19819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19820. */
  19821. export class PhysicsJoint {
  19822. /**
  19823. * The type of the physics joint
  19824. */
  19825. type: number;
  19826. /**
  19827. * The data for the physics joint
  19828. */
  19829. jointData: PhysicsJointData;
  19830. private _physicsJoint;
  19831. protected _physicsPlugin: IPhysicsEnginePlugin;
  19832. /**
  19833. * Initializes the physics joint
  19834. * @param type The type of the physics joint
  19835. * @param jointData The data for the physics joint
  19836. */
  19837. constructor(
  19838. /**
  19839. * The type of the physics joint
  19840. */
  19841. type: number,
  19842. /**
  19843. * The data for the physics joint
  19844. */
  19845. jointData: PhysicsJointData);
  19846. /**
  19847. * Gets the physics joint
  19848. */
  19849. /**
  19850. * Sets the physics joint
  19851. */
  19852. physicsJoint: any;
  19853. /**
  19854. * Sets the physics plugin
  19855. */
  19856. physicsPlugin: IPhysicsEnginePlugin;
  19857. /**
  19858. * Execute a function that is physics-plugin specific.
  19859. * @param {Function} func the function that will be executed.
  19860. * It accepts two parameters: the physics world and the physics joint
  19861. */
  19862. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19863. /**
  19864. * Distance-Joint type
  19865. */
  19866. static DistanceJoint: number;
  19867. /**
  19868. * Hinge-Joint type
  19869. */
  19870. static HingeJoint: number;
  19871. /**
  19872. * Ball-and-Socket joint type
  19873. */
  19874. static BallAndSocketJoint: number;
  19875. /**
  19876. * Wheel-Joint type
  19877. */
  19878. static WheelJoint: number;
  19879. /**
  19880. * Slider-Joint type
  19881. */
  19882. static SliderJoint: number;
  19883. /**
  19884. * Prismatic-Joint type
  19885. */
  19886. static PrismaticJoint: number;
  19887. /**
  19888. * Universal-Joint type
  19889. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19890. */
  19891. static UniversalJoint: number;
  19892. /**
  19893. * Hinge-Joint 2 type
  19894. */
  19895. static Hinge2Joint: number;
  19896. /**
  19897. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19898. */
  19899. static PointToPointJoint: number;
  19900. /**
  19901. * Spring-Joint type
  19902. */
  19903. static SpringJoint: number;
  19904. /**
  19905. * Lock-Joint type
  19906. */
  19907. static LockJoint: number;
  19908. }
  19909. /**
  19910. * A class representing a physics distance joint
  19911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19912. */
  19913. export class DistanceJoint extends PhysicsJoint {
  19914. /**
  19915. *
  19916. * @param jointData The data for the Distance-Joint
  19917. */
  19918. constructor(jointData: DistanceJointData);
  19919. /**
  19920. * Update the predefined distance.
  19921. * @param maxDistance The maximum preferred distance
  19922. * @param minDistance The minimum preferred distance
  19923. */
  19924. updateDistance(maxDistance: number, minDistance?: number): void;
  19925. }
  19926. /**
  19927. * Represents a Motor-Enabled Joint
  19928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19929. */
  19930. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19931. /**
  19932. * Initializes the Motor-Enabled Joint
  19933. * @param type The type of the joint
  19934. * @param jointData The physica joint data for the joint
  19935. */
  19936. constructor(type: number, jointData: PhysicsJointData);
  19937. /**
  19938. * Set the motor values.
  19939. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19940. * @param force the force to apply
  19941. * @param maxForce max force for this motor.
  19942. */
  19943. setMotor(force?: number, maxForce?: number): void;
  19944. /**
  19945. * Set the motor's limits.
  19946. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19947. * @param upperLimit The upper limit of the motor
  19948. * @param lowerLimit The lower limit of the motor
  19949. */
  19950. setLimit(upperLimit: number, lowerLimit?: number): void;
  19951. }
  19952. /**
  19953. * This class represents a single physics Hinge-Joint
  19954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19955. */
  19956. export class HingeJoint extends MotorEnabledJoint {
  19957. /**
  19958. * Initializes the Hinge-Joint
  19959. * @param jointData The joint data for the Hinge-Joint
  19960. */
  19961. constructor(jointData: PhysicsJointData);
  19962. /**
  19963. * Set the motor values.
  19964. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19965. * @param {number} force the force to apply
  19966. * @param {number} maxForce max force for this motor.
  19967. */
  19968. setMotor(force?: number, maxForce?: number): void;
  19969. /**
  19970. * Set the motor's limits.
  19971. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19972. * @param upperLimit The upper limit of the motor
  19973. * @param lowerLimit The lower limit of the motor
  19974. */
  19975. setLimit(upperLimit: number, lowerLimit?: number): void;
  19976. }
  19977. /**
  19978. * This class represents a dual hinge physics joint (same as wheel joint)
  19979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19980. */
  19981. export class Hinge2Joint extends MotorEnabledJoint {
  19982. /**
  19983. * Initializes the Hinge2-Joint
  19984. * @param jointData The joint data for the Hinge2-Joint
  19985. */
  19986. constructor(jointData: PhysicsJointData);
  19987. /**
  19988. * Set the motor values.
  19989. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19990. * @param {number} targetSpeed the speed the motor is to reach
  19991. * @param {number} maxForce max force for this motor.
  19992. * @param {motorIndex} the motor's index, 0 or 1.
  19993. */
  19994. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19995. /**
  19996. * Set the motor limits.
  19997. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19998. * @param {number} upperLimit the upper limit
  19999. * @param {number} lowerLimit lower limit
  20000. * @param {motorIndex} the motor's index, 0 or 1.
  20001. */
  20002. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20003. }
  20004. /**
  20005. * Interface for a motor enabled joint
  20006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20007. */
  20008. export interface IMotorEnabledJoint {
  20009. /**
  20010. * Physics joint
  20011. */
  20012. physicsJoint: any;
  20013. /**
  20014. * Sets the motor of the motor-enabled joint
  20015. * @param force The force of the motor
  20016. * @param maxForce The maximum force of the motor
  20017. * @param motorIndex The index of the motor
  20018. */
  20019. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20020. /**
  20021. * Sets the limit of the motor
  20022. * @param upperLimit The upper limit of the motor
  20023. * @param lowerLimit The lower limit of the motor
  20024. * @param motorIndex The index of the motor
  20025. */
  20026. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20027. }
  20028. /**
  20029. * Joint data for a Distance-Joint
  20030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20031. */
  20032. export interface DistanceJointData extends PhysicsJointData {
  20033. /**
  20034. * Max distance the 2 joint objects can be apart
  20035. */
  20036. maxDistance: number;
  20037. }
  20038. /**
  20039. * Joint data from a spring joint
  20040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20041. */
  20042. export interface SpringJointData extends PhysicsJointData {
  20043. /**
  20044. * Length of the spring
  20045. */
  20046. length: number;
  20047. /**
  20048. * Stiffness of the spring
  20049. */
  20050. stiffness: number;
  20051. /**
  20052. * Damping of the spring
  20053. */
  20054. damping: number;
  20055. /** this callback will be called when applying the force to the impostors. */
  20056. forceApplicationCallback: () => void;
  20057. }
  20058. }
  20059. declare module "babylonjs/Physics/physicsRaycastResult" {
  20060. import { Vector3 } from "babylonjs/Maths/math";
  20061. /**
  20062. * Holds the data for the raycast result
  20063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20064. */
  20065. export class PhysicsRaycastResult {
  20066. private _hasHit;
  20067. private _hitDistance;
  20068. private _hitNormalWorld;
  20069. private _hitPointWorld;
  20070. private _rayFromWorld;
  20071. private _rayToWorld;
  20072. /**
  20073. * Gets if there was a hit
  20074. */
  20075. readonly hasHit: boolean;
  20076. /**
  20077. * Gets the distance from the hit
  20078. */
  20079. readonly hitDistance: number;
  20080. /**
  20081. * Gets the hit normal/direction in the world
  20082. */
  20083. readonly hitNormalWorld: Vector3;
  20084. /**
  20085. * Gets the hit point in the world
  20086. */
  20087. readonly hitPointWorld: Vector3;
  20088. /**
  20089. * Gets the ray "start point" of the ray in the world
  20090. */
  20091. readonly rayFromWorld: Vector3;
  20092. /**
  20093. * Gets the ray "end point" of the ray in the world
  20094. */
  20095. readonly rayToWorld: Vector3;
  20096. /**
  20097. * Sets the hit data (normal & point in world space)
  20098. * @param hitNormalWorld defines the normal in world space
  20099. * @param hitPointWorld defines the point in world space
  20100. */
  20101. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20102. /**
  20103. * Sets the distance from the start point to the hit point
  20104. * @param distance
  20105. */
  20106. setHitDistance(distance: number): void;
  20107. /**
  20108. * Calculates the distance manually
  20109. */
  20110. calculateHitDistance(): void;
  20111. /**
  20112. * Resets all the values to default
  20113. * @param from The from point on world space
  20114. * @param to The to point on world space
  20115. */
  20116. reset(from?: Vector3, to?: Vector3): void;
  20117. }
  20118. /**
  20119. * Interface for the size containing width and height
  20120. */
  20121. interface IXYZ {
  20122. /**
  20123. * X
  20124. */
  20125. x: number;
  20126. /**
  20127. * Y
  20128. */
  20129. y: number;
  20130. /**
  20131. * Z
  20132. */
  20133. z: number;
  20134. }
  20135. }
  20136. declare module "babylonjs/Physics/IPhysicsEngine" {
  20137. import { Nullable } from "babylonjs/types";
  20138. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20140. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20141. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20142. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20143. /**
  20144. * Interface used to describe a physics joint
  20145. */
  20146. export interface PhysicsImpostorJoint {
  20147. /** Defines the main impostor to which the joint is linked */
  20148. mainImpostor: PhysicsImpostor;
  20149. /** Defines the impostor that is connected to the main impostor using this joint */
  20150. connectedImpostor: PhysicsImpostor;
  20151. /** Defines the joint itself */
  20152. joint: PhysicsJoint;
  20153. }
  20154. /** @hidden */
  20155. export interface IPhysicsEnginePlugin {
  20156. world: any;
  20157. name: string;
  20158. setGravity(gravity: Vector3): void;
  20159. setTimeStep(timeStep: number): void;
  20160. getTimeStep(): number;
  20161. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20162. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20163. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20164. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20165. removePhysicsBody(impostor: PhysicsImpostor): void;
  20166. generateJoint(joint: PhysicsImpostorJoint): void;
  20167. removeJoint(joint: PhysicsImpostorJoint): void;
  20168. isSupported(): boolean;
  20169. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20170. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20171. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20172. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20173. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20174. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20175. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20176. getBodyMass(impostor: PhysicsImpostor): number;
  20177. getBodyFriction(impostor: PhysicsImpostor): number;
  20178. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20179. getBodyRestitution(impostor: PhysicsImpostor): number;
  20180. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20181. getBodyPressure?(impostor: PhysicsImpostor): number;
  20182. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20183. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20184. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20185. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20186. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20187. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20188. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20189. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20190. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20191. sleepBody(impostor: PhysicsImpostor): void;
  20192. wakeUpBody(impostor: PhysicsImpostor): void;
  20193. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20194. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20195. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20196. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20197. getRadius(impostor: PhysicsImpostor): number;
  20198. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20199. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20200. dispose(): void;
  20201. }
  20202. /**
  20203. * Interface used to define a physics engine
  20204. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20205. */
  20206. export interface IPhysicsEngine {
  20207. /**
  20208. * Gets the gravity vector used by the simulation
  20209. */
  20210. gravity: Vector3;
  20211. /**
  20212. * Sets the gravity vector used by the simulation
  20213. * @param gravity defines the gravity vector to use
  20214. */
  20215. setGravity(gravity: Vector3): void;
  20216. /**
  20217. * Set the time step of the physics engine.
  20218. * Default is 1/60.
  20219. * To slow it down, enter 1/600 for example.
  20220. * To speed it up, 1/30
  20221. * @param newTimeStep the new timestep to apply to this world.
  20222. */
  20223. setTimeStep(newTimeStep: number): void;
  20224. /**
  20225. * Get the time step of the physics engine.
  20226. * @returns the current time step
  20227. */
  20228. getTimeStep(): number;
  20229. /**
  20230. * Release all resources
  20231. */
  20232. dispose(): void;
  20233. /**
  20234. * Gets the name of the current physics plugin
  20235. * @returns the name of the plugin
  20236. */
  20237. getPhysicsPluginName(): string;
  20238. /**
  20239. * Adding a new impostor for the impostor tracking.
  20240. * This will be done by the impostor itself.
  20241. * @param impostor the impostor to add
  20242. */
  20243. addImpostor(impostor: PhysicsImpostor): void;
  20244. /**
  20245. * Remove an impostor from the engine.
  20246. * This impostor and its mesh will not longer be updated by the physics engine.
  20247. * @param impostor the impostor to remove
  20248. */
  20249. removeImpostor(impostor: PhysicsImpostor): void;
  20250. /**
  20251. * Add a joint to the physics engine
  20252. * @param mainImpostor defines the main impostor to which the joint is added.
  20253. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20254. * @param joint defines the joint that will connect both impostors.
  20255. */
  20256. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20257. /**
  20258. * Removes a joint from the simulation
  20259. * @param mainImpostor defines the impostor used with the joint
  20260. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20261. * @param joint defines the joint to remove
  20262. */
  20263. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20264. /**
  20265. * Gets the current plugin used to run the simulation
  20266. * @returns current plugin
  20267. */
  20268. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20269. /**
  20270. * Gets the list of physic impostors
  20271. * @returns an array of PhysicsImpostor
  20272. */
  20273. getImpostors(): Array<PhysicsImpostor>;
  20274. /**
  20275. * Gets the impostor for a physics enabled object
  20276. * @param object defines the object impersonated by the impostor
  20277. * @returns the PhysicsImpostor or null if not found
  20278. */
  20279. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20280. /**
  20281. * Gets the impostor for a physics body object
  20282. * @param body defines physics body used by the impostor
  20283. * @returns the PhysicsImpostor or null if not found
  20284. */
  20285. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20286. /**
  20287. * Does a raycast in the physics world
  20288. * @param from when should the ray start?
  20289. * @param to when should the ray end?
  20290. * @returns PhysicsRaycastResult
  20291. */
  20292. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20293. /**
  20294. * Called by the scene. No need to call it.
  20295. * @param delta defines the timespam between frames
  20296. */
  20297. _step(delta: number): void;
  20298. }
  20299. }
  20300. declare module "babylonjs/Physics/physicsImpostor" {
  20301. import { Nullable, IndicesArray } from "babylonjs/types";
  20302. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20303. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20305. import { Scene } from "babylonjs/scene";
  20306. import { Bone } from "babylonjs/Bones/bone";
  20307. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20308. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20309. /**
  20310. * The interface for the physics imposter parameters
  20311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20312. */
  20313. export interface PhysicsImpostorParameters {
  20314. /**
  20315. * The mass of the physics imposter
  20316. */
  20317. mass: number;
  20318. /**
  20319. * The friction of the physics imposter
  20320. */
  20321. friction?: number;
  20322. /**
  20323. * The coefficient of restitution of the physics imposter
  20324. */
  20325. restitution?: number;
  20326. /**
  20327. * The native options of the physics imposter
  20328. */
  20329. nativeOptions?: any;
  20330. /**
  20331. * Specifies if the parent should be ignored
  20332. */
  20333. ignoreParent?: boolean;
  20334. /**
  20335. * Specifies if bi-directional transformations should be disabled
  20336. */
  20337. disableBidirectionalTransformation?: boolean;
  20338. /**
  20339. * The pressure inside the physics imposter, soft object only
  20340. */
  20341. pressure?: number;
  20342. /**
  20343. * The stiffness the physics imposter, soft object only
  20344. */
  20345. stiffness?: number;
  20346. /**
  20347. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20348. */
  20349. velocityIterations?: number;
  20350. /**
  20351. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20352. */
  20353. positionIterations?: number;
  20354. /**
  20355. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20356. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20357. * Add to fix multiple points
  20358. */
  20359. fixedPoints?: number;
  20360. /**
  20361. * The collision margin around a soft object
  20362. */
  20363. margin?: number;
  20364. /**
  20365. * The collision margin around a soft object
  20366. */
  20367. damping?: number;
  20368. /**
  20369. * The path for a rope based on an extrusion
  20370. */
  20371. path?: any;
  20372. /**
  20373. * The shape of an extrusion used for a rope based on an extrusion
  20374. */
  20375. shape?: any;
  20376. }
  20377. /**
  20378. * Interface for a physics-enabled object
  20379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20380. */
  20381. export interface IPhysicsEnabledObject {
  20382. /**
  20383. * The position of the physics-enabled object
  20384. */
  20385. position: Vector3;
  20386. /**
  20387. * The rotation of the physics-enabled object
  20388. */
  20389. rotationQuaternion: Nullable<Quaternion>;
  20390. /**
  20391. * The scale of the physics-enabled object
  20392. */
  20393. scaling: Vector3;
  20394. /**
  20395. * The rotation of the physics-enabled object
  20396. */
  20397. rotation?: Vector3;
  20398. /**
  20399. * The parent of the physics-enabled object
  20400. */
  20401. parent?: any;
  20402. /**
  20403. * The bounding info of the physics-enabled object
  20404. * @returns The bounding info of the physics-enabled object
  20405. */
  20406. getBoundingInfo(): BoundingInfo;
  20407. /**
  20408. * Computes the world matrix
  20409. * @param force Specifies if the world matrix should be computed by force
  20410. * @returns A world matrix
  20411. */
  20412. computeWorldMatrix(force: boolean): Matrix;
  20413. /**
  20414. * Gets the world matrix
  20415. * @returns A world matrix
  20416. */
  20417. getWorldMatrix?(): Matrix;
  20418. /**
  20419. * Gets the child meshes
  20420. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20421. * @returns An array of abstract meshes
  20422. */
  20423. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20424. /**
  20425. * Gets the vertex data
  20426. * @param kind The type of vertex data
  20427. * @returns A nullable array of numbers, or a float32 array
  20428. */
  20429. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20430. /**
  20431. * Gets the indices from the mesh
  20432. * @returns A nullable array of index arrays
  20433. */
  20434. getIndices?(): Nullable<IndicesArray>;
  20435. /**
  20436. * Gets the scene from the mesh
  20437. * @returns the indices array or null
  20438. */
  20439. getScene?(): Scene;
  20440. /**
  20441. * Gets the absolute position from the mesh
  20442. * @returns the absolute position
  20443. */
  20444. getAbsolutePosition(): Vector3;
  20445. /**
  20446. * Gets the absolute pivot point from the mesh
  20447. * @returns the absolute pivot point
  20448. */
  20449. getAbsolutePivotPoint(): Vector3;
  20450. /**
  20451. * Rotates the mesh
  20452. * @param axis The axis of rotation
  20453. * @param amount The amount of rotation
  20454. * @param space The space of the rotation
  20455. * @returns The rotation transform node
  20456. */
  20457. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20458. /**
  20459. * Translates the mesh
  20460. * @param axis The axis of translation
  20461. * @param distance The distance of translation
  20462. * @param space The space of the translation
  20463. * @returns The transform node
  20464. */
  20465. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20466. /**
  20467. * Sets the absolute position of the mesh
  20468. * @param absolutePosition The absolute position of the mesh
  20469. * @returns The transform node
  20470. */
  20471. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20472. /**
  20473. * Gets the class name of the mesh
  20474. * @returns The class name
  20475. */
  20476. getClassName(): string;
  20477. }
  20478. /**
  20479. * Represents a physics imposter
  20480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20481. */
  20482. export class PhysicsImpostor {
  20483. /**
  20484. * The physics-enabled object used as the physics imposter
  20485. */
  20486. object: IPhysicsEnabledObject;
  20487. /**
  20488. * The type of the physics imposter
  20489. */
  20490. type: number;
  20491. private _options;
  20492. private _scene?;
  20493. /**
  20494. * The default object size of the imposter
  20495. */
  20496. static DEFAULT_OBJECT_SIZE: Vector3;
  20497. /**
  20498. * The identity quaternion of the imposter
  20499. */
  20500. static IDENTITY_QUATERNION: Quaternion;
  20501. /** @hidden */
  20502. _pluginData: any;
  20503. private _physicsEngine;
  20504. private _physicsBody;
  20505. private _bodyUpdateRequired;
  20506. private _onBeforePhysicsStepCallbacks;
  20507. private _onAfterPhysicsStepCallbacks;
  20508. /** @hidden */
  20509. _onPhysicsCollideCallbacks: Array<{
  20510. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20511. otherImpostors: Array<PhysicsImpostor>;
  20512. }>;
  20513. private _deltaPosition;
  20514. private _deltaRotation;
  20515. private _deltaRotationConjugated;
  20516. /** hidden */
  20517. _isFromLine: boolean;
  20518. private _parent;
  20519. private _isDisposed;
  20520. private static _tmpVecs;
  20521. private static _tmpQuat;
  20522. /**
  20523. * Specifies if the physics imposter is disposed
  20524. */
  20525. readonly isDisposed: boolean;
  20526. /**
  20527. * Gets the mass of the physics imposter
  20528. */
  20529. mass: number;
  20530. /**
  20531. * Gets the coefficient of friction
  20532. */
  20533. /**
  20534. * Sets the coefficient of friction
  20535. */
  20536. friction: number;
  20537. /**
  20538. * Gets the coefficient of restitution
  20539. */
  20540. /**
  20541. * Sets the coefficient of restitution
  20542. */
  20543. restitution: number;
  20544. /**
  20545. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20546. */
  20547. /**
  20548. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20549. */
  20550. pressure: number;
  20551. /**
  20552. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20553. */
  20554. /**
  20555. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20556. */
  20557. stiffness: number;
  20558. /**
  20559. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20560. */
  20561. /**
  20562. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20563. */
  20564. velocityIterations: number;
  20565. /**
  20566. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20567. */
  20568. /**
  20569. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20570. */
  20571. positionIterations: number;
  20572. /**
  20573. * The unique id of the physics imposter
  20574. * set by the physics engine when adding this impostor to the array
  20575. */
  20576. uniqueId: number;
  20577. /**
  20578. * @hidden
  20579. */
  20580. soft: boolean;
  20581. /**
  20582. * @hidden
  20583. */
  20584. segments: number;
  20585. private _joints;
  20586. /**
  20587. * Initializes the physics imposter
  20588. * @param object The physics-enabled object used as the physics imposter
  20589. * @param type The type of the physics imposter
  20590. * @param _options The options for the physics imposter
  20591. * @param _scene The Babylon scene
  20592. */
  20593. constructor(
  20594. /**
  20595. * The physics-enabled object used as the physics imposter
  20596. */
  20597. object: IPhysicsEnabledObject,
  20598. /**
  20599. * The type of the physics imposter
  20600. */
  20601. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20602. /**
  20603. * This function will completly initialize this impostor.
  20604. * It will create a new body - but only if this mesh has no parent.
  20605. * If it has, this impostor will not be used other than to define the impostor
  20606. * of the child mesh.
  20607. * @hidden
  20608. */
  20609. _init(): void;
  20610. private _getPhysicsParent;
  20611. /**
  20612. * Should a new body be generated.
  20613. * @returns boolean specifying if body initialization is required
  20614. */
  20615. isBodyInitRequired(): boolean;
  20616. /**
  20617. * Sets the updated scaling
  20618. * @param updated Specifies if the scaling is updated
  20619. */
  20620. setScalingUpdated(): void;
  20621. /**
  20622. * Force a regeneration of this or the parent's impostor's body.
  20623. * Use under cautious - This will remove all joints already implemented.
  20624. */
  20625. forceUpdate(): void;
  20626. /**
  20627. * Gets the body that holds this impostor. Either its own, or its parent.
  20628. */
  20629. /**
  20630. * Set the physics body. Used mainly by the physics engine/plugin
  20631. */
  20632. physicsBody: any;
  20633. /**
  20634. * Get the parent of the physics imposter
  20635. * @returns Physics imposter or null
  20636. */
  20637. /**
  20638. * Sets the parent of the physics imposter
  20639. */
  20640. parent: Nullable<PhysicsImpostor>;
  20641. /**
  20642. * Resets the update flags
  20643. */
  20644. resetUpdateFlags(): void;
  20645. /**
  20646. * Gets the object extend size
  20647. * @returns the object extend size
  20648. */
  20649. getObjectExtendSize(): Vector3;
  20650. /**
  20651. * Gets the object center
  20652. * @returns The object center
  20653. */
  20654. getObjectCenter(): Vector3;
  20655. /**
  20656. * Get a specific parametes from the options parameter
  20657. * @param paramName The object parameter name
  20658. * @returns The object parameter
  20659. */
  20660. getParam(paramName: string): any;
  20661. /**
  20662. * Sets a specific parameter in the options given to the physics plugin
  20663. * @param paramName The parameter name
  20664. * @param value The value of the parameter
  20665. */
  20666. setParam(paramName: string, value: number): void;
  20667. /**
  20668. * Specifically change the body's mass option. Won't recreate the physics body object
  20669. * @param mass The mass of the physics imposter
  20670. */
  20671. setMass(mass: number): void;
  20672. /**
  20673. * Gets the linear velocity
  20674. * @returns linear velocity or null
  20675. */
  20676. getLinearVelocity(): Nullable<Vector3>;
  20677. /**
  20678. * Sets the linear velocity
  20679. * @param velocity linear velocity or null
  20680. */
  20681. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20682. /**
  20683. * Gets the angular velocity
  20684. * @returns angular velocity or null
  20685. */
  20686. getAngularVelocity(): Nullable<Vector3>;
  20687. /**
  20688. * Sets the angular velocity
  20689. * @param velocity The velocity or null
  20690. */
  20691. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20692. /**
  20693. * Execute a function with the physics plugin native code
  20694. * Provide a function the will have two variables - the world object and the physics body object
  20695. * @param func The function to execute with the physics plugin native code
  20696. */
  20697. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20698. /**
  20699. * Register a function that will be executed before the physics world is stepping forward
  20700. * @param func The function to execute before the physics world is stepped forward
  20701. */
  20702. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20703. /**
  20704. * Unregister a function that will be executed before the physics world is stepping forward
  20705. * @param func The function to execute before the physics world is stepped forward
  20706. */
  20707. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20708. /**
  20709. * Register a function that will be executed after the physics step
  20710. * @param func The function to execute after physics step
  20711. */
  20712. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20713. /**
  20714. * Unregisters a function that will be executed after the physics step
  20715. * @param func The function to execute after physics step
  20716. */
  20717. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20718. /**
  20719. * register a function that will be executed when this impostor collides against a different body
  20720. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20721. * @param func Callback that is executed on collision
  20722. */
  20723. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20724. /**
  20725. * Unregisters the physics imposter on contact
  20726. * @param collideAgainst The physics object to collide against
  20727. * @param func Callback to execute on collision
  20728. */
  20729. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20730. private _tmpQuat;
  20731. private _tmpQuat2;
  20732. /**
  20733. * Get the parent rotation
  20734. * @returns The parent rotation
  20735. */
  20736. getParentsRotation(): Quaternion;
  20737. /**
  20738. * this function is executed by the physics engine.
  20739. */
  20740. beforeStep: () => void;
  20741. /**
  20742. * this function is executed by the physics engine
  20743. */
  20744. afterStep: () => void;
  20745. /**
  20746. * Legacy collision detection event support
  20747. */
  20748. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20749. /**
  20750. * event and body object due to cannon's event-based architecture.
  20751. */
  20752. onCollide: (e: {
  20753. body: any;
  20754. }) => void;
  20755. /**
  20756. * Apply a force
  20757. * @param force The force to apply
  20758. * @param contactPoint The contact point for the force
  20759. * @returns The physics imposter
  20760. */
  20761. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20762. /**
  20763. * Apply an impulse
  20764. * @param force The impulse force
  20765. * @param contactPoint The contact point for the impulse force
  20766. * @returns The physics imposter
  20767. */
  20768. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20769. /**
  20770. * A help function to create a joint
  20771. * @param otherImpostor A physics imposter used to create a joint
  20772. * @param jointType The type of joint
  20773. * @param jointData The data for the joint
  20774. * @returns The physics imposter
  20775. */
  20776. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20777. /**
  20778. * Add a joint to this impostor with a different impostor
  20779. * @param otherImpostor A physics imposter used to add a joint
  20780. * @param joint The joint to add
  20781. * @returns The physics imposter
  20782. */
  20783. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20784. /**
  20785. * Add an anchor to a cloth impostor
  20786. * @param otherImpostor rigid impostor to anchor to
  20787. * @param width ratio across width from 0 to 1
  20788. * @param height ratio up height from 0 to 1
  20789. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20790. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20791. * @returns impostor the soft imposter
  20792. */
  20793. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20794. /**
  20795. * Add a hook to a rope impostor
  20796. * @param otherImpostor rigid impostor to anchor to
  20797. * @param length ratio across rope from 0 to 1
  20798. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20799. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20800. * @returns impostor the rope imposter
  20801. */
  20802. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20803. /**
  20804. * Will keep this body still, in a sleep mode.
  20805. * @returns the physics imposter
  20806. */
  20807. sleep(): PhysicsImpostor;
  20808. /**
  20809. * Wake the body up.
  20810. * @returns The physics imposter
  20811. */
  20812. wakeUp(): PhysicsImpostor;
  20813. /**
  20814. * Clones the physics imposter
  20815. * @param newObject The physics imposter clones to this physics-enabled object
  20816. * @returns A nullable physics imposter
  20817. */
  20818. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20819. /**
  20820. * Disposes the physics imposter
  20821. */
  20822. dispose(): void;
  20823. /**
  20824. * Sets the delta position
  20825. * @param position The delta position amount
  20826. */
  20827. setDeltaPosition(position: Vector3): void;
  20828. /**
  20829. * Sets the delta rotation
  20830. * @param rotation The delta rotation amount
  20831. */
  20832. setDeltaRotation(rotation: Quaternion): void;
  20833. /**
  20834. * Gets the box size of the physics imposter and stores the result in the input parameter
  20835. * @param result Stores the box size
  20836. * @returns The physics imposter
  20837. */
  20838. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20839. /**
  20840. * Gets the radius of the physics imposter
  20841. * @returns Radius of the physics imposter
  20842. */
  20843. getRadius(): number;
  20844. /**
  20845. * Sync a bone with this impostor
  20846. * @param bone The bone to sync to the impostor.
  20847. * @param boneMesh The mesh that the bone is influencing.
  20848. * @param jointPivot The pivot of the joint / bone in local space.
  20849. * @param distToJoint Optional distance from the impostor to the joint.
  20850. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20851. */
  20852. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20853. /**
  20854. * Sync impostor to a bone
  20855. * @param bone The bone that the impostor will be synced to.
  20856. * @param boneMesh The mesh that the bone is influencing.
  20857. * @param jointPivot The pivot of the joint / bone in local space.
  20858. * @param distToJoint Optional distance from the impostor to the joint.
  20859. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20860. * @param boneAxis Optional vector3 axis the bone is aligned with
  20861. */
  20862. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20863. /**
  20864. * No-Imposter type
  20865. */
  20866. static NoImpostor: number;
  20867. /**
  20868. * Sphere-Imposter type
  20869. */
  20870. static SphereImpostor: number;
  20871. /**
  20872. * Box-Imposter type
  20873. */
  20874. static BoxImpostor: number;
  20875. /**
  20876. * Plane-Imposter type
  20877. */
  20878. static PlaneImpostor: number;
  20879. /**
  20880. * Mesh-imposter type
  20881. */
  20882. static MeshImpostor: number;
  20883. /**
  20884. * Cylinder-Imposter type
  20885. */
  20886. static CylinderImpostor: number;
  20887. /**
  20888. * Particle-Imposter type
  20889. */
  20890. static ParticleImpostor: number;
  20891. /**
  20892. * Heightmap-Imposter type
  20893. */
  20894. static HeightmapImpostor: number;
  20895. /**
  20896. * ConvexHull-Impostor type (Ammo.js plugin only)
  20897. */
  20898. static ConvexHullImpostor: number;
  20899. /**
  20900. * Rope-Imposter type
  20901. */
  20902. static RopeImpostor: number;
  20903. /**
  20904. * Cloth-Imposter type
  20905. */
  20906. static ClothImpostor: number;
  20907. /**
  20908. * Softbody-Imposter type
  20909. */
  20910. static SoftbodyImpostor: number;
  20911. }
  20912. }
  20913. declare module "babylonjs/Meshes/mesh" {
  20914. import { Observable } from "babylonjs/Misc/observable";
  20915. import { IAnimatable } from "babylonjs/Misc/tools";
  20916. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20917. import { Camera } from "babylonjs/Cameras/camera";
  20918. import { Scene } from "babylonjs/scene";
  20919. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20920. import { Engine } from "babylonjs/Engines/engine";
  20921. import { Node } from "babylonjs/node";
  20922. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20923. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20924. import { Buffer } from "babylonjs/Meshes/buffer";
  20925. import { Geometry } from "babylonjs/Meshes/geometry";
  20926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20927. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20928. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20929. import { Effect } from "babylonjs/Materials/effect";
  20930. import { Material } from "babylonjs/Materials/material";
  20931. import { Skeleton } from "babylonjs/Bones/skeleton";
  20932. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20933. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20934. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20935. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20936. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20937. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20938. /**
  20939. * Class used to represent a specific level of detail of a mesh
  20940. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20941. */
  20942. export class MeshLODLevel {
  20943. /** Defines the distance where this level should star being displayed */
  20944. distance: number;
  20945. /** Defines the mesh to use to render this level */
  20946. mesh: Nullable<Mesh>;
  20947. /**
  20948. * Creates a new LOD level
  20949. * @param distance defines the distance where this level should star being displayed
  20950. * @param mesh defines the mesh to use to render this level
  20951. */
  20952. constructor(
  20953. /** Defines the distance where this level should star being displayed */
  20954. distance: number,
  20955. /** Defines the mesh to use to render this level */
  20956. mesh: Nullable<Mesh>);
  20957. }
  20958. /**
  20959. * @hidden
  20960. **/
  20961. export class _CreationDataStorage {
  20962. closePath?: boolean;
  20963. closeArray?: boolean;
  20964. idx: number[];
  20965. dashSize: number;
  20966. gapSize: number;
  20967. path3D: Path3D;
  20968. pathArray: Vector3[][];
  20969. arc: number;
  20970. radius: number;
  20971. cap: number;
  20972. tessellation: number;
  20973. }
  20974. /**
  20975. * @hidden
  20976. **/
  20977. class _InstanceDataStorage {
  20978. visibleInstances: any;
  20979. renderIdForInstances: number[];
  20980. batchCache: _InstancesBatch;
  20981. instancesBufferSize: number;
  20982. instancesBuffer: Nullable<Buffer>;
  20983. instancesData: Float32Array;
  20984. overridenInstanceCount: number;
  20985. }
  20986. /**
  20987. * @hidden
  20988. **/
  20989. export class _InstancesBatch {
  20990. mustReturn: boolean;
  20991. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20992. renderSelf: boolean[];
  20993. }
  20994. /**
  20995. * Class used to represent renderable models
  20996. */
  20997. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20998. /**
  20999. * Mesh side orientation : usually the external or front surface
  21000. */
  21001. static readonly FRONTSIDE: number;
  21002. /**
  21003. * Mesh side orientation : usually the internal or back surface
  21004. */
  21005. static readonly BACKSIDE: number;
  21006. /**
  21007. * Mesh side orientation : both internal and external or front and back surfaces
  21008. */
  21009. static readonly DOUBLESIDE: number;
  21010. /**
  21011. * Mesh side orientation : by default, `FRONTSIDE`
  21012. */
  21013. static readonly DEFAULTSIDE: number;
  21014. /**
  21015. * Mesh cap setting : no cap
  21016. */
  21017. static readonly NO_CAP: number;
  21018. /**
  21019. * Mesh cap setting : one cap at the beginning of the mesh
  21020. */
  21021. static readonly CAP_START: number;
  21022. /**
  21023. * Mesh cap setting : one cap at the end of the mesh
  21024. */
  21025. static readonly CAP_END: number;
  21026. /**
  21027. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21028. */
  21029. static readonly CAP_ALL: number;
  21030. /**
  21031. * Gets the default side orientation.
  21032. * @param orientation the orientation to value to attempt to get
  21033. * @returns the default orientation
  21034. * @hidden
  21035. */
  21036. static _GetDefaultSideOrientation(orientation?: number): number;
  21037. private _onBeforeRenderObservable;
  21038. private _onBeforeBindObservable;
  21039. private _onAfterRenderObservable;
  21040. private _onBeforeDrawObservable;
  21041. /**
  21042. * An event triggered before rendering the mesh
  21043. */
  21044. readonly onBeforeRenderObservable: Observable<Mesh>;
  21045. /**
  21046. * An event triggered before binding the mesh
  21047. */
  21048. readonly onBeforeBindObservable: Observable<Mesh>;
  21049. /**
  21050. * An event triggered after rendering the mesh
  21051. */
  21052. readonly onAfterRenderObservable: Observable<Mesh>;
  21053. /**
  21054. * An event triggered before drawing the mesh
  21055. */
  21056. readonly onBeforeDrawObservable: Observable<Mesh>;
  21057. private _onBeforeDrawObserver;
  21058. /**
  21059. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21060. */
  21061. onBeforeDraw: () => void;
  21062. /**
  21063. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21064. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21065. */
  21066. delayLoadState: number;
  21067. /**
  21068. * Gets the list of instances created from this mesh
  21069. * it is not supposed to be modified manually.
  21070. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21071. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21072. */
  21073. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21074. /**
  21075. * Gets the file containing delay loading data for this mesh
  21076. */
  21077. delayLoadingFile: string;
  21078. /** @hidden */
  21079. _binaryInfo: any;
  21080. private _LODLevels;
  21081. /**
  21082. * User defined function used to change how LOD level selection is done
  21083. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21084. */
  21085. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21086. private _morphTargetManager;
  21087. /**
  21088. * Gets or sets the morph target manager
  21089. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21090. */
  21091. morphTargetManager: Nullable<MorphTargetManager>;
  21092. /** @hidden */
  21093. _creationDataStorage: Nullable<_CreationDataStorage>;
  21094. /** @hidden */
  21095. _geometry: Nullable<Geometry>;
  21096. /** @hidden */
  21097. _delayInfo: Array<string>;
  21098. /** @hidden */
  21099. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21100. /** @hidden */
  21101. _instanceDataStorage: _InstanceDataStorage;
  21102. private _effectiveMaterial;
  21103. /** @hidden */
  21104. _shouldGenerateFlatShading: boolean;
  21105. private _preActivateId;
  21106. /** @hidden */
  21107. _originalBuilderSideOrientation: number;
  21108. /**
  21109. * Use this property to change the original side orientation defined at construction time
  21110. */
  21111. overrideMaterialSideOrientation: Nullable<number>;
  21112. private _areNormalsFrozen;
  21113. private _sourcePositions;
  21114. private _sourceNormals;
  21115. private _source;
  21116. private meshMap;
  21117. /**
  21118. * Gets the source mesh (the one used to clone this one from)
  21119. */
  21120. readonly source: Nullable<Mesh>;
  21121. /**
  21122. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21123. */
  21124. isUnIndexed: boolean;
  21125. /**
  21126. * @constructor
  21127. * @param name The value used by scene.getMeshByName() to do a lookup.
  21128. * @param scene The scene to add this mesh to.
  21129. * @param parent The parent of this mesh, if it has one
  21130. * @param source An optional Mesh from which geometry is shared, cloned.
  21131. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21132. * When false, achieved by calling a clone(), also passing False.
  21133. * This will make creation of children, recursive.
  21134. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21135. */
  21136. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21137. /**
  21138. * Gets the class name
  21139. * @returns the string "Mesh".
  21140. */
  21141. getClassName(): string;
  21142. /** @hidden */
  21143. readonly _isMesh: boolean;
  21144. /**
  21145. * Returns a description of this mesh
  21146. * @param fullDetails define if full details about this mesh must be used
  21147. * @returns a descriptive string representing this mesh
  21148. */
  21149. toString(fullDetails?: boolean): string;
  21150. /** @hidden */
  21151. _unBindEffect(): void;
  21152. /**
  21153. * Gets a boolean indicating if this mesh has LOD
  21154. */
  21155. readonly hasLODLevels: boolean;
  21156. /**
  21157. * Gets the list of MeshLODLevel associated with the current mesh
  21158. * @returns an array of MeshLODLevel
  21159. */
  21160. getLODLevels(): MeshLODLevel[];
  21161. private _sortLODLevels;
  21162. /**
  21163. * Add a mesh as LOD level triggered at the given distance.
  21164. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21165. * @param distance The distance from the center of the object to show this level
  21166. * @param mesh The mesh to be added as LOD level (can be null)
  21167. * @return This mesh (for chaining)
  21168. */
  21169. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21170. /**
  21171. * Returns the LOD level mesh at the passed distance or null if not found.
  21172. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21173. * @param distance The distance from the center of the object to show this level
  21174. * @returns a Mesh or `null`
  21175. */
  21176. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21177. /**
  21178. * Remove a mesh from the LOD array
  21179. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21180. * @param mesh defines the mesh to be removed
  21181. * @return This mesh (for chaining)
  21182. */
  21183. removeLODLevel(mesh: Mesh): Mesh;
  21184. /**
  21185. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21186. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21187. * @param camera defines the camera to use to compute distance
  21188. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21189. * @return This mesh (for chaining)
  21190. */
  21191. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21192. /**
  21193. * Gets the mesh internal Geometry object
  21194. */
  21195. readonly geometry: Nullable<Geometry>;
  21196. /**
  21197. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21198. * @returns the total number of vertices
  21199. */
  21200. getTotalVertices(): number;
  21201. /**
  21202. * Returns the content of an associated vertex buffer
  21203. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21204. * - VertexBuffer.PositionKind
  21205. * - VertexBuffer.UVKind
  21206. * - VertexBuffer.UV2Kind
  21207. * - VertexBuffer.UV3Kind
  21208. * - VertexBuffer.UV4Kind
  21209. * - VertexBuffer.UV5Kind
  21210. * - VertexBuffer.UV6Kind
  21211. * - VertexBuffer.ColorKind
  21212. * - VertexBuffer.MatricesIndicesKind
  21213. * - VertexBuffer.MatricesIndicesExtraKind
  21214. * - VertexBuffer.MatricesWeightsKind
  21215. * - VertexBuffer.MatricesWeightsExtraKind
  21216. * @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
  21217. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21218. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21219. */
  21220. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21221. /**
  21222. * Returns the mesh VertexBuffer object from the requested `kind`
  21223. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21224. * - VertexBuffer.PositionKind
  21225. * - VertexBuffer.UVKind
  21226. * - VertexBuffer.UV2Kind
  21227. * - VertexBuffer.UV3Kind
  21228. * - VertexBuffer.UV4Kind
  21229. * - VertexBuffer.UV5Kind
  21230. * - VertexBuffer.UV6Kind
  21231. * - VertexBuffer.ColorKind
  21232. * - VertexBuffer.MatricesIndicesKind
  21233. * - VertexBuffer.MatricesIndicesExtraKind
  21234. * - VertexBuffer.MatricesWeightsKind
  21235. * - VertexBuffer.MatricesWeightsExtraKind
  21236. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21237. */
  21238. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21239. /**
  21240. * Tests if a specific vertex buffer is associated with this mesh
  21241. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21242. * - VertexBuffer.PositionKind
  21243. * - VertexBuffer.UVKind
  21244. * - VertexBuffer.UV2Kind
  21245. * - VertexBuffer.UV3Kind
  21246. * - VertexBuffer.UV4Kind
  21247. * - VertexBuffer.UV5Kind
  21248. * - VertexBuffer.UV6Kind
  21249. * - VertexBuffer.ColorKind
  21250. * - VertexBuffer.MatricesIndicesKind
  21251. * - VertexBuffer.MatricesIndicesExtraKind
  21252. * - VertexBuffer.MatricesWeightsKind
  21253. * - VertexBuffer.MatricesWeightsExtraKind
  21254. * @returns a boolean
  21255. */
  21256. isVerticesDataPresent(kind: string): boolean;
  21257. /**
  21258. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21259. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21260. * - VertexBuffer.PositionKind
  21261. * - VertexBuffer.UVKind
  21262. * - VertexBuffer.UV2Kind
  21263. * - VertexBuffer.UV3Kind
  21264. * - VertexBuffer.UV4Kind
  21265. * - VertexBuffer.UV5Kind
  21266. * - VertexBuffer.UV6Kind
  21267. * - VertexBuffer.ColorKind
  21268. * - VertexBuffer.MatricesIndicesKind
  21269. * - VertexBuffer.MatricesIndicesExtraKind
  21270. * - VertexBuffer.MatricesWeightsKind
  21271. * - VertexBuffer.MatricesWeightsExtraKind
  21272. * @returns a boolean
  21273. */
  21274. isVertexBufferUpdatable(kind: string): boolean;
  21275. /**
  21276. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21277. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21278. * - VertexBuffer.PositionKind
  21279. * - VertexBuffer.UVKind
  21280. * - VertexBuffer.UV2Kind
  21281. * - VertexBuffer.UV3Kind
  21282. * - VertexBuffer.UV4Kind
  21283. * - VertexBuffer.UV5Kind
  21284. * - VertexBuffer.UV6Kind
  21285. * - VertexBuffer.ColorKind
  21286. * - VertexBuffer.MatricesIndicesKind
  21287. * - VertexBuffer.MatricesIndicesExtraKind
  21288. * - VertexBuffer.MatricesWeightsKind
  21289. * - VertexBuffer.MatricesWeightsExtraKind
  21290. * @returns an array of strings
  21291. */
  21292. getVerticesDataKinds(): string[];
  21293. /**
  21294. * Returns a positive integer : the total number of indices in this mesh geometry.
  21295. * @returns the numner of indices or zero if the mesh has no geometry.
  21296. */
  21297. getTotalIndices(): number;
  21298. /**
  21299. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21300. * @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.
  21301. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21302. * @returns the indices array or an empty array if the mesh has no geometry
  21303. */
  21304. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21305. readonly isBlocked: boolean;
  21306. /**
  21307. * Determine if the current mesh is ready to be rendered
  21308. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21309. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21310. * @returns true if all associated assets are ready (material, textures, shaders)
  21311. */
  21312. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21313. /**
  21314. * 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.
  21315. */
  21316. readonly areNormalsFrozen: boolean;
  21317. /**
  21318. * 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.
  21319. * @returns the current mesh
  21320. */
  21321. freezeNormals(): Mesh;
  21322. /**
  21323. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  21324. * @returns the current mesh
  21325. */
  21326. unfreezeNormals(): Mesh;
  21327. /**
  21328. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21329. */
  21330. overridenInstanceCount: number;
  21331. /** @hidden */
  21332. _preActivate(): Mesh;
  21333. /** @hidden */
  21334. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21335. /** @hidden */
  21336. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21337. /**
  21338. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21339. * This means the mesh underlying bounding box and sphere are recomputed.
  21340. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21341. * @returns the current mesh
  21342. */
  21343. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21344. /** @hidden */
  21345. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21346. /**
  21347. * This function will subdivide the mesh into multiple submeshes
  21348. * @param count defines the expected number of submeshes
  21349. */
  21350. subdivide(count: number): void;
  21351. /**
  21352. * Copy a FloatArray into a specific associated vertex buffer
  21353. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21354. * - VertexBuffer.PositionKind
  21355. * - VertexBuffer.UVKind
  21356. * - VertexBuffer.UV2Kind
  21357. * - VertexBuffer.UV3Kind
  21358. * - VertexBuffer.UV4Kind
  21359. * - VertexBuffer.UV5Kind
  21360. * - VertexBuffer.UV6Kind
  21361. * - VertexBuffer.ColorKind
  21362. * - VertexBuffer.MatricesIndicesKind
  21363. * - VertexBuffer.MatricesIndicesExtraKind
  21364. * - VertexBuffer.MatricesWeightsKind
  21365. * - VertexBuffer.MatricesWeightsExtraKind
  21366. * @param data defines the data source
  21367. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21368. * @param stride defines the data stride size (can be null)
  21369. * @returns the current mesh
  21370. */
  21371. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21372. /**
  21373. * Flags an associated vertex buffer as updatable
  21374. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21375. * - VertexBuffer.PositionKind
  21376. * - VertexBuffer.UVKind
  21377. * - VertexBuffer.UV2Kind
  21378. * - VertexBuffer.UV3Kind
  21379. * - VertexBuffer.UV4Kind
  21380. * - VertexBuffer.UV5Kind
  21381. * - VertexBuffer.UV6Kind
  21382. * - VertexBuffer.ColorKind
  21383. * - VertexBuffer.MatricesIndicesKind
  21384. * - VertexBuffer.MatricesIndicesExtraKind
  21385. * - VertexBuffer.MatricesWeightsKind
  21386. * - VertexBuffer.MatricesWeightsExtraKind
  21387. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21388. */
  21389. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21390. /**
  21391. * Sets the mesh global Vertex Buffer
  21392. * @param buffer defines the buffer to use
  21393. * @returns the current mesh
  21394. */
  21395. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21396. /**
  21397. * Update a specific associated vertex buffer
  21398. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21399. * - VertexBuffer.PositionKind
  21400. * - VertexBuffer.UVKind
  21401. * - VertexBuffer.UV2Kind
  21402. * - VertexBuffer.UV3Kind
  21403. * - VertexBuffer.UV4Kind
  21404. * - VertexBuffer.UV5Kind
  21405. * - VertexBuffer.UV6Kind
  21406. * - VertexBuffer.ColorKind
  21407. * - VertexBuffer.MatricesIndicesKind
  21408. * - VertexBuffer.MatricesIndicesExtraKind
  21409. * - VertexBuffer.MatricesWeightsKind
  21410. * - VertexBuffer.MatricesWeightsExtraKind
  21411. * @param data defines the data source
  21412. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21413. * @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)
  21414. * @returns the current mesh
  21415. */
  21416. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21417. /**
  21418. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21419. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21420. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21421. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21422. * @returns the current mesh
  21423. */
  21424. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21425. /**
  21426. * Creates a un-shared specific occurence of the geometry for the mesh.
  21427. * @returns the current mesh
  21428. */
  21429. makeGeometryUnique(): Mesh;
  21430. /**
  21431. * Set the index buffer of this mesh
  21432. * @param indices defines the source data
  21433. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21434. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21435. * @returns the current mesh
  21436. */
  21437. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21438. /**
  21439. * Update the current index buffer
  21440. * @param indices defines the source data
  21441. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21442. * @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)
  21443. * @returns the current mesh
  21444. */
  21445. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21446. /**
  21447. * Invert the geometry to move from a right handed system to a left handed one.
  21448. * @returns the current mesh
  21449. */
  21450. toLeftHanded(): Mesh;
  21451. /** @hidden */
  21452. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21453. /** @hidden */
  21454. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21455. /**
  21456. * Registers for this mesh a javascript function called just before the rendering process
  21457. * @param func defines the function to call before rendering this mesh
  21458. * @returns the current mesh
  21459. */
  21460. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21461. /**
  21462. * Disposes a previously registered javascript function called before the rendering
  21463. * @param func defines the function to remove
  21464. * @returns the current mesh
  21465. */
  21466. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21467. /**
  21468. * Registers for this mesh a javascript function called just after the rendering is complete
  21469. * @param func defines the function to call after rendering this mesh
  21470. * @returns the current mesh
  21471. */
  21472. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21473. /**
  21474. * Disposes a previously registered javascript function called after the rendering.
  21475. * @param func defines the function to remove
  21476. * @returns the current mesh
  21477. */
  21478. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21479. /** @hidden */
  21480. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21481. /** @hidden */
  21482. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21483. /** @hidden */
  21484. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21485. /**
  21486. * 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
  21487. * @param subMesh defines the subMesh to render
  21488. * @param enableAlphaMode defines if alpha mode can be changed
  21489. * @returns the current mesh
  21490. */
  21491. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21492. private _onBeforeDraw;
  21493. /**
  21494. * Renormalize the mesh and patch it up if there are no weights
  21495. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21496. * However in the case of zero weights then we set just a single influence to 1.
  21497. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21498. */
  21499. cleanMatrixWeights(): void;
  21500. private normalizeSkinFourWeights;
  21501. private normalizeSkinWeightsAndExtra;
  21502. /**
  21503. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21504. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21505. * the user know there was an issue with importing the mesh
  21506. * @returns a validation object with skinned, valid and report string
  21507. */
  21508. validateSkinning(): {
  21509. skinned: boolean;
  21510. valid: boolean;
  21511. report: string;
  21512. };
  21513. /** @hidden */
  21514. _checkDelayState(): Mesh;
  21515. private _queueLoad;
  21516. /**
  21517. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21518. * A mesh is in the frustum if its bounding box intersects the frustum
  21519. * @param frustumPlanes defines the frustum to test
  21520. * @returns true if the mesh is in the frustum planes
  21521. */
  21522. isInFrustum(frustumPlanes: Plane[]): boolean;
  21523. /**
  21524. * Sets the mesh material by the material or multiMaterial `id` property
  21525. * @param id is a string identifying the material or the multiMaterial
  21526. * @returns the current mesh
  21527. */
  21528. setMaterialByID(id: string): Mesh;
  21529. /**
  21530. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21531. * @returns an array of IAnimatable
  21532. */
  21533. getAnimatables(): IAnimatable[];
  21534. /**
  21535. * Modifies the mesh geometry according to the passed transformation matrix.
  21536. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21537. * The mesh normals are modified using the same transformation.
  21538. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21539. * @param transform defines the transform matrix to use
  21540. * @see http://doc.babylonjs.com/resources/baking_transformations
  21541. * @returns the current mesh
  21542. */
  21543. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21544. /**
  21545. * Modifies the mesh geometry according to its own current World Matrix.
  21546. * The mesh World Matrix is then reset.
  21547. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21548. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21549. * @see http://doc.babylonjs.com/resources/baking_transformations
  21550. * @returns the current mesh
  21551. */
  21552. bakeCurrentTransformIntoVertices(): Mesh;
  21553. /** @hidden */
  21554. readonly _positions: Nullable<Vector3[]>;
  21555. /** @hidden */
  21556. _resetPointsArrayCache(): Mesh;
  21557. /** @hidden */
  21558. _generatePointsArray(): boolean;
  21559. /**
  21560. * Returns a new Mesh object generated from the current mesh properties.
  21561. * This method must not get confused with createInstance()
  21562. * @param name is a string, the name given to the new mesh
  21563. * @param newParent can be any Node object (default `null`)
  21564. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21565. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21566. * @returns a new mesh
  21567. */
  21568. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21569. /**
  21570. * Releases resources associated with this mesh.
  21571. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21572. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21573. */
  21574. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21575. /**
  21576. * Modifies the mesh geometry according to a displacement map.
  21577. * 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.
  21578. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21579. * @param url is a string, the URL from the image file is to be downloaded.
  21580. * @param minHeight is the lower limit of the displacement.
  21581. * @param maxHeight is the upper limit of the displacement.
  21582. * @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.
  21583. * @param uvOffset is an optional vector2 used to offset UV.
  21584. * @param uvScale is an optional vector2 used to scale UV.
  21585. * @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.
  21586. * @returns the Mesh.
  21587. */
  21588. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21589. /**
  21590. * Modifies the mesh geometry according to a displacementMap buffer.
  21591. * 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.
  21592. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21593. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21594. * @param heightMapWidth is the width of the buffer image.
  21595. * @param heightMapHeight is the height of the buffer image.
  21596. * @param minHeight is the lower limit of the displacement.
  21597. * @param maxHeight is the upper limit of the displacement.
  21598. * @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.
  21599. * @param uvOffset is an optional vector2 used to offset UV.
  21600. * @param uvScale is an optional vector2 used to scale UV.
  21601. * @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.
  21602. * @returns the Mesh.
  21603. */
  21604. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21605. /**
  21606. * Modify the mesh to get a flat shading rendering.
  21607. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21608. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21609. * @returns current mesh
  21610. */
  21611. convertToFlatShadedMesh(): Mesh;
  21612. /**
  21613. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21614. * In other words, more vertices, no more indices and a single bigger VBO.
  21615. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21616. * @returns current mesh
  21617. */
  21618. convertToUnIndexedMesh(): Mesh;
  21619. /**
  21620. * Inverses facet orientations.
  21621. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21622. * @param flipNormals will also inverts the normals
  21623. * @returns current mesh
  21624. */
  21625. flipFaces(flipNormals?: boolean): Mesh;
  21626. /**
  21627. * Increase the number of facets and hence vertices in a mesh
  21628. * Vertex normals are interpolated from existing vertex normals
  21629. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21630. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21631. */
  21632. increaseVertices(numberPerEdge: number): void;
  21633. /**
  21634. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21635. * This will undo any application of covertToFlatShadedMesh
  21636. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21637. */
  21638. forceSharedVertices(): void;
  21639. /** @hidden */
  21640. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21641. /** @hidden */
  21642. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21643. /**
  21644. * Creates a new InstancedMesh object from the mesh model.
  21645. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21646. * @param name defines the name of the new instance
  21647. * @returns a new InstancedMesh
  21648. */
  21649. createInstance(name: string): InstancedMesh;
  21650. /**
  21651. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21652. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21653. * @returns the current mesh
  21654. */
  21655. synchronizeInstances(): Mesh;
  21656. /**
  21657. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21658. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21659. * This should be used together with the simplification to avoid disappearing triangles.
  21660. * @param successCallback an optional success callback to be called after the optimization finished.
  21661. * @returns the current mesh
  21662. */
  21663. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21664. /**
  21665. * Serialize current mesh
  21666. * @param serializationObject defines the object which will receive the serialization data
  21667. */
  21668. serialize(serializationObject: any): void;
  21669. /** @hidden */
  21670. _syncGeometryWithMorphTargetManager(): void;
  21671. /** @hidden */
  21672. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21673. /**
  21674. * Returns a new Mesh object parsed from the source provided.
  21675. * @param parsedMesh is the source
  21676. * @param scene defines the hosting scene
  21677. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21678. * @returns a new Mesh
  21679. */
  21680. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21681. /**
  21682. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21683. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21684. * @param name defines the name of the mesh to create
  21685. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21686. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21687. * @param closePath creates a seam between the first and the last points of each path of the path array
  21688. * @param offset is taken in account only if the `pathArray` is containing a single path
  21689. * @param scene defines the hosting scene
  21690. * @param updatable defines if the mesh must be flagged as updatable
  21691. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21692. * @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)
  21693. * @returns a new Mesh
  21694. */
  21695. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21696. /**
  21697. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21698. * @param name defines the name of the mesh to create
  21699. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21700. * @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
  21701. * @param scene defines the hosting scene
  21702. * @param updatable defines if the mesh must be flagged as updatable
  21703. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21704. * @returns a new Mesh
  21705. */
  21706. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21707. /**
  21708. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21709. * @param name defines the name of the mesh to create
  21710. * @param size sets the size (float) of each box side (default 1)
  21711. * @param scene defines the hosting scene
  21712. * @param updatable defines if the mesh must be flagged as updatable
  21713. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21714. * @returns a new Mesh
  21715. */
  21716. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21717. /**
  21718. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21719. * @param name defines the name of the mesh to create
  21720. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21721. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21722. * @param scene defines the hosting scene
  21723. * @param updatable defines if the mesh must be flagged as updatable
  21724. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21725. * @returns a new Mesh
  21726. */
  21727. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21728. /**
  21729. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21730. * @param name defines the name of the mesh to create
  21731. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21732. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21733. * @param scene defines the hosting scene
  21734. * @returns a new Mesh
  21735. */
  21736. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21737. /**
  21738. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21739. * @param name defines the name of the mesh to create
  21740. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21741. * @param diameterTop set the top cap diameter (floats, default 1)
  21742. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21743. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21744. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21745. * @param scene defines the hosting scene
  21746. * @param updatable defines if the mesh must be flagged as updatable
  21747. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21748. * @returns a new Mesh
  21749. */
  21750. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21751. /**
  21752. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21753. * @param name defines the name of the mesh to create
  21754. * @param diameter sets the diameter size (float) of the torus (default 1)
  21755. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21756. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21757. * @param scene defines the hosting scene
  21758. * @param updatable defines if the mesh must be flagged as updatable
  21759. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21760. * @returns a new Mesh
  21761. */
  21762. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21763. /**
  21764. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21765. * @param name defines the name of the mesh to create
  21766. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21767. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21768. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21769. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21770. * @param p the number of windings on X axis (positive integers, default 2)
  21771. * @param q the number of windings on Y axis (positive integers, default 3)
  21772. * @param scene defines the hosting scene
  21773. * @param updatable defines if the mesh must be flagged as updatable
  21774. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21775. * @returns a new Mesh
  21776. */
  21777. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21778. /**
  21779. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21780. * @param name defines the name of the mesh to create
  21781. * @param points is an array successive Vector3
  21782. * @param scene defines the hosting scene
  21783. * @param updatable defines if the mesh must be flagged as updatable
  21784. * @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).
  21785. * @returns a new Mesh
  21786. */
  21787. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21788. /**
  21789. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21790. * @param name defines the name of the mesh to create
  21791. * @param points is an array successive Vector3
  21792. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21793. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21794. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21795. * @param scene defines the hosting scene
  21796. * @param updatable defines if the mesh must be flagged as updatable
  21797. * @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)
  21798. * @returns a new Mesh
  21799. */
  21800. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21801. /**
  21802. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21803. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21804. * 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.
  21805. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21806. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21807. * Remember you can only change the shape positions, not their number when updating a polygon.
  21808. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21809. * @param name defines the name of the mesh to create
  21810. * @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
  21811. * @param scene defines the hosting scene
  21812. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21813. * @param updatable defines if the mesh must be flagged as updatable
  21814. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21815. * @param earcutInjection can be used to inject your own earcut reference
  21816. * @returns a new Mesh
  21817. */
  21818. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21819. /**
  21820. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21821. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21822. * @param name defines the name of the mesh to create
  21823. * @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
  21824. * @param depth defines the height of extrusion
  21825. * @param scene defines the hosting scene
  21826. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21827. * @param updatable defines if the mesh must be flagged as updatable
  21828. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21829. * @param earcutInjection can be used to inject your own earcut reference
  21830. * @returns a new Mesh
  21831. */
  21832. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21833. /**
  21834. * Creates an extruded shape mesh.
  21835. * 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
  21836. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21837. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21838. * @param name defines the name of the mesh to create
  21839. * @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
  21840. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21841. * @param scale is the value to scale the shape
  21842. * @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
  21843. * @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
  21844. * @param scene defines the hosting scene
  21845. * @param updatable defines if the mesh must be flagged as updatable
  21846. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21847. * @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)
  21848. * @returns a new Mesh
  21849. */
  21850. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21851. /**
  21852. * Creates an custom extruded shape mesh.
  21853. * The custom extrusion is a parametric shape.
  21854. * It has no predefined shape. Its final shape will depend on the input parameters.
  21855. * Please consider using the same method from the MeshBuilder class instead
  21856. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21857. * @param name defines the name of the mesh to create
  21858. * @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
  21859. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21860. * @param scaleFunction is a custom Javascript function called on each path point
  21861. * @param rotationFunction is a custom Javascript function called on each path point
  21862. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21863. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21864. * @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
  21865. * @param scene defines the hosting scene
  21866. * @param updatable defines if the mesh must be flagged as updatable
  21867. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21868. * @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)
  21869. * @returns a new Mesh
  21870. */
  21871. 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;
  21872. /**
  21873. * Creates lathe mesh.
  21874. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21875. * Please consider using the same method from the MeshBuilder class instead
  21876. * @param name defines the name of the mesh to create
  21877. * @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
  21878. * @param radius is the radius value of the lathe
  21879. * @param tessellation is the side number of the lathe.
  21880. * @param scene defines the hosting scene
  21881. * @param updatable defines if the mesh must be flagged as updatable
  21882. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21883. * @returns a new Mesh
  21884. */
  21885. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21886. /**
  21887. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21888. * @param name defines the name of the mesh to create
  21889. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21890. * @param scene defines the hosting scene
  21891. * @param updatable defines if the mesh must be flagged as updatable
  21892. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21893. * @returns a new Mesh
  21894. */
  21895. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21896. /**
  21897. * Creates a ground mesh.
  21898. * Please consider using the same method from the MeshBuilder class instead
  21899. * @param name defines the name of the mesh to create
  21900. * @param width set the width of the ground
  21901. * @param height set the height of the ground
  21902. * @param subdivisions sets the number of subdivisions per side
  21903. * @param scene defines the hosting scene
  21904. * @param updatable defines if the mesh must be flagged as updatable
  21905. * @returns a new Mesh
  21906. */
  21907. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21908. /**
  21909. * Creates a tiled ground mesh.
  21910. * Please consider using the same method from the MeshBuilder class instead
  21911. * @param name defines the name of the mesh to create
  21912. * @param xmin set the ground minimum X coordinate
  21913. * @param zmin set the ground minimum Y coordinate
  21914. * @param xmax set the ground maximum X coordinate
  21915. * @param zmax set the ground maximum Z coordinate
  21916. * @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
  21917. * @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
  21918. * @param scene defines the hosting scene
  21919. * @param updatable defines if the mesh must be flagged as updatable
  21920. * @returns a new Mesh
  21921. */
  21922. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21923. w: number;
  21924. h: number;
  21925. }, precision: {
  21926. w: number;
  21927. h: number;
  21928. }, scene: Scene, updatable?: boolean): Mesh;
  21929. /**
  21930. * Creates a ground mesh from a height map.
  21931. * Please consider using the same method from the MeshBuilder class instead
  21932. * @see http://doc.babylonjs.com/babylon101/height_map
  21933. * @param name defines the name of the mesh to create
  21934. * @param url sets the URL of the height map image resource
  21935. * @param width set the ground width size
  21936. * @param height set the ground height size
  21937. * @param subdivisions sets the number of subdivision per side
  21938. * @param minHeight is the minimum altitude on the ground
  21939. * @param maxHeight is the maximum altitude on the ground
  21940. * @param scene defines the hosting scene
  21941. * @param updatable defines if the mesh must be flagged as updatable
  21942. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21943. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21944. * @returns a new Mesh
  21945. */
  21946. 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;
  21947. /**
  21948. * Creates a tube mesh.
  21949. * The tube is a parametric shape.
  21950. * It has no predefined shape. Its final shape will depend on the input parameters.
  21951. * Please consider using the same method from the MeshBuilder class instead
  21952. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21953. * @param name defines the name of the mesh to create
  21954. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21955. * @param radius sets the tube radius size
  21956. * @param tessellation is the number of sides on the tubular surface
  21957. * @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
  21958. * @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
  21959. * @param scene defines the hosting scene
  21960. * @param updatable defines if the mesh must be flagged as updatable
  21961. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21962. * @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)
  21963. * @returns a new Mesh
  21964. */
  21965. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21966. (i: number, distance: number): number;
  21967. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21968. /**
  21969. * Creates a polyhedron mesh.
  21970. * Please consider using the same method from the MeshBuilder class instead.
  21971. * * 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
  21972. * * The parameter `size` (positive float, default 1) sets the polygon size
  21973. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21974. * * 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`
  21975. * * 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
  21976. * * 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)`)
  21977. * * 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
  21978. * * 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
  21979. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21980. * * If you create a double-sided mesh, you can choose what parts of 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
  21981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21982. * @param name defines the name of the mesh to create
  21983. * @param options defines the options used to create the mesh
  21984. * @param scene defines the hosting scene
  21985. * @returns a new Mesh
  21986. */
  21987. static CreatePolyhedron(name: string, options: {
  21988. type?: number;
  21989. size?: number;
  21990. sizeX?: number;
  21991. sizeY?: number;
  21992. sizeZ?: number;
  21993. custom?: any;
  21994. faceUV?: Vector4[];
  21995. faceColors?: Color4[];
  21996. updatable?: boolean;
  21997. sideOrientation?: number;
  21998. }, scene: Scene): Mesh;
  21999. /**
  22000. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22001. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22002. * * 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`)
  22003. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22004. * * 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
  22005. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22006. * * If you create a double-sided mesh, you can choose what parts of 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
  22007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22008. * @param name defines the name of the mesh
  22009. * @param options defines the options used to create the mesh
  22010. * @param scene defines the hosting scene
  22011. * @returns a new Mesh
  22012. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22013. */
  22014. static CreateIcoSphere(name: string, options: {
  22015. radius?: number;
  22016. flat?: boolean;
  22017. subdivisions?: number;
  22018. sideOrientation?: number;
  22019. updatable?: boolean;
  22020. }, scene: Scene): Mesh;
  22021. /**
  22022. * Creates a decal mesh.
  22023. * Please consider using the same method from the MeshBuilder class instead.
  22024. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22025. * @param name defines the name of the mesh
  22026. * @param sourceMesh defines the mesh receiving the decal
  22027. * @param position sets the position of the decal in world coordinates
  22028. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22029. * @param size sets the decal scaling
  22030. * @param angle sets the angle to rotate the decal
  22031. * @returns a new Mesh
  22032. */
  22033. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22034. /**
  22035. * Prepare internal position array for software CPU skinning
  22036. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22037. */
  22038. setPositionsForCPUSkinning(): Float32Array;
  22039. /**
  22040. * Prepare internal normal array for software CPU skinning
  22041. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22042. */
  22043. setNormalsForCPUSkinning(): Float32Array;
  22044. /**
  22045. * Updates the vertex buffer by applying transformation from the bones
  22046. * @param skeleton defines the skeleton to apply to current mesh
  22047. * @returns the current mesh
  22048. */
  22049. applySkeleton(skeleton: Skeleton): Mesh;
  22050. /**
  22051. * 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
  22052. * @param meshes defines the list of meshes to scan
  22053. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22054. */
  22055. static MinMax(meshes: AbstractMesh[]): {
  22056. min: Vector3;
  22057. max: Vector3;
  22058. };
  22059. /**
  22060. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22061. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22062. * @returns a vector3
  22063. */
  22064. static Center(meshesOrMinMaxVector: {
  22065. min: Vector3;
  22066. max: Vector3;
  22067. } | AbstractMesh[]): Vector3;
  22068. /**
  22069. * Merge the array of meshes into a single mesh for performance reasons.
  22070. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22071. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22072. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22073. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22074. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22075. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22076. * @returns a new mesh
  22077. */
  22078. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22079. /** @hidden */
  22080. addInstance(instance: InstancedMesh): void;
  22081. /** @hidden */
  22082. removeInstance(instance: InstancedMesh): void;
  22083. }
  22084. }
  22085. declare module "babylonjs/Materials/material" {
  22086. import { IAnimatable } from "babylonjs/Misc/tools";
  22087. import { SmartArray } from "babylonjs/Misc/smartArray";
  22088. import { Observable } from "babylonjs/Misc/observable";
  22089. import { Nullable } from "babylonjs/types";
  22090. import { Scene } from "babylonjs/scene";
  22091. import { Matrix } from "babylonjs/Maths/math";
  22092. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22094. import { Mesh } from "babylonjs/Meshes/mesh";
  22095. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22096. import { Effect } from "babylonjs/Materials/effect";
  22097. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22098. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22099. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22100. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22101. import { Animation } from "babylonjs/Animations/animation";
  22102. /**
  22103. * Base class for the main features of a material in Babylon.js
  22104. */
  22105. export class Material implements IAnimatable {
  22106. /**
  22107. * Returns the triangle fill mode
  22108. */
  22109. static readonly TriangleFillMode: number;
  22110. /**
  22111. * Returns the wireframe mode
  22112. */
  22113. static readonly WireFrameFillMode: number;
  22114. /**
  22115. * Returns the point fill mode
  22116. */
  22117. static readonly PointFillMode: number;
  22118. /**
  22119. * Returns the point list draw mode
  22120. */
  22121. static readonly PointListDrawMode: number;
  22122. /**
  22123. * Returns the line list draw mode
  22124. */
  22125. static readonly LineListDrawMode: number;
  22126. /**
  22127. * Returns the line loop draw mode
  22128. */
  22129. static readonly LineLoopDrawMode: number;
  22130. /**
  22131. * Returns the line strip draw mode
  22132. */
  22133. static readonly LineStripDrawMode: number;
  22134. /**
  22135. * Returns the triangle strip draw mode
  22136. */
  22137. static readonly TriangleStripDrawMode: number;
  22138. /**
  22139. * Returns the triangle fan draw mode
  22140. */
  22141. static readonly TriangleFanDrawMode: number;
  22142. /**
  22143. * Stores the clock-wise side orientation
  22144. */
  22145. static readonly ClockWiseSideOrientation: number;
  22146. /**
  22147. * Stores the counter clock-wise side orientation
  22148. */
  22149. static readonly CounterClockWiseSideOrientation: number;
  22150. /**
  22151. * The dirty texture flag value
  22152. */
  22153. static readonly TextureDirtyFlag: number;
  22154. /**
  22155. * The dirty light flag value
  22156. */
  22157. static readonly LightDirtyFlag: number;
  22158. /**
  22159. * The dirty fresnel flag value
  22160. */
  22161. static readonly FresnelDirtyFlag: number;
  22162. /**
  22163. * The dirty attribute flag value
  22164. */
  22165. static readonly AttributesDirtyFlag: number;
  22166. /**
  22167. * The dirty misc flag value
  22168. */
  22169. static readonly MiscDirtyFlag: number;
  22170. /**
  22171. * The all dirty flag value
  22172. */
  22173. static readonly AllDirtyFlag: number;
  22174. /**
  22175. * The ID of the material
  22176. */
  22177. id: string;
  22178. /**
  22179. * Gets or sets the unique id of the material
  22180. */
  22181. uniqueId: number;
  22182. /**
  22183. * The name of the material
  22184. */
  22185. name: string;
  22186. /**
  22187. * Gets or sets user defined metadata
  22188. */
  22189. metadata: any;
  22190. /**
  22191. * For internal use only. Please do not use.
  22192. */
  22193. reservedDataStore: any;
  22194. /**
  22195. * Specifies if the ready state should be checked on each call
  22196. */
  22197. checkReadyOnEveryCall: boolean;
  22198. /**
  22199. * Specifies if the ready state should be checked once
  22200. */
  22201. checkReadyOnlyOnce: boolean;
  22202. /**
  22203. * The state of the material
  22204. */
  22205. state: string;
  22206. /**
  22207. * The alpha value of the material
  22208. */
  22209. protected _alpha: number;
  22210. /**
  22211. * List of inspectable custom properties (used by the Inspector)
  22212. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22213. */
  22214. inspectableCustomProperties: IInspectable[];
  22215. /**
  22216. * Sets the alpha value of the material
  22217. */
  22218. /**
  22219. * Gets the alpha value of the material
  22220. */
  22221. alpha: number;
  22222. /**
  22223. * Specifies if back face culling is enabled
  22224. */
  22225. protected _backFaceCulling: boolean;
  22226. /**
  22227. * Sets the back-face culling state
  22228. */
  22229. /**
  22230. * Gets the back-face culling state
  22231. */
  22232. backFaceCulling: boolean;
  22233. /**
  22234. * Stores the value for side orientation
  22235. */
  22236. sideOrientation: number;
  22237. /**
  22238. * Callback triggered when the material is compiled
  22239. */
  22240. onCompiled: (effect: Effect) => void;
  22241. /**
  22242. * Callback triggered when an error occurs
  22243. */
  22244. onError: (effect: Effect, errors: string) => void;
  22245. /**
  22246. * Callback triggered to get the render target textures
  22247. */
  22248. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22249. /**
  22250. * Gets a boolean indicating that current material needs to register RTT
  22251. */
  22252. readonly hasRenderTargetTextures: boolean;
  22253. /**
  22254. * Specifies if the material should be serialized
  22255. */
  22256. doNotSerialize: boolean;
  22257. /**
  22258. * @hidden
  22259. */
  22260. _storeEffectOnSubMeshes: boolean;
  22261. /**
  22262. * Stores the animations for the material
  22263. */
  22264. animations: Array<Animation>;
  22265. /**
  22266. * An event triggered when the material is disposed
  22267. */
  22268. onDisposeObservable: Observable<Material>;
  22269. /**
  22270. * An observer which watches for dispose events
  22271. */
  22272. private _onDisposeObserver;
  22273. private _onUnBindObservable;
  22274. /**
  22275. * Called during a dispose event
  22276. */
  22277. onDispose: () => void;
  22278. private _onBindObservable;
  22279. /**
  22280. * An event triggered when the material is bound
  22281. */
  22282. readonly onBindObservable: Observable<AbstractMesh>;
  22283. /**
  22284. * An observer which watches for bind events
  22285. */
  22286. private _onBindObserver;
  22287. /**
  22288. * Called during a bind event
  22289. */
  22290. onBind: (Mesh: AbstractMesh) => void;
  22291. /**
  22292. * An event triggered when the material is unbound
  22293. */
  22294. readonly onUnBindObservable: Observable<Material>;
  22295. /**
  22296. * Stores the value of the alpha mode
  22297. */
  22298. private _alphaMode;
  22299. /**
  22300. * Sets the value of the alpha mode.
  22301. *
  22302. * | Value | Type | Description |
  22303. * | --- | --- | --- |
  22304. * | 0 | ALPHA_DISABLE | |
  22305. * | 1 | ALPHA_ADD | |
  22306. * | 2 | ALPHA_COMBINE | |
  22307. * | 3 | ALPHA_SUBTRACT | |
  22308. * | 4 | ALPHA_MULTIPLY | |
  22309. * | 5 | ALPHA_MAXIMIZED | |
  22310. * | 6 | ALPHA_ONEONE | |
  22311. * | 7 | ALPHA_PREMULTIPLIED | |
  22312. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22313. * | 9 | ALPHA_INTERPOLATE | |
  22314. * | 10 | ALPHA_SCREENMODE | |
  22315. *
  22316. */
  22317. /**
  22318. * Gets the value of the alpha mode
  22319. */
  22320. alphaMode: number;
  22321. /**
  22322. * Stores the state of the need depth pre-pass value
  22323. */
  22324. private _needDepthPrePass;
  22325. /**
  22326. * Sets the need depth pre-pass value
  22327. */
  22328. /**
  22329. * Gets the depth pre-pass value
  22330. */
  22331. needDepthPrePass: boolean;
  22332. /**
  22333. * Specifies if depth writing should be disabled
  22334. */
  22335. disableDepthWrite: boolean;
  22336. /**
  22337. * Specifies if depth writing should be forced
  22338. */
  22339. forceDepthWrite: boolean;
  22340. /**
  22341. * Specifies if there should be a separate pass for culling
  22342. */
  22343. separateCullingPass: boolean;
  22344. /**
  22345. * Stores the state specifing if fog should be enabled
  22346. */
  22347. private _fogEnabled;
  22348. /**
  22349. * Sets the state for enabling fog
  22350. */
  22351. /**
  22352. * Gets the value of the fog enabled state
  22353. */
  22354. fogEnabled: boolean;
  22355. /**
  22356. * Stores the size of points
  22357. */
  22358. pointSize: number;
  22359. /**
  22360. * Stores the z offset value
  22361. */
  22362. zOffset: number;
  22363. /**
  22364. * Gets a value specifying if wireframe mode is enabled
  22365. */
  22366. /**
  22367. * Sets the state of wireframe mode
  22368. */
  22369. wireframe: boolean;
  22370. /**
  22371. * Gets the value specifying if point clouds are enabled
  22372. */
  22373. /**
  22374. * Sets the state of point cloud mode
  22375. */
  22376. pointsCloud: boolean;
  22377. /**
  22378. * Gets the material fill mode
  22379. */
  22380. /**
  22381. * Sets the material fill mode
  22382. */
  22383. fillMode: number;
  22384. /**
  22385. * @hidden
  22386. * Stores the effects for the material
  22387. */
  22388. _effect: Nullable<Effect>;
  22389. /**
  22390. * @hidden
  22391. * Specifies if the material was previously ready
  22392. */
  22393. _wasPreviouslyReady: boolean;
  22394. /**
  22395. * Specifies if uniform buffers should be used
  22396. */
  22397. private _useUBO;
  22398. /**
  22399. * Stores a reference to the scene
  22400. */
  22401. private _scene;
  22402. /**
  22403. * Stores the fill mode state
  22404. */
  22405. private _fillMode;
  22406. /**
  22407. * Specifies if the depth write state should be cached
  22408. */
  22409. private _cachedDepthWriteState;
  22410. /**
  22411. * Stores the uniform buffer
  22412. */
  22413. protected _uniformBuffer: UniformBuffer;
  22414. /** @hidden */
  22415. _indexInSceneMaterialArray: number;
  22416. /** @hidden */
  22417. meshMap: Nullable<{
  22418. [id: string]: AbstractMesh | undefined;
  22419. }>;
  22420. /**
  22421. * Creates a material instance
  22422. * @param name defines the name of the material
  22423. * @param scene defines the scene to reference
  22424. * @param doNotAdd specifies if the material should be added to the scene
  22425. */
  22426. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22427. /**
  22428. * Returns a string representation of the current material
  22429. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22430. * @returns a string with material information
  22431. */
  22432. toString(fullDetails?: boolean): string;
  22433. /**
  22434. * Gets the class name of the material
  22435. * @returns a string with the class name of the material
  22436. */
  22437. getClassName(): string;
  22438. /**
  22439. * Specifies if updates for the material been locked
  22440. */
  22441. readonly isFrozen: boolean;
  22442. /**
  22443. * Locks updates for the material
  22444. */
  22445. freeze(): void;
  22446. /**
  22447. * Unlocks updates for the material
  22448. */
  22449. unfreeze(): void;
  22450. /**
  22451. * Specifies if the material is ready to be used
  22452. * @param mesh defines the mesh to check
  22453. * @param useInstances specifies if instances should be used
  22454. * @returns a boolean indicating if the material is ready to be used
  22455. */
  22456. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22457. /**
  22458. * Specifies that the submesh is ready to be used
  22459. * @param mesh defines the mesh to check
  22460. * @param subMesh defines which submesh to check
  22461. * @param useInstances specifies that instances should be used
  22462. * @returns a boolean indicating that the submesh is ready or not
  22463. */
  22464. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22465. /**
  22466. * Returns the material effect
  22467. * @returns the effect associated with the material
  22468. */
  22469. getEffect(): Nullable<Effect>;
  22470. /**
  22471. * Returns the current scene
  22472. * @returns a Scene
  22473. */
  22474. getScene(): Scene;
  22475. /**
  22476. * Specifies if the material will require alpha blending
  22477. * @returns a boolean specifying if alpha blending is needed
  22478. */
  22479. needAlphaBlending(): boolean;
  22480. /**
  22481. * Specifies if the mesh will require alpha blending
  22482. * @param mesh defines the mesh to check
  22483. * @returns a boolean specifying if alpha blending is needed for the mesh
  22484. */
  22485. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22486. /**
  22487. * Specifies if this material should be rendered in alpha test mode
  22488. * @returns a boolean specifying if an alpha test is needed.
  22489. */
  22490. needAlphaTesting(): boolean;
  22491. /**
  22492. * Gets the texture used for the alpha test
  22493. * @returns the texture to use for alpha testing
  22494. */
  22495. getAlphaTestTexture(): Nullable<BaseTexture>;
  22496. /**
  22497. * Marks the material to indicate that it needs to be re-calculated
  22498. */
  22499. markDirty(): void;
  22500. /** @hidden */
  22501. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22502. /**
  22503. * Binds the material to the mesh
  22504. * @param world defines the world transformation matrix
  22505. * @param mesh defines the mesh to bind the material to
  22506. */
  22507. bind(world: Matrix, mesh?: Mesh): void;
  22508. /**
  22509. * Binds the submesh to the material
  22510. * @param world defines the world transformation matrix
  22511. * @param mesh defines the mesh containing the submesh
  22512. * @param subMesh defines the submesh to bind the material to
  22513. */
  22514. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22515. /**
  22516. * Binds the world matrix to the material
  22517. * @param world defines the world transformation matrix
  22518. */
  22519. bindOnlyWorldMatrix(world: Matrix): void;
  22520. /**
  22521. * Binds the scene's uniform buffer to the effect.
  22522. * @param effect defines the effect to bind to the scene uniform buffer
  22523. * @param sceneUbo defines the uniform buffer storing scene data
  22524. */
  22525. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22526. /**
  22527. * Binds the view matrix to the effect
  22528. * @param effect defines the effect to bind the view matrix to
  22529. */
  22530. bindView(effect: Effect): void;
  22531. /**
  22532. * Binds the view projection matrix to the effect
  22533. * @param effect defines the effect to bind the view projection matrix to
  22534. */
  22535. bindViewProjection(effect: Effect): void;
  22536. /**
  22537. * Specifies if material alpha testing should be turned on for the mesh
  22538. * @param mesh defines the mesh to check
  22539. */
  22540. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22541. /**
  22542. * Processes to execute after binding the material to a mesh
  22543. * @param mesh defines the rendered mesh
  22544. */
  22545. protected _afterBind(mesh?: Mesh): void;
  22546. /**
  22547. * Unbinds the material from the mesh
  22548. */
  22549. unbind(): void;
  22550. /**
  22551. * Gets the active textures from the material
  22552. * @returns an array of textures
  22553. */
  22554. getActiveTextures(): BaseTexture[];
  22555. /**
  22556. * Specifies if the material uses a texture
  22557. * @param texture defines the texture to check against the material
  22558. * @returns a boolean specifying if the material uses the texture
  22559. */
  22560. hasTexture(texture: BaseTexture): boolean;
  22561. /**
  22562. * Makes a duplicate of the material, and gives it a new name
  22563. * @param name defines the new name for the duplicated material
  22564. * @returns the cloned material
  22565. */
  22566. clone(name: string): Nullable<Material>;
  22567. /**
  22568. * Gets the meshes bound to the material
  22569. * @returns an array of meshes bound to the material
  22570. */
  22571. getBindedMeshes(): AbstractMesh[];
  22572. /**
  22573. * Force shader compilation
  22574. * @param mesh defines the mesh associated with this material
  22575. * @param onCompiled defines a function to execute once the material is compiled
  22576. * @param options defines the options to configure the compilation
  22577. */
  22578. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22579. clipPlane: boolean;
  22580. }>): void;
  22581. /**
  22582. * Force shader compilation
  22583. * @param mesh defines the mesh that will use this material
  22584. * @param options defines additional options for compiling the shaders
  22585. * @returns a promise that resolves when the compilation completes
  22586. */
  22587. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22588. clipPlane: boolean;
  22589. }>): Promise<void>;
  22590. private static readonly _ImageProcessingDirtyCallBack;
  22591. private static readonly _TextureDirtyCallBack;
  22592. private static readonly _FresnelDirtyCallBack;
  22593. private static readonly _MiscDirtyCallBack;
  22594. private static readonly _LightsDirtyCallBack;
  22595. private static readonly _AttributeDirtyCallBack;
  22596. private static _FresnelAndMiscDirtyCallBack;
  22597. private static _TextureAndMiscDirtyCallBack;
  22598. private static readonly _DirtyCallbackArray;
  22599. private static readonly _RunDirtyCallBacks;
  22600. /**
  22601. * Marks a define in the material to indicate that it needs to be re-computed
  22602. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22603. */
  22604. markAsDirty(flag: number): void;
  22605. /**
  22606. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22607. * @param func defines a function which checks material defines against the submeshes
  22608. */
  22609. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22610. /**
  22611. * Indicates that image processing needs to be re-calculated for all submeshes
  22612. */
  22613. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22614. /**
  22615. * Indicates that textures need to be re-calculated for all submeshes
  22616. */
  22617. protected _markAllSubMeshesAsTexturesDirty(): void;
  22618. /**
  22619. * Indicates that fresnel needs to be re-calculated for all submeshes
  22620. */
  22621. protected _markAllSubMeshesAsFresnelDirty(): void;
  22622. /**
  22623. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22624. */
  22625. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22626. /**
  22627. * Indicates that lights need to be re-calculated for all submeshes
  22628. */
  22629. protected _markAllSubMeshesAsLightsDirty(): void;
  22630. /**
  22631. * Indicates that attributes need to be re-calculated for all submeshes
  22632. */
  22633. protected _markAllSubMeshesAsAttributesDirty(): void;
  22634. /**
  22635. * Indicates that misc needs to be re-calculated for all submeshes
  22636. */
  22637. protected _markAllSubMeshesAsMiscDirty(): void;
  22638. /**
  22639. * Indicates that textures and misc need to be re-calculated for all submeshes
  22640. */
  22641. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22642. /**
  22643. * Disposes the material
  22644. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22645. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22646. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22647. */
  22648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22649. /** @hidden */
  22650. private releaseVertexArrayObject;
  22651. /**
  22652. * Serializes this material
  22653. * @returns the serialized material object
  22654. */
  22655. serialize(): any;
  22656. /**
  22657. * Creates a material from parsed material data
  22658. * @param parsedMaterial defines parsed material data
  22659. * @param scene defines the hosting scene
  22660. * @param rootUrl defines the root URL to use to load textures
  22661. * @returns a new material
  22662. */
  22663. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22664. }
  22665. }
  22666. declare module "babylonjs/Meshes/subMesh" {
  22667. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22668. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22669. import { Engine } from "babylonjs/Engines/engine";
  22670. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22671. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22672. import { Effect } from "babylonjs/Materials/effect";
  22673. import { Collider } from "babylonjs/Collisions/collider";
  22674. import { Material } from "babylonjs/Materials/material";
  22675. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22677. import { Mesh } from "babylonjs/Meshes/mesh";
  22678. import { Ray } from "babylonjs/Culling/ray";
  22679. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22680. /**
  22681. * Base class for submeshes
  22682. */
  22683. export class BaseSubMesh {
  22684. /** @hidden */
  22685. _materialDefines: Nullable<MaterialDefines>;
  22686. /** @hidden */
  22687. _materialEffect: Nullable<Effect>;
  22688. /**
  22689. * Gets associated effect
  22690. */
  22691. readonly effect: Nullable<Effect>;
  22692. /**
  22693. * Sets associated effect (effect used to render this submesh)
  22694. * @param effect defines the effect to associate with
  22695. * @param defines defines the set of defines used to compile this effect
  22696. */
  22697. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22698. }
  22699. /**
  22700. * Defines a subdivision inside a mesh
  22701. */
  22702. export class SubMesh extends BaseSubMesh implements ICullable {
  22703. /** the material index to use */
  22704. materialIndex: number;
  22705. /** vertex index start */
  22706. verticesStart: number;
  22707. /** vertices count */
  22708. verticesCount: number;
  22709. /** index start */
  22710. indexStart: number;
  22711. /** indices count */
  22712. indexCount: number;
  22713. /** @hidden */
  22714. _linesIndexCount: number;
  22715. private _mesh;
  22716. private _renderingMesh;
  22717. private _boundingInfo;
  22718. private _linesIndexBuffer;
  22719. /** @hidden */
  22720. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22721. /** @hidden */
  22722. _trianglePlanes: Plane[];
  22723. /** @hidden */
  22724. _lastColliderTransformMatrix: Matrix;
  22725. /** @hidden */
  22726. _renderId: number;
  22727. /** @hidden */
  22728. _alphaIndex: number;
  22729. /** @hidden */
  22730. _distanceToCamera: number;
  22731. /** @hidden */
  22732. _id: number;
  22733. private _currentMaterial;
  22734. /**
  22735. * Add a new submesh to a mesh
  22736. * @param materialIndex defines the material index to use
  22737. * @param verticesStart defines vertex index start
  22738. * @param verticesCount defines vertices count
  22739. * @param indexStart defines index start
  22740. * @param indexCount defines indices count
  22741. * @param mesh defines the parent mesh
  22742. * @param renderingMesh defines an optional rendering mesh
  22743. * @param createBoundingBox defines if bounding box should be created for this submesh
  22744. * @returns the new submesh
  22745. */
  22746. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22747. /**
  22748. * Creates a new submesh
  22749. * @param materialIndex defines the material index to use
  22750. * @param verticesStart defines vertex index start
  22751. * @param verticesCount defines vertices count
  22752. * @param indexStart defines index start
  22753. * @param indexCount defines indices count
  22754. * @param mesh defines the parent mesh
  22755. * @param renderingMesh defines an optional rendering mesh
  22756. * @param createBoundingBox defines if bounding box should be created for this submesh
  22757. */
  22758. constructor(
  22759. /** the material index to use */
  22760. materialIndex: number,
  22761. /** vertex index start */
  22762. verticesStart: number,
  22763. /** vertices count */
  22764. verticesCount: number,
  22765. /** index start */
  22766. indexStart: number,
  22767. /** indices count */
  22768. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22769. /**
  22770. * Returns true if this submesh covers the entire parent mesh
  22771. * @ignorenaming
  22772. */
  22773. readonly IsGlobal: boolean;
  22774. /**
  22775. * Returns the submesh BoudingInfo object
  22776. * @returns current bounding info (or mesh's one if the submesh is global)
  22777. */
  22778. getBoundingInfo(): BoundingInfo;
  22779. /**
  22780. * Sets the submesh BoundingInfo
  22781. * @param boundingInfo defines the new bounding info to use
  22782. * @returns the SubMesh
  22783. */
  22784. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22785. /**
  22786. * Returns the mesh of the current submesh
  22787. * @return the parent mesh
  22788. */
  22789. getMesh(): AbstractMesh;
  22790. /**
  22791. * Returns the rendering mesh of the submesh
  22792. * @returns the rendering mesh (could be different from parent mesh)
  22793. */
  22794. getRenderingMesh(): Mesh;
  22795. /**
  22796. * Returns the submesh material
  22797. * @returns null or the current material
  22798. */
  22799. getMaterial(): Nullable<Material>;
  22800. /**
  22801. * Sets a new updated BoundingInfo object to the submesh
  22802. * @returns the SubMesh
  22803. */
  22804. refreshBoundingInfo(): SubMesh;
  22805. /** @hidden */
  22806. _checkCollision(collider: Collider): boolean;
  22807. /**
  22808. * Updates the submesh BoundingInfo
  22809. * @param world defines the world matrix to use to update the bounding info
  22810. * @returns the submesh
  22811. */
  22812. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22813. /**
  22814. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22815. * @param frustumPlanes defines the frustum planes
  22816. * @returns true if the submesh is intersecting with the frustum
  22817. */
  22818. isInFrustum(frustumPlanes: Plane[]): boolean;
  22819. /**
  22820. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22821. * @param frustumPlanes defines the frustum planes
  22822. * @returns true if the submesh is inside the frustum
  22823. */
  22824. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22825. /**
  22826. * Renders the submesh
  22827. * @param enableAlphaMode defines if alpha needs to be used
  22828. * @returns the submesh
  22829. */
  22830. render(enableAlphaMode: boolean): SubMesh;
  22831. /**
  22832. * @hidden
  22833. */
  22834. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22835. /**
  22836. * Checks if the submesh intersects with a ray
  22837. * @param ray defines the ray to test
  22838. * @returns true is the passed ray intersects the submesh bounding box
  22839. */
  22840. canIntersects(ray: Ray): boolean;
  22841. /**
  22842. * Intersects current submesh with a ray
  22843. * @param ray defines the ray to test
  22844. * @param positions defines mesh's positions array
  22845. * @param indices defines mesh's indices array
  22846. * @param fastCheck defines if only bounding info should be used
  22847. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22848. * @returns intersection info or null if no intersection
  22849. */
  22850. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22851. /** @hidden */
  22852. private _intersectLines;
  22853. /** @hidden */
  22854. private _intersectTriangles;
  22855. /** @hidden */
  22856. _rebuild(): void;
  22857. /**
  22858. * Creates a new submesh from the passed mesh
  22859. * @param newMesh defines the new hosting mesh
  22860. * @param newRenderingMesh defines an optional rendering mesh
  22861. * @returns the new submesh
  22862. */
  22863. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22864. /**
  22865. * Release associated resources
  22866. */
  22867. dispose(): void;
  22868. /**
  22869. * Gets the class name
  22870. * @returns the string "SubMesh".
  22871. */
  22872. getClassName(): string;
  22873. /**
  22874. * Creates a new submesh from indices data
  22875. * @param materialIndex the index of the main mesh material
  22876. * @param startIndex the index where to start the copy in the mesh indices array
  22877. * @param indexCount the number of indices to copy then from the startIndex
  22878. * @param mesh the main mesh to create the submesh from
  22879. * @param renderingMesh the optional rendering mesh
  22880. * @returns a new submesh
  22881. */
  22882. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22883. }
  22884. }
  22885. declare module "babylonjs/Meshes/geometry" {
  22886. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22887. import { Scene } from "babylonjs/scene";
  22888. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22889. import { Engine } from "babylonjs/Engines/engine";
  22890. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22891. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22892. import { Effect } from "babylonjs/Materials/effect";
  22893. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22894. import { Mesh } from "babylonjs/Meshes/mesh";
  22895. /**
  22896. * Class used to store geometry data (vertex buffers + index buffer)
  22897. */
  22898. export class Geometry implements IGetSetVerticesData {
  22899. /**
  22900. * Gets or sets the ID of the geometry
  22901. */
  22902. id: string;
  22903. /**
  22904. * Gets or sets the unique ID of the geometry
  22905. */
  22906. uniqueId: number;
  22907. /**
  22908. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22909. */
  22910. delayLoadState: number;
  22911. /**
  22912. * Gets the file containing the data to load when running in delay load state
  22913. */
  22914. delayLoadingFile: Nullable<string>;
  22915. /**
  22916. * Callback called when the geometry is updated
  22917. */
  22918. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22919. private _scene;
  22920. private _engine;
  22921. private _meshes;
  22922. private _totalVertices;
  22923. /** @hidden */
  22924. _indices: IndicesArray;
  22925. /** @hidden */
  22926. _vertexBuffers: {
  22927. [key: string]: VertexBuffer;
  22928. };
  22929. private _isDisposed;
  22930. private _extend;
  22931. private _boundingBias;
  22932. /** @hidden */
  22933. _delayInfo: Array<string>;
  22934. private _indexBuffer;
  22935. private _indexBufferIsUpdatable;
  22936. /** @hidden */
  22937. _boundingInfo: Nullable<BoundingInfo>;
  22938. /** @hidden */
  22939. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22940. /** @hidden */
  22941. _softwareSkinningFrameId: number;
  22942. private _vertexArrayObjects;
  22943. private _updatable;
  22944. /** @hidden */
  22945. _positions: Nullable<Vector3[]>;
  22946. /**
  22947. * 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
  22948. */
  22949. /**
  22950. * 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
  22951. */
  22952. boundingBias: Vector2;
  22953. /**
  22954. * Static function used to attach a new empty geometry to a mesh
  22955. * @param mesh defines the mesh to attach the geometry to
  22956. * @returns the new Geometry
  22957. */
  22958. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22959. /**
  22960. * Creates a new geometry
  22961. * @param id defines the unique ID
  22962. * @param scene defines the hosting scene
  22963. * @param vertexData defines the VertexData used to get geometry data
  22964. * @param updatable defines if geometry must be updatable (false by default)
  22965. * @param mesh defines the mesh that will be associated with the geometry
  22966. */
  22967. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22968. /**
  22969. * Gets the current extend of the geometry
  22970. */
  22971. readonly extend: {
  22972. minimum: Vector3;
  22973. maximum: Vector3;
  22974. };
  22975. /**
  22976. * Gets the hosting scene
  22977. * @returns the hosting Scene
  22978. */
  22979. getScene(): Scene;
  22980. /**
  22981. * Gets the hosting engine
  22982. * @returns the hosting Engine
  22983. */
  22984. getEngine(): Engine;
  22985. /**
  22986. * Defines if the geometry is ready to use
  22987. * @returns true if the geometry is ready to be used
  22988. */
  22989. isReady(): boolean;
  22990. /**
  22991. * Gets a value indicating that the geometry should not be serialized
  22992. */
  22993. readonly doNotSerialize: boolean;
  22994. /** @hidden */
  22995. _rebuild(): void;
  22996. /**
  22997. * Affects all geometry data in one call
  22998. * @param vertexData defines the geometry data
  22999. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23000. */
  23001. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23002. /**
  23003. * Set specific vertex data
  23004. * @param kind defines the data kind (Position, normal, etc...)
  23005. * @param data defines the vertex data to use
  23006. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23007. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23008. */
  23009. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23010. /**
  23011. * Removes a specific vertex data
  23012. * @param kind defines the data kind (Position, normal, etc...)
  23013. */
  23014. removeVerticesData(kind: string): void;
  23015. /**
  23016. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23017. * @param buffer defines the vertex buffer to use
  23018. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23019. */
  23020. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23021. /**
  23022. * Update a specific vertex buffer
  23023. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23024. * It will do nothing if the buffer is not updatable
  23025. * @param kind defines the data kind (Position, normal, etc...)
  23026. * @param data defines the data to use
  23027. * @param offset defines the offset in the target buffer where to store the data
  23028. * @param useBytes set to true if the offset is in bytes
  23029. */
  23030. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23031. /**
  23032. * Update a specific vertex buffer
  23033. * This function will create a new buffer if the current one is not updatable
  23034. * @param kind defines the data kind (Position, normal, etc...)
  23035. * @param data defines the data to use
  23036. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23037. */
  23038. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23039. private _updateBoundingInfo;
  23040. /** @hidden */
  23041. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23042. /**
  23043. * Gets total number of vertices
  23044. * @returns the total number of vertices
  23045. */
  23046. getTotalVertices(): number;
  23047. /**
  23048. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23049. * @param kind defines the data kind (Position, normal, etc...)
  23050. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23051. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23052. * @returns a float array containing vertex data
  23053. */
  23054. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23055. /**
  23056. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23057. * @param kind defines the data kind (Position, normal, etc...)
  23058. * @returns true if the vertex buffer with the specified kind is updatable
  23059. */
  23060. isVertexBufferUpdatable(kind: string): boolean;
  23061. /**
  23062. * Gets a specific vertex buffer
  23063. * @param kind defines the data kind (Position, normal, etc...)
  23064. * @returns a VertexBuffer
  23065. */
  23066. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23067. /**
  23068. * Returns all vertex buffers
  23069. * @return an object holding all vertex buffers indexed by kind
  23070. */
  23071. getVertexBuffers(): Nullable<{
  23072. [key: string]: VertexBuffer;
  23073. }>;
  23074. /**
  23075. * Gets a boolean indicating if specific vertex buffer is present
  23076. * @param kind defines the data kind (Position, normal, etc...)
  23077. * @returns true if data is present
  23078. */
  23079. isVerticesDataPresent(kind: string): boolean;
  23080. /**
  23081. * Gets a list of all attached data kinds (Position, normal, etc...)
  23082. * @returns a list of string containing all kinds
  23083. */
  23084. getVerticesDataKinds(): string[];
  23085. /**
  23086. * Update index buffer
  23087. * @param indices defines the indices to store in the index buffer
  23088. * @param offset defines the offset in the target buffer where to store the data
  23089. * @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)
  23090. */
  23091. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23092. /**
  23093. * Creates a new index buffer
  23094. * @param indices defines the indices to store in the index buffer
  23095. * @param totalVertices defines the total number of vertices (could be null)
  23096. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23097. */
  23098. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23099. /**
  23100. * Return the total number of indices
  23101. * @returns the total number of indices
  23102. */
  23103. getTotalIndices(): number;
  23104. /**
  23105. * Gets the index buffer array
  23106. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23107. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23108. * @returns the index buffer array
  23109. */
  23110. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23111. /**
  23112. * Gets the index buffer
  23113. * @return the index buffer
  23114. */
  23115. getIndexBuffer(): Nullable<WebGLBuffer>;
  23116. /** @hidden */
  23117. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23118. /**
  23119. * Release the associated resources for a specific mesh
  23120. * @param mesh defines the source mesh
  23121. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23122. */
  23123. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23124. /**
  23125. * Apply current geometry to a given mesh
  23126. * @param mesh defines the mesh to apply geometry to
  23127. */
  23128. applyToMesh(mesh: Mesh): void;
  23129. private _updateExtend;
  23130. private _applyToMesh;
  23131. private notifyUpdate;
  23132. /**
  23133. * Load the geometry if it was flagged as delay loaded
  23134. * @param scene defines the hosting scene
  23135. * @param onLoaded defines a callback called when the geometry is loaded
  23136. */
  23137. load(scene: Scene, onLoaded?: () => void): void;
  23138. private _queueLoad;
  23139. /**
  23140. * Invert the geometry to move from a right handed system to a left handed one.
  23141. */
  23142. toLeftHanded(): void;
  23143. /** @hidden */
  23144. _resetPointsArrayCache(): void;
  23145. /** @hidden */
  23146. _generatePointsArray(): boolean;
  23147. /**
  23148. * Gets a value indicating if the geometry is disposed
  23149. * @returns true if the geometry was disposed
  23150. */
  23151. isDisposed(): boolean;
  23152. private _disposeVertexArrayObjects;
  23153. /**
  23154. * Free all associated resources
  23155. */
  23156. dispose(): void;
  23157. /**
  23158. * Clone the current geometry into a new geometry
  23159. * @param id defines the unique ID of the new geometry
  23160. * @returns a new geometry object
  23161. */
  23162. copy(id: string): Geometry;
  23163. /**
  23164. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23165. * @return a JSON representation of the current geometry data (without the vertices data)
  23166. */
  23167. serialize(): any;
  23168. private toNumberArray;
  23169. /**
  23170. * Serialize all vertices data into a JSON oject
  23171. * @returns a JSON representation of the current geometry data
  23172. */
  23173. serializeVerticeData(): any;
  23174. /**
  23175. * Extracts a clone of a mesh geometry
  23176. * @param mesh defines the source mesh
  23177. * @param id defines the unique ID of the new geometry object
  23178. * @returns the new geometry object
  23179. */
  23180. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23181. /**
  23182. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23183. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23184. * Be aware Math.random() could cause collisions, but:
  23185. * "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"
  23186. * @returns a string containing a new GUID
  23187. */
  23188. static RandomId(): string;
  23189. /** @hidden */
  23190. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23191. private static _CleanMatricesWeights;
  23192. /**
  23193. * Create a new geometry from persisted data (Using .babylon file format)
  23194. * @param parsedVertexData defines the persisted data
  23195. * @param scene defines the hosting scene
  23196. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23197. * @returns the new geometry object
  23198. */
  23199. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23200. }
  23201. }
  23202. declare module "babylonjs/Meshes/mesh.vertexData" {
  23203. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23204. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23205. import { Geometry } from "babylonjs/Meshes/geometry";
  23206. import { Mesh } from "babylonjs/Meshes/mesh";
  23207. /**
  23208. * Define an interface for all classes that will get and set the data on vertices
  23209. */
  23210. export interface IGetSetVerticesData {
  23211. /**
  23212. * Gets a boolean indicating if specific vertex data is present
  23213. * @param kind defines the vertex data kind to use
  23214. * @returns true is data kind is present
  23215. */
  23216. isVerticesDataPresent(kind: string): boolean;
  23217. /**
  23218. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23219. * @param kind defines the data kind (Position, normal, etc...)
  23220. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23221. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23222. * @returns a float array containing vertex data
  23223. */
  23224. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23225. /**
  23226. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23227. * @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.
  23228. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23229. * @returns the indices array or an empty array if the mesh has no geometry
  23230. */
  23231. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23232. /**
  23233. * Set specific vertex data
  23234. * @param kind defines the data kind (Position, normal, etc...)
  23235. * @param data defines the vertex data to use
  23236. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23237. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23238. */
  23239. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23240. /**
  23241. * Update a specific associated vertex buffer
  23242. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23243. * - VertexBuffer.PositionKind
  23244. * - VertexBuffer.UVKind
  23245. * - VertexBuffer.UV2Kind
  23246. * - VertexBuffer.UV3Kind
  23247. * - VertexBuffer.UV4Kind
  23248. * - VertexBuffer.UV5Kind
  23249. * - VertexBuffer.UV6Kind
  23250. * - VertexBuffer.ColorKind
  23251. * - VertexBuffer.MatricesIndicesKind
  23252. * - VertexBuffer.MatricesIndicesExtraKind
  23253. * - VertexBuffer.MatricesWeightsKind
  23254. * - VertexBuffer.MatricesWeightsExtraKind
  23255. * @param data defines the data source
  23256. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23257. * @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)
  23258. */
  23259. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23260. /**
  23261. * Creates a new index buffer
  23262. * @param indices defines the indices to store in the index buffer
  23263. * @param totalVertices defines the total number of vertices (could be null)
  23264. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23265. */
  23266. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23267. }
  23268. /**
  23269. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23270. */
  23271. export class VertexData {
  23272. /**
  23273. * Mesh side orientation : usually the external or front surface
  23274. */
  23275. static readonly FRONTSIDE: number;
  23276. /**
  23277. * Mesh side orientation : usually the internal or back surface
  23278. */
  23279. static readonly BACKSIDE: number;
  23280. /**
  23281. * Mesh side orientation : both internal and external or front and back surfaces
  23282. */
  23283. static readonly DOUBLESIDE: number;
  23284. /**
  23285. * Mesh side orientation : by default, `FRONTSIDE`
  23286. */
  23287. static readonly DEFAULTSIDE: number;
  23288. /**
  23289. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23290. */
  23291. positions: Nullable<FloatArray>;
  23292. /**
  23293. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23294. */
  23295. normals: Nullable<FloatArray>;
  23296. /**
  23297. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23298. */
  23299. tangents: Nullable<FloatArray>;
  23300. /**
  23301. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23302. */
  23303. uvs: Nullable<FloatArray>;
  23304. /**
  23305. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23306. */
  23307. uvs2: Nullable<FloatArray>;
  23308. /**
  23309. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23310. */
  23311. uvs3: Nullable<FloatArray>;
  23312. /**
  23313. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23314. */
  23315. uvs4: Nullable<FloatArray>;
  23316. /**
  23317. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23318. */
  23319. uvs5: Nullable<FloatArray>;
  23320. /**
  23321. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23322. */
  23323. uvs6: Nullable<FloatArray>;
  23324. /**
  23325. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23326. */
  23327. colors: Nullable<FloatArray>;
  23328. /**
  23329. * 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).
  23330. */
  23331. matricesIndices: Nullable<FloatArray>;
  23332. /**
  23333. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23334. */
  23335. matricesWeights: Nullable<FloatArray>;
  23336. /**
  23337. * An array extending the number of possible indices
  23338. */
  23339. matricesIndicesExtra: Nullable<FloatArray>;
  23340. /**
  23341. * An array extending the number of possible weights when the number of indices is extended
  23342. */
  23343. matricesWeightsExtra: Nullable<FloatArray>;
  23344. /**
  23345. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23346. */
  23347. indices: Nullable<IndicesArray>;
  23348. /**
  23349. * Uses the passed data array to set the set the values for the specified kind of data
  23350. * @param data a linear array of floating numbers
  23351. * @param kind the type of data that is being set, eg positions, colors etc
  23352. */
  23353. set(data: FloatArray, kind: string): void;
  23354. /**
  23355. * Associates the vertexData to the passed Mesh.
  23356. * Sets it as updatable or not (default `false`)
  23357. * @param mesh the mesh the vertexData is applied to
  23358. * @param updatable when used and having the value true allows new data to update the vertexData
  23359. * @returns the VertexData
  23360. */
  23361. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23362. /**
  23363. * Associates the vertexData to the passed Geometry.
  23364. * Sets it as updatable or not (default `false`)
  23365. * @param geometry the geometry the vertexData is applied to
  23366. * @param updatable when used and having the value true allows new data to update the vertexData
  23367. * @returns VertexData
  23368. */
  23369. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23370. /**
  23371. * Updates the associated mesh
  23372. * @param mesh the mesh to be updated
  23373. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23374. * @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
  23375. * @returns VertexData
  23376. */
  23377. updateMesh(mesh: Mesh): VertexData;
  23378. /**
  23379. * Updates the associated geometry
  23380. * @param geometry the geometry to be updated
  23381. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23382. * @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
  23383. * @returns VertexData.
  23384. */
  23385. updateGeometry(geometry: Geometry): VertexData;
  23386. private _applyTo;
  23387. private _update;
  23388. /**
  23389. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23390. * @param matrix the transforming matrix
  23391. * @returns the VertexData
  23392. */
  23393. transform(matrix: Matrix): VertexData;
  23394. /**
  23395. * Merges the passed VertexData into the current one
  23396. * @param other the VertexData to be merged into the current one
  23397. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23398. * @returns the modified VertexData
  23399. */
  23400. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23401. private _mergeElement;
  23402. private _validate;
  23403. /**
  23404. * Serializes the VertexData
  23405. * @returns a serialized object
  23406. */
  23407. serialize(): any;
  23408. /**
  23409. * Extracts the vertexData from a mesh
  23410. * @param mesh the mesh from which to extract the VertexData
  23411. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23412. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23413. * @returns the object VertexData associated to the passed mesh
  23414. */
  23415. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23416. /**
  23417. * Extracts the vertexData from the geometry
  23418. * @param geometry the geometry from which to extract the VertexData
  23419. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23420. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23421. * @returns the object VertexData associated to the passed mesh
  23422. */
  23423. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23424. private static _ExtractFrom;
  23425. /**
  23426. * Creates the VertexData for a Ribbon
  23427. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23428. * * pathArray array of paths, each of which an array of successive Vector3
  23429. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23430. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23431. * * 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
  23432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23433. * * 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)
  23434. * * 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)
  23435. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23436. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23437. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23438. * @returns the VertexData of the ribbon
  23439. */
  23440. static CreateRibbon(options: {
  23441. pathArray: Vector3[][];
  23442. closeArray?: boolean;
  23443. closePath?: boolean;
  23444. offset?: number;
  23445. sideOrientation?: number;
  23446. frontUVs?: Vector4;
  23447. backUVs?: Vector4;
  23448. invertUV?: boolean;
  23449. uvs?: Vector2[];
  23450. colors?: Color4[];
  23451. }): VertexData;
  23452. /**
  23453. * Creates the VertexData for a box
  23454. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23455. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23456. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23457. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23458. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23459. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23460. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23461. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23462. * * 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)
  23463. * * 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)
  23464. * @returns the VertexData of the box
  23465. */
  23466. static CreateBox(options: {
  23467. size?: number;
  23468. width?: number;
  23469. height?: number;
  23470. depth?: number;
  23471. faceUV?: Vector4[];
  23472. faceColors?: Color4[];
  23473. sideOrientation?: number;
  23474. frontUVs?: Vector4;
  23475. backUVs?: Vector4;
  23476. }): VertexData;
  23477. /**
  23478. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23479. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23480. * * segments sets the number of horizontal strips optional, default 32
  23481. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23482. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23483. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23484. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23485. * * 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
  23486. * * 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
  23487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23488. * * 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)
  23489. * * 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)
  23490. * @returns the VertexData of the ellipsoid
  23491. */
  23492. static CreateSphere(options: {
  23493. segments?: number;
  23494. diameter?: number;
  23495. diameterX?: number;
  23496. diameterY?: number;
  23497. diameterZ?: number;
  23498. arc?: number;
  23499. slice?: number;
  23500. sideOrientation?: number;
  23501. frontUVs?: Vector4;
  23502. backUVs?: Vector4;
  23503. }): VertexData;
  23504. /**
  23505. * Creates the VertexData for a cylinder, cone or prism
  23506. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23507. * * height sets the height (y direction) of the cylinder, optional, default 2
  23508. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23509. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23510. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23511. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23512. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23513. * * 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
  23514. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23515. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23516. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23517. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23519. * * 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)
  23520. * * 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)
  23521. * @returns the VertexData of the cylinder, cone or prism
  23522. */
  23523. static CreateCylinder(options: {
  23524. height?: number;
  23525. diameterTop?: number;
  23526. diameterBottom?: number;
  23527. diameter?: number;
  23528. tessellation?: number;
  23529. subdivisions?: number;
  23530. arc?: number;
  23531. faceColors?: Color4[];
  23532. faceUV?: Vector4[];
  23533. hasRings?: boolean;
  23534. enclose?: boolean;
  23535. sideOrientation?: number;
  23536. frontUVs?: Vector4;
  23537. backUVs?: Vector4;
  23538. }): VertexData;
  23539. /**
  23540. * Creates the VertexData for a torus
  23541. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23542. * * diameter the diameter of the torus, optional default 1
  23543. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23544. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23545. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23546. * * 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)
  23547. * * 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)
  23548. * @returns the VertexData of the torus
  23549. */
  23550. static CreateTorus(options: {
  23551. diameter?: number;
  23552. thickness?: number;
  23553. tessellation?: number;
  23554. sideOrientation?: number;
  23555. frontUVs?: Vector4;
  23556. backUVs?: Vector4;
  23557. }): VertexData;
  23558. /**
  23559. * Creates the VertexData of the LineSystem
  23560. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23561. * - lines an array of lines, each line being an array of successive Vector3
  23562. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23563. * @returns the VertexData of the LineSystem
  23564. */
  23565. static CreateLineSystem(options: {
  23566. lines: Vector3[][];
  23567. colors?: Nullable<Color4[][]>;
  23568. }): VertexData;
  23569. /**
  23570. * Create the VertexData for a DashedLines
  23571. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23572. * - points an array successive Vector3
  23573. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23574. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23575. * - dashNb the intended total number of dashes, optional, default 200
  23576. * @returns the VertexData for the DashedLines
  23577. */
  23578. static CreateDashedLines(options: {
  23579. points: Vector3[];
  23580. dashSize?: number;
  23581. gapSize?: number;
  23582. dashNb?: number;
  23583. }): VertexData;
  23584. /**
  23585. * Creates the VertexData for a Ground
  23586. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23587. * - width the width (x direction) of the ground, optional, default 1
  23588. * - height the height (z direction) of the ground, optional, default 1
  23589. * - subdivisions the number of subdivisions per side, optional, default 1
  23590. * @returns the VertexData of the Ground
  23591. */
  23592. static CreateGround(options: {
  23593. width?: number;
  23594. height?: number;
  23595. subdivisions?: number;
  23596. subdivisionsX?: number;
  23597. subdivisionsY?: number;
  23598. }): VertexData;
  23599. /**
  23600. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23601. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23602. * * xmin the ground minimum X coordinate, optional, default -1
  23603. * * zmin the ground minimum Z coordinate, optional, default -1
  23604. * * xmax the ground maximum X coordinate, optional, default 1
  23605. * * zmax the ground maximum Z coordinate, optional, default 1
  23606. * * 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}
  23607. * * 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}
  23608. * @returns the VertexData of the TiledGround
  23609. */
  23610. static CreateTiledGround(options: {
  23611. xmin: number;
  23612. zmin: number;
  23613. xmax: number;
  23614. zmax: number;
  23615. subdivisions?: {
  23616. w: number;
  23617. h: number;
  23618. };
  23619. precision?: {
  23620. w: number;
  23621. h: number;
  23622. };
  23623. }): VertexData;
  23624. /**
  23625. * Creates the VertexData of the Ground designed from a heightmap
  23626. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23627. * * width the width (x direction) of the ground
  23628. * * height the height (z direction) of the ground
  23629. * * subdivisions the number of subdivisions per side
  23630. * * minHeight the minimum altitude on the ground, optional, default 0
  23631. * * maxHeight the maximum altitude on the ground, optional default 1
  23632. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23633. * * buffer the array holding the image color data
  23634. * * bufferWidth the width of image
  23635. * * bufferHeight the height of image
  23636. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23637. * @returns the VertexData of the Ground designed from a heightmap
  23638. */
  23639. static CreateGroundFromHeightMap(options: {
  23640. width: number;
  23641. height: number;
  23642. subdivisions: number;
  23643. minHeight: number;
  23644. maxHeight: number;
  23645. colorFilter: Color3;
  23646. buffer: Uint8Array;
  23647. bufferWidth: number;
  23648. bufferHeight: number;
  23649. alphaFilter: number;
  23650. }): VertexData;
  23651. /**
  23652. * Creates the VertexData for a Plane
  23653. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23654. * * size sets the width and height of the plane to the value of size, optional default 1
  23655. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23656. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23657. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23658. * * 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)
  23659. * * 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)
  23660. * @returns the VertexData of the box
  23661. */
  23662. static CreatePlane(options: {
  23663. size?: number;
  23664. width?: number;
  23665. height?: number;
  23666. sideOrientation?: number;
  23667. frontUVs?: Vector4;
  23668. backUVs?: Vector4;
  23669. }): VertexData;
  23670. /**
  23671. * Creates the VertexData of the Disc or regular Polygon
  23672. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23673. * * radius the radius of the disc, optional default 0.5
  23674. * * tessellation the number of polygon sides, optional, default 64
  23675. * * 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
  23676. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23677. * * 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)
  23678. * * 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)
  23679. * @returns the VertexData of the box
  23680. */
  23681. static CreateDisc(options: {
  23682. radius?: number;
  23683. tessellation?: number;
  23684. arc?: number;
  23685. sideOrientation?: number;
  23686. frontUVs?: Vector4;
  23687. backUVs?: Vector4;
  23688. }): VertexData;
  23689. /**
  23690. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23691. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23692. * @param polygon a mesh built from polygonTriangulation.build()
  23693. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23694. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23695. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23696. * @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)
  23697. * @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)
  23698. * @returns the VertexData of the Polygon
  23699. */
  23700. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23701. /**
  23702. * Creates the VertexData of the IcoSphere
  23703. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23704. * * radius the radius of the IcoSphere, optional default 1
  23705. * * radiusX allows stretching in the x direction, optional, default radius
  23706. * * radiusY allows stretching in the y direction, optional, default radius
  23707. * * radiusZ allows stretching in the z direction, optional, default radius
  23708. * * flat when true creates a flat shaded mesh, optional, default true
  23709. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23710. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23711. * * 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)
  23712. * * 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)
  23713. * @returns the VertexData of the IcoSphere
  23714. */
  23715. static CreateIcoSphere(options: {
  23716. radius?: number;
  23717. radiusX?: number;
  23718. radiusY?: number;
  23719. radiusZ?: number;
  23720. flat?: boolean;
  23721. subdivisions?: number;
  23722. sideOrientation?: number;
  23723. frontUVs?: Vector4;
  23724. backUVs?: Vector4;
  23725. }): VertexData;
  23726. /**
  23727. * Creates the VertexData for a Polyhedron
  23728. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23729. * * type provided types are:
  23730. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23731. * * 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)
  23732. * * size the size of the IcoSphere, optional default 1
  23733. * * sizeX allows stretching in the x direction, optional, default size
  23734. * * sizeY allows stretching in the y direction, optional, default size
  23735. * * sizeZ allows stretching in the z direction, optional, default size
  23736. * * 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
  23737. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23738. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23739. * * flat when true creates a flat shaded mesh, optional, default true
  23740. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23741. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23742. * * 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)
  23743. * * 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)
  23744. * @returns the VertexData of the Polyhedron
  23745. */
  23746. static CreatePolyhedron(options: {
  23747. type?: number;
  23748. size?: number;
  23749. sizeX?: number;
  23750. sizeY?: number;
  23751. sizeZ?: number;
  23752. custom?: any;
  23753. faceUV?: Vector4[];
  23754. faceColors?: Color4[];
  23755. flat?: boolean;
  23756. sideOrientation?: number;
  23757. frontUVs?: Vector4;
  23758. backUVs?: Vector4;
  23759. }): VertexData;
  23760. /**
  23761. * Creates the VertexData for a TorusKnot
  23762. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23763. * * radius the radius of the torus knot, optional, default 2
  23764. * * tube the thickness of the tube, optional, default 0.5
  23765. * * radialSegments the number of sides on each tube segments, optional, default 32
  23766. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23767. * * p the number of windings around the z axis, optional, default 2
  23768. * * q the number of windings around the x axis, optional, default 3
  23769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23770. * * 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)
  23771. * * 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)
  23772. * @returns the VertexData of the Torus Knot
  23773. */
  23774. static CreateTorusKnot(options: {
  23775. radius?: number;
  23776. tube?: number;
  23777. radialSegments?: number;
  23778. tubularSegments?: number;
  23779. p?: number;
  23780. q?: number;
  23781. sideOrientation?: number;
  23782. frontUVs?: Vector4;
  23783. backUVs?: Vector4;
  23784. }): VertexData;
  23785. /**
  23786. * Compute normals for given positions and indices
  23787. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23788. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23789. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23790. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23791. * * facetNormals : optional array of facet normals (vector3)
  23792. * * facetPositions : optional array of facet positions (vector3)
  23793. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23794. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23795. * * bInfo : optional bounding info, required for facetPartitioning computation
  23796. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23797. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23798. * * useRightHandedSystem: optional boolean to for right handed system computation
  23799. * * depthSort : optional boolean to enable the facet depth sort computation
  23800. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23801. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23802. */
  23803. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23804. facetNormals?: any;
  23805. facetPositions?: any;
  23806. facetPartitioning?: any;
  23807. ratio?: number;
  23808. bInfo?: any;
  23809. bbSize?: Vector3;
  23810. subDiv?: any;
  23811. useRightHandedSystem?: boolean;
  23812. depthSort?: boolean;
  23813. distanceTo?: Vector3;
  23814. depthSortedFacets?: any;
  23815. }): void;
  23816. /** @hidden */
  23817. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23818. /**
  23819. * Applies VertexData created from the imported parameters to the geometry
  23820. * @param parsedVertexData the parsed data from an imported file
  23821. * @param geometry the geometry to apply the VertexData to
  23822. */
  23823. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23824. }
  23825. }
  23826. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23827. import { Nullable } from "babylonjs/types";
  23828. import { Scene } from "babylonjs/scene";
  23829. import { Vector4 } from "babylonjs/Maths/math";
  23830. import { Mesh } from "babylonjs/Meshes/mesh";
  23831. /**
  23832. * Class containing static functions to help procedurally build meshes
  23833. */
  23834. export class DiscBuilder {
  23835. /**
  23836. * Creates a plane polygonal mesh. By default, this is a disc
  23837. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23838. * * 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
  23839. * * 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
  23840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23843. * @param name defines the name of the mesh
  23844. * @param options defines the options used to create the mesh
  23845. * @param scene defines the hosting scene
  23846. * @returns the plane polygonal mesh
  23847. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23848. */
  23849. static CreateDisc(name: string, options: {
  23850. radius?: number;
  23851. tessellation?: number;
  23852. arc?: number;
  23853. updatable?: boolean;
  23854. sideOrientation?: number;
  23855. frontUVs?: Vector4;
  23856. backUVs?: Vector4;
  23857. }, scene?: Nullable<Scene>): Mesh;
  23858. }
  23859. }
  23860. declare module "babylonjs/Particles/solidParticleSystem" {
  23861. import { Vector3 } from "babylonjs/Maths/math";
  23862. import { Mesh } from "babylonjs/Meshes/mesh";
  23863. import { Scene, IDisposable } from "babylonjs/scene";
  23864. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23865. /**
  23866. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23867. *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.
  23868. * The SPS is also a particle system. It provides some methods to manage the particles.
  23869. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23870. *
  23871. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23872. */
  23873. export class SolidParticleSystem implements IDisposable {
  23874. /**
  23875. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23876. * Example : var p = SPS.particles[i];
  23877. */
  23878. particles: SolidParticle[];
  23879. /**
  23880. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23881. */
  23882. nbParticles: number;
  23883. /**
  23884. * If the particles must ever face the camera (default false). Useful for planar particles.
  23885. */
  23886. billboard: boolean;
  23887. /**
  23888. * Recompute normals when adding a shape
  23889. */
  23890. recomputeNormals: boolean;
  23891. /**
  23892. * This a counter ofr your own usage. It's not set by any SPS functions.
  23893. */
  23894. counter: number;
  23895. /**
  23896. * The SPS name. This name is also given to the underlying mesh.
  23897. */
  23898. name: string;
  23899. /**
  23900. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23901. */
  23902. mesh: Mesh;
  23903. /**
  23904. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23905. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23906. */
  23907. vars: any;
  23908. /**
  23909. * This array is populated when the SPS is set as 'pickable'.
  23910. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23911. * Each element of this array is an object `{idx: int, faceId: int}`.
  23912. * `idx` is the picked particle index in the `SPS.particles` array
  23913. * `faceId` is the picked face index counted within this particle.
  23914. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23915. */
  23916. pickedParticles: {
  23917. idx: number;
  23918. faceId: number;
  23919. }[];
  23920. /**
  23921. * This array is populated when `enableDepthSort` is set to true.
  23922. * Each element of this array is an instance of the class DepthSortedParticle.
  23923. */
  23924. depthSortedParticles: DepthSortedParticle[];
  23925. /**
  23926. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23927. * @hidden
  23928. */
  23929. _bSphereOnly: boolean;
  23930. /**
  23931. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23932. * @hidden
  23933. */
  23934. _bSphereRadiusFactor: number;
  23935. private _scene;
  23936. private _positions;
  23937. private _indices;
  23938. private _normals;
  23939. private _colors;
  23940. private _uvs;
  23941. private _indices32;
  23942. private _positions32;
  23943. private _normals32;
  23944. private _fixedNormal32;
  23945. private _colors32;
  23946. private _uvs32;
  23947. private _index;
  23948. private _updatable;
  23949. private _pickable;
  23950. private _isVisibilityBoxLocked;
  23951. private _alwaysVisible;
  23952. private _depthSort;
  23953. private _shapeCounter;
  23954. private _copy;
  23955. private _color;
  23956. private _computeParticleColor;
  23957. private _computeParticleTexture;
  23958. private _computeParticleRotation;
  23959. private _computeParticleVertex;
  23960. private _computeBoundingBox;
  23961. private _depthSortParticles;
  23962. private _camera;
  23963. private _mustUnrotateFixedNormals;
  23964. private _particlesIntersect;
  23965. private _needs32Bits;
  23966. /**
  23967. * Creates a SPS (Solid Particle System) object.
  23968. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23969. * @param scene (Scene) is the scene in which the SPS is added.
  23970. * @param options defines the options of the sps e.g.
  23971. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23972. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23973. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23974. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23975. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23976. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23977. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23978. */
  23979. constructor(name: string, scene: Scene, options?: {
  23980. updatable?: boolean;
  23981. isPickable?: boolean;
  23982. enableDepthSort?: boolean;
  23983. particleIntersection?: boolean;
  23984. boundingSphereOnly?: boolean;
  23985. bSphereRadiusFactor?: number;
  23986. });
  23987. /**
  23988. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23989. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23990. * @returns the created mesh
  23991. */
  23992. buildMesh(): Mesh;
  23993. /**
  23994. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23995. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23996. * Thus the particles generated from `digest()` have their property `position` set yet.
  23997. * @param mesh ( Mesh ) is the mesh to be digested
  23998. * @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
  23999. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24000. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24001. * @returns the current SPS
  24002. */
  24003. digest(mesh: Mesh, options?: {
  24004. facetNb?: number;
  24005. number?: number;
  24006. delta?: number;
  24007. }): SolidParticleSystem;
  24008. private _unrotateFixedNormals;
  24009. private _resetCopy;
  24010. private _meshBuilder;
  24011. private _posToShape;
  24012. private _uvsToShapeUV;
  24013. private _addParticle;
  24014. /**
  24015. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24016. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24017. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24018. * @param nb (positive integer) the number of particles to be created from this model
  24019. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24020. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24021. * @returns the number of shapes in the system
  24022. */
  24023. addShape(mesh: Mesh, nb: number, options?: {
  24024. positionFunction?: any;
  24025. vertexFunction?: any;
  24026. }): number;
  24027. private _rebuildParticle;
  24028. /**
  24029. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24030. * @returns the SPS.
  24031. */
  24032. rebuildMesh(): SolidParticleSystem;
  24033. /**
  24034. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24035. * This method calls `updateParticle()` for each particle of the SPS.
  24036. * For an animated SPS, it is usually called within the render loop.
  24037. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24038. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24039. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24040. * @returns the SPS.
  24041. */
  24042. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24043. /**
  24044. * Disposes the SPS.
  24045. */
  24046. dispose(): void;
  24047. /**
  24048. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24049. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24050. * @returns the SPS.
  24051. */
  24052. refreshVisibleSize(): SolidParticleSystem;
  24053. /**
  24054. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24055. * @param size the size (float) of the visibility box
  24056. * note : this doesn't lock the SPS mesh bounding box.
  24057. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24058. */
  24059. setVisibilityBox(size: number): void;
  24060. /**
  24061. * Gets whether the SPS as always visible or not
  24062. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24063. */
  24064. /**
  24065. * Sets the SPS as always visible or not
  24066. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24067. */
  24068. isAlwaysVisible: boolean;
  24069. /**
  24070. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24071. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24072. */
  24073. /**
  24074. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24075. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24076. */
  24077. isVisibilityBoxLocked: boolean;
  24078. /**
  24079. * Tells to `setParticles()` to compute the particle rotations or not.
  24080. * Default value : true. The SPS is faster when it's set to false.
  24081. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24082. */
  24083. /**
  24084. * Gets if `setParticles()` computes the particle rotations or not.
  24085. * Default value : true. The SPS is faster when it's set to false.
  24086. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24087. */
  24088. computeParticleRotation: boolean;
  24089. /**
  24090. * Tells to `setParticles()` to compute the particle colors or not.
  24091. * Default value : true. The SPS is faster when it's set to false.
  24092. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24093. */
  24094. /**
  24095. * Gets if `setParticles()` computes the particle colors or not.
  24096. * Default value : true. The SPS is faster when it's set to false.
  24097. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24098. */
  24099. computeParticleColor: boolean;
  24100. /**
  24101. * Gets if `setParticles()` computes the particle textures or not.
  24102. * Default value : true. The SPS is faster when it's set to false.
  24103. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24104. */
  24105. computeParticleTexture: boolean;
  24106. /**
  24107. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24108. * Default value : false. The SPS is faster when it's set to false.
  24109. * Note : the particle custom vertex positions aren't stored values.
  24110. */
  24111. /**
  24112. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24113. * Default value : false. The SPS is faster when it's set to false.
  24114. * Note : the particle custom vertex positions aren't stored values.
  24115. */
  24116. computeParticleVertex: boolean;
  24117. /**
  24118. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24119. */
  24120. /**
  24121. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24122. */
  24123. computeBoundingBox: boolean;
  24124. /**
  24125. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24126. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24127. * Default : `true`
  24128. */
  24129. /**
  24130. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24131. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24132. * Default : `true`
  24133. */
  24134. depthSortParticles: boolean;
  24135. /**
  24136. * This function does nothing. It may be overwritten to set all the particle first values.
  24137. * The SPS doesn't call this function, you may have to call it by your own.
  24138. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24139. */
  24140. initParticles(): void;
  24141. /**
  24142. * This function does nothing. It may be overwritten to recycle a particle.
  24143. * The SPS doesn't call this function, you may have to call it by your own.
  24144. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24145. * @param particle The particle to recycle
  24146. * @returns the recycled particle
  24147. */
  24148. recycleParticle(particle: SolidParticle): SolidParticle;
  24149. /**
  24150. * Updates a particle : this function should be overwritten by the user.
  24151. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24152. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24153. * @example : just set a particle position or velocity and recycle conditions
  24154. * @param particle The particle to update
  24155. * @returns the updated particle
  24156. */
  24157. updateParticle(particle: SolidParticle): SolidParticle;
  24158. /**
  24159. * Updates a vertex of a particle : it can be overwritten by the user.
  24160. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24161. * @param particle the current particle
  24162. * @param vertex the current index of the current particle
  24163. * @param pt the index of the current vertex in the particle shape
  24164. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24165. * @example : just set a vertex particle position
  24166. * @returns the updated vertex
  24167. */
  24168. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24169. /**
  24170. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24171. * This does nothing and may be overwritten by the user.
  24172. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24173. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24174. * @param update the boolean update value actually passed to setParticles()
  24175. */
  24176. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24177. /**
  24178. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24179. * This will be passed three parameters.
  24180. * This does nothing and may be overwritten by the user.
  24181. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24182. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24183. * @param update the boolean update value actually passed to setParticles()
  24184. */
  24185. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24186. }
  24187. }
  24188. declare module "babylonjs/Particles/solidParticle" {
  24189. import { Nullable } from "babylonjs/types";
  24190. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24191. import { Mesh } from "babylonjs/Meshes/mesh";
  24192. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24193. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24194. /**
  24195. * Represents one particle of a solid particle system.
  24196. */
  24197. export class SolidParticle {
  24198. /**
  24199. * particle global index
  24200. */
  24201. idx: number;
  24202. /**
  24203. * The color of the particle
  24204. */
  24205. color: Nullable<Color4>;
  24206. /**
  24207. * The world space position of the particle.
  24208. */
  24209. position: Vector3;
  24210. /**
  24211. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24212. */
  24213. rotation: Vector3;
  24214. /**
  24215. * The world space rotation quaternion of the particle.
  24216. */
  24217. rotationQuaternion: Nullable<Quaternion>;
  24218. /**
  24219. * The scaling of the particle.
  24220. */
  24221. scaling: Vector3;
  24222. /**
  24223. * The uvs of the particle.
  24224. */
  24225. uvs: Vector4;
  24226. /**
  24227. * The current speed of the particle.
  24228. */
  24229. velocity: Vector3;
  24230. /**
  24231. * The pivot point in the particle local space.
  24232. */
  24233. pivot: Vector3;
  24234. /**
  24235. * Must the particle be translated from its pivot point in its local space ?
  24236. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24237. * Default : false
  24238. */
  24239. translateFromPivot: boolean;
  24240. /**
  24241. * Is the particle active or not ?
  24242. */
  24243. alive: boolean;
  24244. /**
  24245. * Is the particle visible or not ?
  24246. */
  24247. isVisible: boolean;
  24248. /**
  24249. * Index of this particle in the global "positions" array (Internal use)
  24250. * @hidden
  24251. */
  24252. _pos: number;
  24253. /**
  24254. * @hidden Index of this particle in the global "indices" array (Internal use)
  24255. */
  24256. _ind: number;
  24257. /**
  24258. * @hidden ModelShape of this particle (Internal use)
  24259. */
  24260. _model: ModelShape;
  24261. /**
  24262. * ModelShape id of this particle
  24263. */
  24264. shapeId: number;
  24265. /**
  24266. * Index of the particle in its shape id (Internal use)
  24267. */
  24268. idxInShape: number;
  24269. /**
  24270. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24271. */
  24272. _modelBoundingInfo: BoundingInfo;
  24273. /**
  24274. * @hidden Particle BoundingInfo object (Internal use)
  24275. */
  24276. _boundingInfo: BoundingInfo;
  24277. /**
  24278. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24279. */
  24280. _sps: SolidParticleSystem;
  24281. /**
  24282. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24283. */
  24284. _stillInvisible: boolean;
  24285. /**
  24286. * @hidden Last computed particle rotation matrix
  24287. */
  24288. _rotationMatrix: number[];
  24289. /**
  24290. * Parent particle Id, if any.
  24291. * Default null.
  24292. */
  24293. parentId: Nullable<number>;
  24294. /**
  24295. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24296. * The possible values are :
  24297. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24298. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24299. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24300. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24301. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24302. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24303. * */
  24304. cullingStrategy: number;
  24305. /**
  24306. * @hidden Internal global position in the SPS.
  24307. */
  24308. _globalPosition: Vector3;
  24309. /**
  24310. * Creates a Solid Particle object.
  24311. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24312. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24313. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24314. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24315. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24316. * @param shapeId (integer) is the model shape identifier in the SPS.
  24317. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24318. * @param sps defines the sps it is associated to
  24319. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24320. */
  24321. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24322. /**
  24323. * Legacy support, changed scale to scaling
  24324. */
  24325. /**
  24326. * Legacy support, changed scale to scaling
  24327. */
  24328. scale: Vector3;
  24329. /**
  24330. * Legacy support, changed quaternion to rotationQuaternion
  24331. */
  24332. /**
  24333. * Legacy support, changed quaternion to rotationQuaternion
  24334. */
  24335. quaternion: Nullable<Quaternion>;
  24336. /**
  24337. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24338. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24339. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24340. * @returns true if it intersects
  24341. */
  24342. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24343. /**
  24344. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24345. * A particle is in the frustum if its bounding box intersects the frustum
  24346. * @param frustumPlanes defines the frustum to test
  24347. * @returns true if the particle is in the frustum planes
  24348. */
  24349. isInFrustum(frustumPlanes: Plane[]): boolean;
  24350. /**
  24351. * get the rotation matrix of the particle
  24352. * @hidden
  24353. */
  24354. getRotationMatrix(m: Matrix): void;
  24355. }
  24356. /**
  24357. * Represents the shape of the model used by one particle of a solid particle system.
  24358. * SPS internal tool, don't use it manually.
  24359. */
  24360. export class ModelShape {
  24361. /**
  24362. * The shape id
  24363. * @hidden
  24364. */
  24365. shapeID: number;
  24366. /**
  24367. * flat array of model positions (internal use)
  24368. * @hidden
  24369. */
  24370. _shape: Vector3[];
  24371. /**
  24372. * flat array of model UVs (internal use)
  24373. * @hidden
  24374. */
  24375. _shapeUV: number[];
  24376. /**
  24377. * length of the shape in the model indices array (internal use)
  24378. * @hidden
  24379. */
  24380. _indicesLength: number;
  24381. /**
  24382. * Custom position function (internal use)
  24383. * @hidden
  24384. */
  24385. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24386. /**
  24387. * Custom vertex function (internal use)
  24388. * @hidden
  24389. */
  24390. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24391. /**
  24392. * 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.
  24393. * SPS internal tool, don't use it manually.
  24394. * @hidden
  24395. */
  24396. 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>);
  24397. }
  24398. /**
  24399. * Represents a Depth Sorted Particle in the solid particle system.
  24400. */
  24401. export class DepthSortedParticle {
  24402. /**
  24403. * Index of the particle in the "indices" array
  24404. */
  24405. ind: number;
  24406. /**
  24407. * Length of the particle shape in the "indices" array
  24408. */
  24409. indicesLength: number;
  24410. /**
  24411. * Squared distance from the particle to the camera
  24412. */
  24413. sqDistance: number;
  24414. }
  24415. }
  24416. declare module "babylonjs/Meshes/abstractMesh" {
  24417. import { Observable } from "babylonjs/Misc/observable";
  24418. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24419. import { Camera } from "babylonjs/Cameras/camera";
  24420. import { Scene, IDisposable } from "babylonjs/scene";
  24421. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24422. import { Node } from "babylonjs/node";
  24423. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24424. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24425. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24426. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24427. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24428. import { Material } from "babylonjs/Materials/material";
  24429. import { Light } from "babylonjs/Lights/light";
  24430. import { Skeleton } from "babylonjs/Bones/skeleton";
  24431. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24432. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24433. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24434. import { Ray } from "babylonjs/Culling/ray";
  24435. import { Collider } from "babylonjs/Collisions/collider";
  24436. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24437. /**
  24438. * Class used to store all common mesh properties
  24439. */
  24440. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24441. /** No occlusion */
  24442. static OCCLUSION_TYPE_NONE: number;
  24443. /** Occlusion set to optimisitic */
  24444. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24445. /** Occlusion set to strict */
  24446. static OCCLUSION_TYPE_STRICT: number;
  24447. /** Use an accurante occlusion algorithm */
  24448. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24449. /** Use a conservative occlusion algorithm */
  24450. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24451. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24452. * Test order :
  24453. * Is the bounding sphere outside the frustum ?
  24454. * If not, are the bounding box vertices outside the frustum ?
  24455. * It not, then the cullable object is in the frustum.
  24456. */
  24457. static readonly CULLINGSTRATEGY_STANDARD: number;
  24458. /** Culling strategy : Bounding Sphere Only.
  24459. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24460. * It's also less accurate than the standard because some not visible objects can still be selected.
  24461. * Test : is the bounding sphere outside the frustum ?
  24462. * If not, then the cullable object is in the frustum.
  24463. */
  24464. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24465. /** Culling strategy : Optimistic Inclusion.
  24466. * This in an inclusion test first, then the standard exclusion test.
  24467. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24468. * 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.
  24469. * Anyway, it's as accurate as the standard strategy.
  24470. * Test :
  24471. * Is the cullable object bounding sphere center in the frustum ?
  24472. * If not, apply the default culling strategy.
  24473. */
  24474. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24475. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24476. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24477. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24478. * 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.
  24479. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24480. * Test :
  24481. * Is the cullable object bounding sphere center in the frustum ?
  24482. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24483. */
  24484. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24485. /**
  24486. * No billboard
  24487. */
  24488. static readonly BILLBOARDMODE_NONE: number;
  24489. /** Billboard on X axis */
  24490. static readonly BILLBOARDMODE_X: number;
  24491. /** Billboard on Y axis */
  24492. static readonly BILLBOARDMODE_Y: number;
  24493. /** Billboard on Z axis */
  24494. static readonly BILLBOARDMODE_Z: number;
  24495. /** Billboard on all axes */
  24496. static readonly BILLBOARDMODE_ALL: number;
  24497. private _facetData;
  24498. /**
  24499. * The culling strategy to use to check whether the mesh must be rendered or not.
  24500. * This value can be changed at any time and will be used on the next render mesh selection.
  24501. * The possible values are :
  24502. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24503. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24504. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24505. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24506. * Please read each static variable documentation to get details about the culling process.
  24507. * */
  24508. cullingStrategy: number;
  24509. /**
  24510. * Gets the number of facets in the mesh
  24511. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24512. */
  24513. readonly facetNb: number;
  24514. /**
  24515. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24517. */
  24518. partitioningSubdivisions: number;
  24519. /**
  24520. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24521. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24522. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24523. */
  24524. partitioningBBoxRatio: number;
  24525. /**
  24526. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24527. * Works only for updatable meshes.
  24528. * Doesn't work with multi-materials
  24529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24530. */
  24531. mustDepthSortFacets: boolean;
  24532. /**
  24533. * The location (Vector3) where the facet depth sort must be computed from.
  24534. * By default, the active camera position.
  24535. * Used only when facet depth sort is enabled
  24536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24537. */
  24538. facetDepthSortFrom: Vector3;
  24539. /**
  24540. * gets a boolean indicating if facetData is enabled
  24541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24542. */
  24543. readonly isFacetDataEnabled: boolean;
  24544. /** @hidden */
  24545. _updateNonUniformScalingState(value: boolean): boolean;
  24546. /**
  24547. * An event triggered when this mesh collides with another one
  24548. */
  24549. onCollideObservable: Observable<AbstractMesh>;
  24550. private _onCollideObserver;
  24551. /** Set a function to call when this mesh collides with another one */
  24552. onCollide: () => void;
  24553. /**
  24554. * An event triggered when the collision's position changes
  24555. */
  24556. onCollisionPositionChangeObservable: Observable<Vector3>;
  24557. private _onCollisionPositionChangeObserver;
  24558. /** Set a function to call when the collision's position changes */
  24559. onCollisionPositionChange: () => void;
  24560. /**
  24561. * An event triggered when material is changed
  24562. */
  24563. onMaterialChangedObservable: Observable<AbstractMesh>;
  24564. /**
  24565. * Gets or sets the orientation for POV movement & rotation
  24566. */
  24567. definedFacingForward: boolean;
  24568. /** @hidden */
  24569. _occlusionQuery: Nullable<WebGLQuery>;
  24570. private _visibility;
  24571. /**
  24572. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24573. */
  24574. /**
  24575. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24576. */
  24577. visibility: number;
  24578. /** Gets or sets the alpha index used to sort transparent meshes
  24579. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24580. */
  24581. alphaIndex: number;
  24582. /**
  24583. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24584. */
  24585. isVisible: boolean;
  24586. /**
  24587. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24588. */
  24589. isPickable: boolean;
  24590. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24591. showSubMeshesBoundingBox: boolean;
  24592. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24593. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24594. */
  24595. isBlocker: boolean;
  24596. /**
  24597. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24598. */
  24599. enablePointerMoveEvents: boolean;
  24600. /**
  24601. * Specifies the rendering group id for this mesh (0 by default)
  24602. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24603. */
  24604. renderingGroupId: number;
  24605. private _material;
  24606. /** Gets or sets current material */
  24607. material: Nullable<Material>;
  24608. private _receiveShadows;
  24609. /**
  24610. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24611. * @see http://doc.babylonjs.com/babylon101/shadows
  24612. */
  24613. receiveShadows: boolean;
  24614. /** Defines color to use when rendering outline */
  24615. outlineColor: Color3;
  24616. /** Define width to use when rendering outline */
  24617. outlineWidth: number;
  24618. /** Defines color to use when rendering overlay */
  24619. overlayColor: Color3;
  24620. /** Defines alpha to use when rendering overlay */
  24621. overlayAlpha: number;
  24622. private _hasVertexAlpha;
  24623. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24624. hasVertexAlpha: boolean;
  24625. private _useVertexColors;
  24626. /** 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) */
  24627. useVertexColors: boolean;
  24628. private _computeBonesUsingShaders;
  24629. /**
  24630. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24631. */
  24632. computeBonesUsingShaders: boolean;
  24633. private _numBoneInfluencers;
  24634. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24635. numBoneInfluencers: number;
  24636. private _applyFog;
  24637. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24638. applyFog: boolean;
  24639. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24640. useOctreeForRenderingSelection: boolean;
  24641. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24642. useOctreeForPicking: boolean;
  24643. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24644. useOctreeForCollisions: boolean;
  24645. private _layerMask;
  24646. /**
  24647. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24648. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24649. */
  24650. layerMask: number;
  24651. /**
  24652. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24653. */
  24654. alwaysSelectAsActiveMesh: boolean;
  24655. /**
  24656. * Gets or sets the current action manager
  24657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24658. */
  24659. actionManager: Nullable<AbstractActionManager>;
  24660. private _checkCollisions;
  24661. private _collisionMask;
  24662. private _collisionGroup;
  24663. /**
  24664. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24665. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24666. */
  24667. ellipsoid: Vector3;
  24668. /**
  24669. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24670. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24671. */
  24672. ellipsoidOffset: Vector3;
  24673. private _collider;
  24674. private _oldPositionForCollisions;
  24675. private _diffPositionForCollisions;
  24676. /**
  24677. * Gets or sets a collision mask used to mask collisions (default is -1).
  24678. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24679. */
  24680. collisionMask: number;
  24681. /**
  24682. * Gets or sets the current collision group mask (-1 by default).
  24683. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24684. */
  24685. collisionGroup: number;
  24686. /**
  24687. * Defines edge width used when edgesRenderer is enabled
  24688. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24689. */
  24690. edgesWidth: number;
  24691. /**
  24692. * Defines edge color used when edgesRenderer is enabled
  24693. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24694. */
  24695. edgesColor: Color4;
  24696. /** @hidden */
  24697. _edgesRenderer: Nullable<IEdgesRenderer>;
  24698. /** @hidden */
  24699. _masterMesh: Nullable<AbstractMesh>;
  24700. /** @hidden */
  24701. _boundingInfo: Nullable<BoundingInfo>;
  24702. /** @hidden */
  24703. _renderId: number;
  24704. /**
  24705. * Gets or sets the list of subMeshes
  24706. * @see http://doc.babylonjs.com/how_to/multi_materials
  24707. */
  24708. subMeshes: SubMesh[];
  24709. /** @hidden */
  24710. _intersectionsInProgress: AbstractMesh[];
  24711. /** @hidden */
  24712. _unIndexed: boolean;
  24713. /** @hidden */
  24714. _lightSources: Light[];
  24715. /** @hidden */
  24716. readonly _positions: Nullable<Vector3[]>;
  24717. /** @hidden */
  24718. _waitingActions: any;
  24719. /** @hidden */
  24720. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24721. private _skeleton;
  24722. /** @hidden */
  24723. _bonesTransformMatrices: Nullable<Float32Array>;
  24724. /**
  24725. * Gets or sets a skeleton to apply skining transformations
  24726. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24727. */
  24728. skeleton: Nullable<Skeleton>;
  24729. /**
  24730. * An event triggered when the mesh is rebuilt.
  24731. */
  24732. onRebuildObservable: Observable<AbstractMesh>;
  24733. /**
  24734. * Creates a new AbstractMesh
  24735. * @param name defines the name of the mesh
  24736. * @param scene defines the hosting scene
  24737. */
  24738. constructor(name: string, scene?: Nullable<Scene>);
  24739. /**
  24740. * Returns the string "AbstractMesh"
  24741. * @returns "AbstractMesh"
  24742. */
  24743. getClassName(): string;
  24744. /**
  24745. * Gets a string representation of the current mesh
  24746. * @param fullDetails defines a boolean indicating if full details must be included
  24747. * @returns a string representation of the current mesh
  24748. */
  24749. toString(fullDetails?: boolean): string;
  24750. /** @hidden */
  24751. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24752. /** @hidden */
  24753. _rebuild(): void;
  24754. /** @hidden */
  24755. _resyncLightSources(): void;
  24756. /** @hidden */
  24757. _resyncLighSource(light: Light): void;
  24758. /** @hidden */
  24759. _unBindEffect(): void;
  24760. /** @hidden */
  24761. _removeLightSource(light: Light): void;
  24762. private _markSubMeshesAsDirty;
  24763. /** @hidden */
  24764. _markSubMeshesAsLightDirty(): void;
  24765. /** @hidden */
  24766. _markSubMeshesAsAttributesDirty(): void;
  24767. /** @hidden */
  24768. _markSubMeshesAsMiscDirty(): void;
  24769. /**
  24770. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24771. */
  24772. scaling: Vector3;
  24773. /**
  24774. * Returns true if the mesh is blocked. Implemented by child classes
  24775. */
  24776. readonly isBlocked: boolean;
  24777. /**
  24778. * Returns the mesh itself by default. Implemented by child classes
  24779. * @param camera defines the camera to use to pick the right LOD level
  24780. * @returns the currentAbstractMesh
  24781. */
  24782. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24783. /**
  24784. * Returns 0 by default. Implemented by child classes
  24785. * @returns an integer
  24786. */
  24787. getTotalVertices(): number;
  24788. /**
  24789. * Returns a positive integer : the total number of indices in this mesh geometry.
  24790. * @returns the numner of indices or zero if the mesh has no geometry.
  24791. */
  24792. getTotalIndices(): number;
  24793. /**
  24794. * Returns null by default. Implemented by child classes
  24795. * @returns null
  24796. */
  24797. getIndices(): Nullable<IndicesArray>;
  24798. /**
  24799. * Returns the array of the requested vertex data kind. Implemented by child classes
  24800. * @param kind defines the vertex data kind to use
  24801. * @returns null
  24802. */
  24803. getVerticesData(kind: string): Nullable<FloatArray>;
  24804. /**
  24805. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24806. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24807. * Note that a new underlying VertexBuffer object is created each call.
  24808. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24809. * @param kind defines vertex data kind:
  24810. * * VertexBuffer.PositionKind
  24811. * * VertexBuffer.UVKind
  24812. * * VertexBuffer.UV2Kind
  24813. * * VertexBuffer.UV3Kind
  24814. * * VertexBuffer.UV4Kind
  24815. * * VertexBuffer.UV5Kind
  24816. * * VertexBuffer.UV6Kind
  24817. * * VertexBuffer.ColorKind
  24818. * * VertexBuffer.MatricesIndicesKind
  24819. * * VertexBuffer.MatricesIndicesExtraKind
  24820. * * VertexBuffer.MatricesWeightsKind
  24821. * * VertexBuffer.MatricesWeightsExtraKind
  24822. * @param data defines the data source
  24823. * @param updatable defines if the data must be flagged as updatable (or static)
  24824. * @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
  24825. * @returns the current mesh
  24826. */
  24827. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24828. /**
  24829. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24830. * If the mesh has no geometry, it is simply returned as it is.
  24831. * @param kind defines vertex data kind:
  24832. * * VertexBuffer.PositionKind
  24833. * * VertexBuffer.UVKind
  24834. * * VertexBuffer.UV2Kind
  24835. * * VertexBuffer.UV3Kind
  24836. * * VertexBuffer.UV4Kind
  24837. * * VertexBuffer.UV5Kind
  24838. * * VertexBuffer.UV6Kind
  24839. * * VertexBuffer.ColorKind
  24840. * * VertexBuffer.MatricesIndicesKind
  24841. * * VertexBuffer.MatricesIndicesExtraKind
  24842. * * VertexBuffer.MatricesWeightsKind
  24843. * * VertexBuffer.MatricesWeightsExtraKind
  24844. * @param data defines the data source
  24845. * @param 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
  24846. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24847. * @returns the current mesh
  24848. */
  24849. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24850. /**
  24851. * Sets the mesh indices,
  24852. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24853. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24854. * @param totalVertices Defines the total number of vertices
  24855. * @returns the current mesh
  24856. */
  24857. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24858. /**
  24859. * Gets a boolean indicating if specific vertex data is present
  24860. * @param kind defines the vertex data kind to use
  24861. * @returns true is data kind is present
  24862. */
  24863. isVerticesDataPresent(kind: string): boolean;
  24864. /**
  24865. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24866. * @returns a BoundingInfo
  24867. */
  24868. getBoundingInfo(): BoundingInfo;
  24869. /**
  24870. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24871. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24872. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24873. * @returns the current mesh
  24874. */
  24875. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24876. /**
  24877. * Overwrite the current bounding info
  24878. * @param boundingInfo defines the new bounding info
  24879. * @returns the current mesh
  24880. */
  24881. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24882. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24883. readonly useBones: boolean;
  24884. /** @hidden */
  24885. _preActivate(): void;
  24886. /** @hidden */
  24887. _preActivateForIntermediateRendering(renderId: number): void;
  24888. /** @hidden */
  24889. _activate(renderId: number): void;
  24890. /**
  24891. * Gets the current world matrix
  24892. * @returns a Matrix
  24893. */
  24894. getWorldMatrix(): Matrix;
  24895. /** @hidden */
  24896. _getWorldMatrixDeterminant(): number;
  24897. /**
  24898. * Perform relative position change from the point of view of behind the front of the mesh.
  24899. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24900. * Supports definition of mesh facing forward or backward
  24901. * @param amountRight defines the distance on the right axis
  24902. * @param amountUp defines the distance on the up axis
  24903. * @param amountForward defines the distance on the forward axis
  24904. * @returns the current mesh
  24905. */
  24906. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24907. /**
  24908. * Calculate relative position change from the point of view of behind the front of the mesh.
  24909. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24910. * Supports definition of mesh facing forward or backward
  24911. * @param amountRight defines the distance on the right axis
  24912. * @param amountUp defines the distance on the up axis
  24913. * @param amountForward defines the distance on the forward axis
  24914. * @returns the new displacement vector
  24915. */
  24916. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24917. /**
  24918. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24919. * Supports definition of mesh facing forward or backward
  24920. * @param flipBack defines the flip
  24921. * @param twirlClockwise defines the twirl
  24922. * @param tiltRight defines the tilt
  24923. * @returns the current mesh
  24924. */
  24925. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24926. /**
  24927. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24928. * Supports definition of mesh facing forward or backward.
  24929. * @param flipBack defines the flip
  24930. * @param twirlClockwise defines the twirl
  24931. * @param tiltRight defines the tilt
  24932. * @returns the new rotation vector
  24933. */
  24934. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24935. /**
  24936. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24937. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24938. * @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
  24939. * @returns the new bounding vectors
  24940. */
  24941. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24942. min: Vector3;
  24943. max: Vector3;
  24944. };
  24945. /**
  24946. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24947. * This means the mesh underlying bounding box and sphere are recomputed.
  24948. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24949. * @returns the current mesh
  24950. */
  24951. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24952. /** @hidden */
  24953. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24954. /** @hidden */
  24955. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24956. /** @hidden */
  24957. _updateBoundingInfo(): AbstractMesh;
  24958. /** @hidden */
  24959. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24960. /** @hidden */
  24961. protected _afterComputeWorldMatrix(): void;
  24962. /** @hidden */
  24963. readonly _effectiveMesh: AbstractMesh;
  24964. /**
  24965. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24966. * A mesh is in the frustum if its bounding box intersects the frustum
  24967. * @param frustumPlanes defines the frustum to test
  24968. * @returns true if the mesh is in the frustum planes
  24969. */
  24970. isInFrustum(frustumPlanes: Plane[]): boolean;
  24971. /**
  24972. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24973. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24974. * @param frustumPlanes defines the frustum to test
  24975. * @returns true if the mesh is completely in the frustum planes
  24976. */
  24977. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24978. /**
  24979. * True if the mesh intersects another mesh or a SolidParticle object
  24980. * @param mesh defines a target mesh or SolidParticle to test
  24981. * @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)
  24982. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24983. * @returns true if there is an intersection
  24984. */
  24985. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24986. /**
  24987. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24988. * @param point defines the point to test
  24989. * @returns true if there is an intersection
  24990. */
  24991. intersectsPoint(point: Vector3): boolean;
  24992. /**
  24993. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24995. */
  24996. checkCollisions: boolean;
  24997. /**
  24998. * Gets Collider object used to compute collisions (not physics)
  24999. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25000. */
  25001. readonly collider: Collider;
  25002. /**
  25003. * Move the mesh using collision engine
  25004. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25005. * @param displacement defines the requested displacement vector
  25006. * @returns the current mesh
  25007. */
  25008. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25009. private _onCollisionPositionChange;
  25010. /** @hidden */
  25011. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25012. /** @hidden */
  25013. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25014. /** @hidden */
  25015. _checkCollision(collider: Collider): AbstractMesh;
  25016. /** @hidden */
  25017. _generatePointsArray(): boolean;
  25018. /**
  25019. * Checks if the passed Ray intersects with the mesh
  25020. * @param ray defines the ray to use
  25021. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25022. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25023. * @returns the picking info
  25024. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25025. */
  25026. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25027. /**
  25028. * Clones the current mesh
  25029. * @param name defines the mesh name
  25030. * @param newParent defines the new mesh parent
  25031. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25032. * @returns the new mesh
  25033. */
  25034. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25035. /**
  25036. * Disposes all the submeshes of the current meshnp
  25037. * @returns the current mesh
  25038. */
  25039. releaseSubMeshes(): AbstractMesh;
  25040. /**
  25041. * Releases resources associated with this abstract mesh.
  25042. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25043. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25044. */
  25045. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25046. /**
  25047. * Adds the passed mesh as a child to the current mesh
  25048. * @param mesh defines the child mesh
  25049. * @returns the current mesh
  25050. */
  25051. addChild(mesh: AbstractMesh): AbstractMesh;
  25052. /**
  25053. * Removes the passed mesh from the current mesh children list
  25054. * @param mesh defines the child mesh
  25055. * @returns the current mesh
  25056. */
  25057. removeChild(mesh: AbstractMesh): AbstractMesh;
  25058. /** @hidden */
  25059. private _initFacetData;
  25060. /**
  25061. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25062. * This method can be called within the render loop.
  25063. * 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
  25064. * @returns the current mesh
  25065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25066. */
  25067. updateFacetData(): AbstractMesh;
  25068. /**
  25069. * Returns the facetLocalNormals array.
  25070. * The normals are expressed in the mesh local spac
  25071. * @returns an array of Vector3
  25072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25073. */
  25074. getFacetLocalNormals(): Vector3[];
  25075. /**
  25076. * Returns the facetLocalPositions array.
  25077. * The facet positions are expressed in the mesh local space
  25078. * @returns an array of Vector3
  25079. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25080. */
  25081. getFacetLocalPositions(): Vector3[];
  25082. /**
  25083. * Returns the facetLocalPartioning array
  25084. * @returns an array of array of numbers
  25085. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25086. */
  25087. getFacetLocalPartitioning(): number[][];
  25088. /**
  25089. * Returns the i-th facet position in the world system.
  25090. * This method allocates a new Vector3 per call
  25091. * @param i defines the facet index
  25092. * @returns a new Vector3
  25093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25094. */
  25095. getFacetPosition(i: number): Vector3;
  25096. /**
  25097. * Sets the reference Vector3 with the i-th facet position in the world system
  25098. * @param i defines the facet index
  25099. * @param ref defines the target vector
  25100. * @returns the current mesh
  25101. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25102. */
  25103. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25104. /**
  25105. * Returns the i-th facet normal in the world system.
  25106. * This method allocates a new Vector3 per call
  25107. * @param i defines the facet index
  25108. * @returns a new Vector3
  25109. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25110. */
  25111. getFacetNormal(i: number): Vector3;
  25112. /**
  25113. * Sets the reference Vector3 with the i-th facet normal in the world system
  25114. * @param i defines the facet index
  25115. * @param ref defines the target vector
  25116. * @returns the current mesh
  25117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25118. */
  25119. getFacetNormalToRef(i: number, ref: Vector3): this;
  25120. /**
  25121. * 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)
  25122. * @param x defines x coordinate
  25123. * @param y defines y coordinate
  25124. * @param z defines z coordinate
  25125. * @returns the array of facet indexes
  25126. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25127. */
  25128. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25129. /**
  25130. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25131. * @param projected sets as the (x,y,z) world projection on the facet
  25132. * @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
  25133. * @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
  25134. * @param x defines x coordinate
  25135. * @param y defines y coordinate
  25136. * @param z defines z coordinate
  25137. * @returns the face index if found (or null instead)
  25138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25139. */
  25140. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25141. /**
  25142. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25143. * @param projected sets as the (x,y,z) local projection on the facet
  25144. * @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
  25145. * @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
  25146. * @param x defines x coordinate
  25147. * @param y defines y coordinate
  25148. * @param z defines z coordinate
  25149. * @returns the face index if found (or null instead)
  25150. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25151. */
  25152. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25153. /**
  25154. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25155. * @returns the parameters
  25156. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25157. */
  25158. getFacetDataParameters(): any;
  25159. /**
  25160. * Disables the feature FacetData and frees the related memory
  25161. * @returns the current mesh
  25162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25163. */
  25164. disableFacetData(): AbstractMesh;
  25165. /**
  25166. * Updates the AbstractMesh indices array
  25167. * @param indices defines the data source
  25168. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25169. * @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)
  25170. * @returns the current mesh
  25171. */
  25172. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25173. /**
  25174. * Creates new normals data for the mesh
  25175. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25176. * @returns the current mesh
  25177. */
  25178. createNormals(updatable: boolean): AbstractMesh;
  25179. /**
  25180. * Align the mesh with a normal
  25181. * @param normal defines the normal to use
  25182. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25183. * @returns the current mesh
  25184. */
  25185. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25186. /** @hidden */
  25187. _checkOcclusionQuery(): boolean;
  25188. }
  25189. }
  25190. declare module "babylonjs/Actions/actionEvent" {
  25191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25192. import { Nullable } from "babylonjs/types";
  25193. import { Sprite } from "babylonjs/Sprites/sprite";
  25194. import { Scene } from "babylonjs/scene";
  25195. import { Vector2 } from "babylonjs/Maths/math";
  25196. /**
  25197. * Interface used to define ActionEvent
  25198. */
  25199. export interface IActionEvent {
  25200. /** The mesh or sprite that triggered the action */
  25201. source: any;
  25202. /** The X mouse cursor position at the time of the event */
  25203. pointerX: number;
  25204. /** The Y mouse cursor position at the time of the event */
  25205. pointerY: number;
  25206. /** The mesh that is currently pointed at (can be null) */
  25207. meshUnderPointer: Nullable<AbstractMesh>;
  25208. /** the original (browser) event that triggered the ActionEvent */
  25209. sourceEvent?: any;
  25210. /** additional data for the event */
  25211. additionalData?: any;
  25212. }
  25213. /**
  25214. * ActionEvent is the event being sent when an action is triggered.
  25215. */
  25216. export class ActionEvent implements IActionEvent {
  25217. /** The mesh or sprite that triggered the action */
  25218. source: any;
  25219. /** The X mouse cursor position at the time of the event */
  25220. pointerX: number;
  25221. /** The Y mouse cursor position at the time of the event */
  25222. pointerY: number;
  25223. /** The mesh that is currently pointed at (can be null) */
  25224. meshUnderPointer: Nullable<AbstractMesh>;
  25225. /** the original (browser) event that triggered the ActionEvent */
  25226. sourceEvent?: any;
  25227. /** additional data for the event */
  25228. additionalData?: any;
  25229. /**
  25230. * Creates a new ActionEvent
  25231. * @param source The mesh or sprite that triggered the action
  25232. * @param pointerX The X mouse cursor position at the time of the event
  25233. * @param pointerY The Y mouse cursor position at the time of the event
  25234. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25235. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25236. * @param additionalData additional data for the event
  25237. */
  25238. constructor(
  25239. /** The mesh or sprite that triggered the action */
  25240. source: any,
  25241. /** The X mouse cursor position at the time of the event */
  25242. pointerX: number,
  25243. /** The Y mouse cursor position at the time of the event */
  25244. pointerY: number,
  25245. /** The mesh that is currently pointed at (can be null) */
  25246. meshUnderPointer: Nullable<AbstractMesh>,
  25247. /** the original (browser) event that triggered the ActionEvent */
  25248. sourceEvent?: any,
  25249. /** additional data for the event */
  25250. additionalData?: any);
  25251. /**
  25252. * Helper function to auto-create an ActionEvent from a source mesh.
  25253. * @param source The source mesh that triggered the event
  25254. * @param evt The original (browser) event
  25255. * @param additionalData additional data for the event
  25256. * @returns the new ActionEvent
  25257. */
  25258. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25259. /**
  25260. * Helper function to auto-create an ActionEvent from a source sprite
  25261. * @param source The source sprite that triggered the event
  25262. * @param scene Scene associated with the sprite
  25263. * @param evt The original (browser) event
  25264. * @param additionalData additional data for the event
  25265. * @returns the new ActionEvent
  25266. */
  25267. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25268. /**
  25269. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25270. * @param scene the scene where the event occurred
  25271. * @param evt The original (browser) event
  25272. * @returns the new ActionEvent
  25273. */
  25274. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25275. /**
  25276. * Helper function to auto-create an ActionEvent from a primitive
  25277. * @param prim defines the target primitive
  25278. * @param pointerPos defines the pointer position
  25279. * @param evt The original (browser) event
  25280. * @param additionalData additional data for the event
  25281. * @returns the new ActionEvent
  25282. */
  25283. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25284. }
  25285. }
  25286. declare module "babylonjs/Actions/abstractActionManager" {
  25287. import { IDisposable } from "babylonjs/scene";
  25288. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25289. import { IAction } from "babylonjs/Actions/action";
  25290. import { Nullable } from "babylonjs/types";
  25291. /**
  25292. * Abstract class used to decouple action Manager from scene and meshes.
  25293. * Do not instantiate.
  25294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25295. */
  25296. export abstract class AbstractActionManager implements IDisposable {
  25297. /** Gets the list of active triggers */
  25298. static Triggers: {
  25299. [key: string]: number;
  25300. };
  25301. /** Gets the cursor to use when hovering items */
  25302. hoverCursor: string;
  25303. /** Gets the list of actions */
  25304. actions: IAction[];
  25305. /**
  25306. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25307. */
  25308. isRecursive: boolean;
  25309. /**
  25310. * Releases all associated resources
  25311. */
  25312. abstract dispose(): void;
  25313. /**
  25314. * Does this action manager has pointer triggers
  25315. */
  25316. abstract readonly hasPointerTriggers: boolean;
  25317. /**
  25318. * Does this action manager has pick triggers
  25319. */
  25320. abstract readonly hasPickTriggers: boolean;
  25321. /**
  25322. * Process a specific trigger
  25323. * @param trigger defines the trigger to process
  25324. * @param evt defines the event details to be processed
  25325. */
  25326. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25327. /**
  25328. * Does this action manager handles actions of any of the given triggers
  25329. * @param triggers defines the triggers to be tested
  25330. * @return a boolean indicating whether one (or more) of the triggers is handled
  25331. */
  25332. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25333. /**
  25334. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25335. * speed.
  25336. * @param triggerA defines the trigger to be tested
  25337. * @param triggerB defines the trigger to be tested
  25338. * @return a boolean indicating whether one (or more) of the triggers is handled
  25339. */
  25340. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25341. /**
  25342. * Does this action manager handles actions of a given trigger
  25343. * @param trigger defines the trigger to be tested
  25344. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25345. * @return whether the trigger is handled
  25346. */
  25347. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25348. /**
  25349. * Serialize this manager to a JSON object
  25350. * @param name defines the property name to store this manager
  25351. * @returns a JSON representation of this manager
  25352. */
  25353. abstract serialize(name: string): any;
  25354. /**
  25355. * Registers an action to this action manager
  25356. * @param action defines the action to be registered
  25357. * @return the action amended (prepared) after registration
  25358. */
  25359. abstract registerAction(action: IAction): Nullable<IAction>;
  25360. /**
  25361. * Unregisters an action to this action manager
  25362. * @param action defines the action to be unregistered
  25363. * @return a boolean indicating whether the action has been unregistered
  25364. */
  25365. abstract unregisterAction(action: IAction): Boolean;
  25366. /**
  25367. * Does exist one action manager with at least one trigger
  25368. **/
  25369. static readonly HasTriggers: boolean;
  25370. /**
  25371. * Does exist one action manager with at least one pick trigger
  25372. **/
  25373. static readonly HasPickTriggers: boolean;
  25374. /**
  25375. * Does exist one action manager that handles actions of a given trigger
  25376. * @param trigger defines the trigger to be tested
  25377. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25378. **/
  25379. static HasSpecificTrigger(trigger: number): boolean;
  25380. }
  25381. }
  25382. declare module "babylonjs/node" {
  25383. import { Scene } from "babylonjs/scene";
  25384. import { Nullable } from "babylonjs/types";
  25385. import { Matrix } from "babylonjs/Maths/math";
  25386. import { Engine } from "babylonjs/Engines/engine";
  25387. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25388. import { Observable } from "babylonjs/Misc/observable";
  25389. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25390. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25391. import { Animatable } from "babylonjs/Animations/animatable";
  25392. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25393. import { Animation } from "babylonjs/Animations/animation";
  25394. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25396. /**
  25397. * Defines how a node can be built from a string name.
  25398. */
  25399. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25400. /**
  25401. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25402. */
  25403. export class Node implements IBehaviorAware<Node> {
  25404. /** @hidden */
  25405. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25406. private static _NodeConstructors;
  25407. /**
  25408. * Add a new node constructor
  25409. * @param type defines the type name of the node to construct
  25410. * @param constructorFunc defines the constructor function
  25411. */
  25412. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25413. /**
  25414. * Returns a node constructor based on type name
  25415. * @param type defines the type name
  25416. * @param name defines the new node name
  25417. * @param scene defines the hosting scene
  25418. * @param options defines optional options to transmit to constructors
  25419. * @returns the new constructor or null
  25420. */
  25421. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25422. /**
  25423. * Gets or sets the name of the node
  25424. */
  25425. name: string;
  25426. /**
  25427. * Gets or sets the id of the node
  25428. */
  25429. id: string;
  25430. /**
  25431. * Gets or sets the unique id of the node
  25432. */
  25433. uniqueId: number;
  25434. /**
  25435. * Gets or sets a string used to store user defined state for the node
  25436. */
  25437. state: string;
  25438. /**
  25439. * Gets or sets an object used to store user defined information for the node
  25440. */
  25441. metadata: any;
  25442. /**
  25443. * For internal use only. Please do not use.
  25444. */
  25445. reservedDataStore: any;
  25446. /**
  25447. * List of inspectable custom properties (used by the Inspector)
  25448. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25449. */
  25450. inspectableCustomProperties: IInspectable[];
  25451. /**
  25452. * Gets or sets a boolean used to define if the node must be serialized
  25453. */
  25454. doNotSerialize: boolean;
  25455. /** @hidden */
  25456. _isDisposed: boolean;
  25457. /**
  25458. * Gets a list of Animations associated with the node
  25459. */
  25460. animations: import("babylonjs/Animations/animation").Animation[];
  25461. protected _ranges: {
  25462. [name: string]: Nullable<AnimationRange>;
  25463. };
  25464. /**
  25465. * Callback raised when the node is ready to be used
  25466. */
  25467. onReady: (node: Node) => void;
  25468. private _isEnabled;
  25469. private _isParentEnabled;
  25470. private _isReady;
  25471. /** @hidden */
  25472. _currentRenderId: number;
  25473. private _parentUpdateId;
  25474. protected _childUpdateId: number;
  25475. /** @hidden */
  25476. _waitingParentId: Nullable<string>;
  25477. /** @hidden */
  25478. _scene: Scene;
  25479. /** @hidden */
  25480. _cache: any;
  25481. private _parentNode;
  25482. private _children;
  25483. /** @hidden */
  25484. _worldMatrix: Matrix;
  25485. /** @hidden */
  25486. _worldMatrixDeterminant: number;
  25487. /** @hidden */
  25488. private _sceneRootNodesIndex;
  25489. /**
  25490. * Gets a boolean indicating if the node has been disposed
  25491. * @returns true if the node was disposed
  25492. */
  25493. isDisposed(): boolean;
  25494. /**
  25495. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25496. * @see https://doc.babylonjs.com/how_to/parenting
  25497. */
  25498. parent: Nullable<Node>;
  25499. private addToSceneRootNodes;
  25500. private removeFromSceneRootNodes;
  25501. private _animationPropertiesOverride;
  25502. /**
  25503. * Gets or sets the animation properties override
  25504. */
  25505. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25506. /**
  25507. * Gets a string idenfifying the name of the class
  25508. * @returns "Node" string
  25509. */
  25510. getClassName(): string;
  25511. /** @hidden */
  25512. readonly _isNode: boolean;
  25513. /**
  25514. * An event triggered when the mesh is disposed
  25515. */
  25516. onDisposeObservable: Observable<Node>;
  25517. private _onDisposeObserver;
  25518. /**
  25519. * Sets a callback that will be raised when the node will be disposed
  25520. */
  25521. onDispose: () => void;
  25522. /**
  25523. * Creates a new Node
  25524. * @param name the name and id to be given to this node
  25525. * @param scene the scene this node will be added to
  25526. * @param addToRootNodes the node will be added to scene.rootNodes
  25527. */
  25528. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25529. /**
  25530. * Gets the scene of the node
  25531. * @returns a scene
  25532. */
  25533. getScene(): Scene;
  25534. /**
  25535. * Gets the engine of the node
  25536. * @returns a Engine
  25537. */
  25538. getEngine(): Engine;
  25539. private _behaviors;
  25540. /**
  25541. * Attach a behavior to the node
  25542. * @see http://doc.babylonjs.com/features/behaviour
  25543. * @param behavior defines the behavior to attach
  25544. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25545. * @returns the current Node
  25546. */
  25547. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25548. /**
  25549. * Remove an attached behavior
  25550. * @see http://doc.babylonjs.com/features/behaviour
  25551. * @param behavior defines the behavior to attach
  25552. * @returns the current Node
  25553. */
  25554. removeBehavior(behavior: Behavior<Node>): Node;
  25555. /**
  25556. * Gets the list of attached behaviors
  25557. * @see http://doc.babylonjs.com/features/behaviour
  25558. */
  25559. readonly behaviors: Behavior<Node>[];
  25560. /**
  25561. * Gets an attached behavior by name
  25562. * @param name defines the name of the behavior to look for
  25563. * @see http://doc.babylonjs.com/features/behaviour
  25564. * @returns null if behavior was not found else the requested behavior
  25565. */
  25566. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25567. /**
  25568. * Returns the latest update of the World matrix
  25569. * @returns a Matrix
  25570. */
  25571. getWorldMatrix(): Matrix;
  25572. /** @hidden */
  25573. _getWorldMatrixDeterminant(): number;
  25574. /**
  25575. * Returns directly the latest state of the mesh World matrix.
  25576. * A Matrix is returned.
  25577. */
  25578. readonly worldMatrixFromCache: Matrix;
  25579. /** @hidden */
  25580. _initCache(): void;
  25581. /** @hidden */
  25582. updateCache(force?: boolean): void;
  25583. /** @hidden */
  25584. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25585. /** @hidden */
  25586. _updateCache(ignoreParentClass?: boolean): void;
  25587. /** @hidden */
  25588. _isSynchronized(): boolean;
  25589. /** @hidden */
  25590. _markSyncedWithParent(): void;
  25591. /** @hidden */
  25592. isSynchronizedWithParent(): boolean;
  25593. /** @hidden */
  25594. isSynchronized(): boolean;
  25595. /**
  25596. * Is this node ready to be used/rendered
  25597. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25598. * @return true if the node is ready
  25599. */
  25600. isReady(completeCheck?: boolean): boolean;
  25601. /**
  25602. * Is this node enabled?
  25603. * 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
  25604. * @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
  25605. * @return whether this node (and its parent) is enabled
  25606. */
  25607. isEnabled(checkAncestors?: boolean): boolean;
  25608. /** @hidden */
  25609. protected _syncParentEnabledState(): void;
  25610. /**
  25611. * Set the enabled state of this node
  25612. * @param value defines the new enabled state
  25613. */
  25614. setEnabled(value: boolean): void;
  25615. /**
  25616. * Is this node a descendant of the given node?
  25617. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25618. * @param ancestor defines the parent node to inspect
  25619. * @returns a boolean indicating if this node is a descendant of the given node
  25620. */
  25621. isDescendantOf(ancestor: Node): boolean;
  25622. /** @hidden */
  25623. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25624. /**
  25625. * Will return all nodes that have this node as ascendant
  25626. * @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
  25627. * @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
  25628. * @return all children nodes of all types
  25629. */
  25630. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25631. /**
  25632. * Get all child-meshes of this node
  25633. * @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)
  25634. * @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
  25635. * @returns an array of AbstractMesh
  25636. */
  25637. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25638. /**
  25639. * Get all direct children of this node
  25640. * @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
  25641. * @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)
  25642. * @returns an array of Node
  25643. */
  25644. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25645. /** @hidden */
  25646. _setReady(state: boolean): void;
  25647. /**
  25648. * Get an animation by name
  25649. * @param name defines the name of the animation to look for
  25650. * @returns null if not found else the requested animation
  25651. */
  25652. getAnimationByName(name: string): Nullable<Animation>;
  25653. /**
  25654. * Creates an animation range for this node
  25655. * @param name defines the name of the range
  25656. * @param from defines the starting key
  25657. * @param to defines the end key
  25658. */
  25659. createAnimationRange(name: string, from: number, to: number): void;
  25660. /**
  25661. * Delete a specific animation range
  25662. * @param name defines the name of the range to delete
  25663. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25664. */
  25665. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25666. /**
  25667. * Get an animation range by name
  25668. * @param name defines the name of the animation range to look for
  25669. * @returns null if not found else the requested animation range
  25670. */
  25671. getAnimationRange(name: string): Nullable<AnimationRange>;
  25672. /**
  25673. * Gets the list of all animation ranges defined on this node
  25674. * @returns an array
  25675. */
  25676. getAnimationRanges(): Nullable<AnimationRange>[];
  25677. /**
  25678. * Will start the animation sequence
  25679. * @param name defines the range frames for animation sequence
  25680. * @param loop defines if the animation should loop (false by default)
  25681. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25682. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25683. * @returns the object created for this animation. If range does not exist, it will return null
  25684. */
  25685. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25686. /**
  25687. * Serialize animation ranges into a JSON compatible object
  25688. * @returns serialization object
  25689. */
  25690. serializeAnimationRanges(): any;
  25691. /**
  25692. * Computes the world matrix of the node
  25693. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25694. * @returns the world matrix
  25695. */
  25696. computeWorldMatrix(force?: boolean): Matrix;
  25697. /**
  25698. * Releases resources associated with this node.
  25699. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25700. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25701. */
  25702. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25703. /**
  25704. * Parse animation range data from a serialization object and store them into a given node
  25705. * @param node defines where to store the animation ranges
  25706. * @param parsedNode defines the serialization object to read data from
  25707. * @param scene defines the hosting scene
  25708. */
  25709. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25710. }
  25711. }
  25712. declare module "babylonjs/Animations/animation" {
  25713. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25714. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25715. import { Nullable } from "babylonjs/types";
  25716. import { Scene } from "babylonjs/scene";
  25717. import { IAnimatable } from "babylonjs/Misc/tools";
  25718. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25719. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25720. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25721. import { Node } from "babylonjs/node";
  25722. import { Animatable } from "babylonjs/Animations/animatable";
  25723. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25724. /**
  25725. * Class used to store any kind of animation
  25726. */
  25727. export class Animation {
  25728. /**Name of the animation */
  25729. name: string;
  25730. /**Property to animate */
  25731. targetProperty: string;
  25732. /**The frames per second of the animation */
  25733. framePerSecond: number;
  25734. /**The data type of the animation */
  25735. dataType: number;
  25736. /**The loop mode of the animation */
  25737. loopMode?: number | undefined;
  25738. /**Specifies if blending should be enabled */
  25739. enableBlending?: boolean | undefined;
  25740. /**
  25741. * Use matrix interpolation instead of using direct key value when animating matrices
  25742. */
  25743. static AllowMatricesInterpolation: boolean;
  25744. /**
  25745. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25746. */
  25747. static AllowMatrixDecomposeForInterpolation: boolean;
  25748. /**
  25749. * Stores the key frames of the animation
  25750. */
  25751. private _keys;
  25752. /**
  25753. * Stores the easing function of the animation
  25754. */
  25755. private _easingFunction;
  25756. /**
  25757. * @hidden Internal use only
  25758. */
  25759. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25760. /**
  25761. * The set of event that will be linked to this animation
  25762. */
  25763. private _events;
  25764. /**
  25765. * Stores an array of target property paths
  25766. */
  25767. targetPropertyPath: string[];
  25768. /**
  25769. * Stores the blending speed of the animation
  25770. */
  25771. blendingSpeed: number;
  25772. /**
  25773. * Stores the animation ranges for the animation
  25774. */
  25775. private _ranges;
  25776. /**
  25777. * @hidden Internal use
  25778. */
  25779. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25780. /**
  25781. * Sets up an animation
  25782. * @param property The property to animate
  25783. * @param animationType The animation type to apply
  25784. * @param framePerSecond The frames per second of the animation
  25785. * @param easingFunction The easing function used in the animation
  25786. * @returns The created animation
  25787. */
  25788. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25789. /**
  25790. * Create and start an animation on a node
  25791. * @param name defines the name of the global animation that will be run on all nodes
  25792. * @param node defines the root node where the animation will take place
  25793. * @param targetProperty defines property to animate
  25794. * @param framePerSecond defines the number of frame per second yo use
  25795. * @param totalFrame defines the number of frames in total
  25796. * @param from defines the initial value
  25797. * @param to defines the final value
  25798. * @param loopMode defines which loop mode you want to use (off by default)
  25799. * @param easingFunction defines the easing function to use (linear by default)
  25800. * @param onAnimationEnd defines the callback to call when animation end
  25801. * @returns the animatable created for this animation
  25802. */
  25803. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25804. /**
  25805. * Create and start an animation on a node and its descendants
  25806. * @param name defines the name of the global animation that will be run on all nodes
  25807. * @param node defines the root node where the animation will take place
  25808. * @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
  25809. * @param targetProperty defines property to animate
  25810. * @param framePerSecond defines the number of frame per second to use
  25811. * @param totalFrame defines the number of frames in total
  25812. * @param from defines the initial value
  25813. * @param to defines the final value
  25814. * @param loopMode defines which loop mode you want to use (off by default)
  25815. * @param easingFunction defines the easing function to use (linear by default)
  25816. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25817. * @returns the list of animatables created for all nodes
  25818. * @example https://www.babylonjs-playground.com/#MH0VLI
  25819. */
  25820. 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[]>;
  25821. /**
  25822. * Creates a new animation, merges it with the existing animations and starts it
  25823. * @param name Name of the animation
  25824. * @param node Node which contains the scene that begins the animations
  25825. * @param targetProperty Specifies which property to animate
  25826. * @param framePerSecond The frames per second of the animation
  25827. * @param totalFrame The total number of frames
  25828. * @param from The frame at the beginning of the animation
  25829. * @param to The frame at the end of the animation
  25830. * @param loopMode Specifies the loop mode of the animation
  25831. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25832. * @param onAnimationEnd Callback to run once the animation is complete
  25833. * @returns Nullable animation
  25834. */
  25835. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25836. /**
  25837. * Transition property of an host to the target Value
  25838. * @param property The property to transition
  25839. * @param targetValue The target Value of the property
  25840. * @param host The object where the property to animate belongs
  25841. * @param scene Scene used to run the animation
  25842. * @param frameRate Framerate (in frame/s) to use
  25843. * @param transition The transition type we want to use
  25844. * @param duration The duration of the animation, in milliseconds
  25845. * @param onAnimationEnd Callback trigger at the end of the animation
  25846. * @returns Nullable animation
  25847. */
  25848. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25849. /**
  25850. * Return the array of runtime animations currently using this animation
  25851. */
  25852. readonly runtimeAnimations: RuntimeAnimation[];
  25853. /**
  25854. * Specifies if any of the runtime animations are currently running
  25855. */
  25856. readonly hasRunningRuntimeAnimations: boolean;
  25857. /**
  25858. * Initializes the animation
  25859. * @param name Name of the animation
  25860. * @param targetProperty Property to animate
  25861. * @param framePerSecond The frames per second of the animation
  25862. * @param dataType The data type of the animation
  25863. * @param loopMode The loop mode of the animation
  25864. * @param enableBlending Specifies if blending should be enabled
  25865. */
  25866. constructor(
  25867. /**Name of the animation */
  25868. name: string,
  25869. /**Property to animate */
  25870. targetProperty: string,
  25871. /**The frames per second of the animation */
  25872. framePerSecond: number,
  25873. /**The data type of the animation */
  25874. dataType: number,
  25875. /**The loop mode of the animation */
  25876. loopMode?: number | undefined,
  25877. /**Specifies if blending should be enabled */
  25878. enableBlending?: boolean | undefined);
  25879. /**
  25880. * Converts the animation to a string
  25881. * @param fullDetails support for multiple levels of logging within scene loading
  25882. * @returns String form of the animation
  25883. */
  25884. toString(fullDetails?: boolean): string;
  25885. /**
  25886. * Add an event to this animation
  25887. * @param event Event to add
  25888. */
  25889. addEvent(event: AnimationEvent): void;
  25890. /**
  25891. * Remove all events found at the given frame
  25892. * @param frame The frame to remove events from
  25893. */
  25894. removeEvents(frame: number): void;
  25895. /**
  25896. * Retrieves all the events from the animation
  25897. * @returns Events from the animation
  25898. */
  25899. getEvents(): AnimationEvent[];
  25900. /**
  25901. * Creates an animation range
  25902. * @param name Name of the animation range
  25903. * @param from Starting frame of the animation range
  25904. * @param to Ending frame of the animation
  25905. */
  25906. createRange(name: string, from: number, to: number): void;
  25907. /**
  25908. * Deletes an animation range by name
  25909. * @param name Name of the animation range to delete
  25910. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25911. */
  25912. deleteRange(name: string, deleteFrames?: boolean): void;
  25913. /**
  25914. * Gets the animation range by name, or null if not defined
  25915. * @param name Name of the animation range
  25916. * @returns Nullable animation range
  25917. */
  25918. getRange(name: string): Nullable<AnimationRange>;
  25919. /**
  25920. * Gets the key frames from the animation
  25921. * @returns The key frames of the animation
  25922. */
  25923. getKeys(): Array<IAnimationKey>;
  25924. /**
  25925. * Gets the highest frame rate of the animation
  25926. * @returns Highest frame rate of the animation
  25927. */
  25928. getHighestFrame(): number;
  25929. /**
  25930. * Gets the easing function of the animation
  25931. * @returns Easing function of the animation
  25932. */
  25933. getEasingFunction(): IEasingFunction;
  25934. /**
  25935. * Sets the easing function of the animation
  25936. * @param easingFunction A custom mathematical formula for animation
  25937. */
  25938. setEasingFunction(easingFunction: EasingFunction): void;
  25939. /**
  25940. * Interpolates a scalar linearly
  25941. * @param startValue Start value of the animation curve
  25942. * @param endValue End value of the animation curve
  25943. * @param gradient Scalar amount to interpolate
  25944. * @returns Interpolated scalar value
  25945. */
  25946. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25947. /**
  25948. * Interpolates a scalar cubically
  25949. * @param startValue Start value of the animation curve
  25950. * @param outTangent End tangent of the animation
  25951. * @param endValue End value of the animation curve
  25952. * @param inTangent Start tangent of the animation curve
  25953. * @param gradient Scalar amount to interpolate
  25954. * @returns Interpolated scalar value
  25955. */
  25956. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25957. /**
  25958. * Interpolates a quaternion using a spherical linear interpolation
  25959. * @param startValue Start value of the animation curve
  25960. * @param endValue End value of the animation curve
  25961. * @param gradient Scalar amount to interpolate
  25962. * @returns Interpolated quaternion value
  25963. */
  25964. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25965. /**
  25966. * Interpolates a quaternion cubically
  25967. * @param startValue Start value of the animation curve
  25968. * @param outTangent End tangent of the animation curve
  25969. * @param endValue End value of the animation curve
  25970. * @param inTangent Start tangent of the animation curve
  25971. * @param gradient Scalar amount to interpolate
  25972. * @returns Interpolated quaternion value
  25973. */
  25974. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25975. /**
  25976. * Interpolates a Vector3 linearl
  25977. * @param startValue Start value of the animation curve
  25978. * @param endValue End value of the animation curve
  25979. * @param gradient Scalar amount to interpolate
  25980. * @returns Interpolated scalar value
  25981. */
  25982. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25983. /**
  25984. * Interpolates a Vector3 cubically
  25985. * @param startValue Start value of the animation curve
  25986. * @param outTangent End tangent of the animation
  25987. * @param endValue End value of the animation curve
  25988. * @param inTangent Start tangent of the animation curve
  25989. * @param gradient Scalar amount to interpolate
  25990. * @returns InterpolatedVector3 value
  25991. */
  25992. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25993. /**
  25994. * Interpolates a Vector2 linearly
  25995. * @param startValue Start value of the animation curve
  25996. * @param endValue End value of the animation curve
  25997. * @param gradient Scalar amount to interpolate
  25998. * @returns Interpolated Vector2 value
  25999. */
  26000. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26001. /**
  26002. * Interpolates a Vector2 cubically
  26003. * @param startValue Start value of the animation curve
  26004. * @param outTangent End tangent of the animation
  26005. * @param endValue End value of the animation curve
  26006. * @param inTangent Start tangent of the animation curve
  26007. * @param gradient Scalar amount to interpolate
  26008. * @returns Interpolated Vector2 value
  26009. */
  26010. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26011. /**
  26012. * Interpolates a size linearly
  26013. * @param startValue Start value of the animation curve
  26014. * @param endValue End value of the animation curve
  26015. * @param gradient Scalar amount to interpolate
  26016. * @returns Interpolated Size value
  26017. */
  26018. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26019. /**
  26020. * Interpolates a Color3 linearly
  26021. * @param startValue Start value of the animation curve
  26022. * @param endValue End value of the animation curve
  26023. * @param gradient Scalar amount to interpolate
  26024. * @returns Interpolated Color3 value
  26025. */
  26026. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26027. /**
  26028. * @hidden Internal use only
  26029. */
  26030. _getKeyValue(value: any): any;
  26031. /**
  26032. * @hidden Internal use only
  26033. */
  26034. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26035. /**
  26036. * Defines the function to use to interpolate matrices
  26037. * @param startValue defines the start matrix
  26038. * @param endValue defines the end matrix
  26039. * @param gradient defines the gradient between both matrices
  26040. * @param result defines an optional target matrix where to store the interpolation
  26041. * @returns the interpolated matrix
  26042. */
  26043. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26044. /**
  26045. * Makes a copy of the animation
  26046. * @returns Cloned animation
  26047. */
  26048. clone(): Animation;
  26049. /**
  26050. * Sets the key frames of the animation
  26051. * @param values The animation key frames to set
  26052. */
  26053. setKeys(values: Array<IAnimationKey>): void;
  26054. /**
  26055. * Serializes the animation to an object
  26056. * @returns Serialized object
  26057. */
  26058. serialize(): any;
  26059. /**
  26060. * Float animation type
  26061. */
  26062. private static _ANIMATIONTYPE_FLOAT;
  26063. /**
  26064. * Vector3 animation type
  26065. */
  26066. private static _ANIMATIONTYPE_VECTOR3;
  26067. /**
  26068. * Quaternion animation type
  26069. */
  26070. private static _ANIMATIONTYPE_QUATERNION;
  26071. /**
  26072. * Matrix animation type
  26073. */
  26074. private static _ANIMATIONTYPE_MATRIX;
  26075. /**
  26076. * Color3 animation type
  26077. */
  26078. private static _ANIMATIONTYPE_COLOR3;
  26079. /**
  26080. * Vector2 animation type
  26081. */
  26082. private static _ANIMATIONTYPE_VECTOR2;
  26083. /**
  26084. * Size animation type
  26085. */
  26086. private static _ANIMATIONTYPE_SIZE;
  26087. /**
  26088. * Relative Loop Mode
  26089. */
  26090. private static _ANIMATIONLOOPMODE_RELATIVE;
  26091. /**
  26092. * Cycle Loop Mode
  26093. */
  26094. private static _ANIMATIONLOOPMODE_CYCLE;
  26095. /**
  26096. * Constant Loop Mode
  26097. */
  26098. private static _ANIMATIONLOOPMODE_CONSTANT;
  26099. /**
  26100. * Get the float animation type
  26101. */
  26102. static readonly ANIMATIONTYPE_FLOAT: number;
  26103. /**
  26104. * Get the Vector3 animation type
  26105. */
  26106. static readonly ANIMATIONTYPE_VECTOR3: number;
  26107. /**
  26108. * Get the Vector2 animation type
  26109. */
  26110. static readonly ANIMATIONTYPE_VECTOR2: number;
  26111. /**
  26112. * Get the Size animation type
  26113. */
  26114. static readonly ANIMATIONTYPE_SIZE: number;
  26115. /**
  26116. * Get the Quaternion animation type
  26117. */
  26118. static readonly ANIMATIONTYPE_QUATERNION: number;
  26119. /**
  26120. * Get the Matrix animation type
  26121. */
  26122. static readonly ANIMATIONTYPE_MATRIX: number;
  26123. /**
  26124. * Get the Color3 animation type
  26125. */
  26126. static readonly ANIMATIONTYPE_COLOR3: number;
  26127. /**
  26128. * Get the Relative Loop Mode
  26129. */
  26130. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26131. /**
  26132. * Get the Cycle Loop Mode
  26133. */
  26134. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26135. /**
  26136. * Get the Constant Loop Mode
  26137. */
  26138. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26139. /** @hidden */
  26140. static _UniversalLerp(left: any, right: any, amount: number): any;
  26141. /**
  26142. * Parses an animation object and creates an animation
  26143. * @param parsedAnimation Parsed animation object
  26144. * @returns Animation object
  26145. */
  26146. static Parse(parsedAnimation: any): Animation;
  26147. /**
  26148. * Appends the serialized animations from the source animations
  26149. * @param source Source containing the animations
  26150. * @param destination Target to store the animations
  26151. */
  26152. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26153. }
  26154. }
  26155. declare module "babylonjs/Materials/Textures/baseTexture" {
  26156. import { Observable } from "babylonjs/Misc/observable";
  26157. import { IAnimatable } from "babylonjs/Misc/tools";
  26158. import { Nullable } from "babylonjs/types";
  26159. import { Scene } from "babylonjs/scene";
  26160. import { Matrix, ISize } from "babylonjs/Maths/math";
  26161. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26162. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26163. /**
  26164. * Base class of all the textures in babylon.
  26165. * It groups all the common properties the materials, post process, lights... might need
  26166. * in order to make a correct use of the texture.
  26167. */
  26168. export class BaseTexture implements IAnimatable {
  26169. /**
  26170. * Default anisotropic filtering level for the application.
  26171. * It is set to 4 as a good tradeoff between perf and quality.
  26172. */
  26173. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26174. /**
  26175. * Gets or sets the unique id of the texture
  26176. */
  26177. uniqueId: number;
  26178. /**
  26179. * Define the name of the texture.
  26180. */
  26181. name: string;
  26182. /**
  26183. * Gets or sets an object used to store user defined information.
  26184. */
  26185. metadata: any;
  26186. /**
  26187. * For internal use only. Please do not use.
  26188. */
  26189. reservedDataStore: any;
  26190. private _hasAlpha;
  26191. /**
  26192. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26193. */
  26194. hasAlpha: boolean;
  26195. /**
  26196. * Defines if the alpha value should be determined via the rgb values.
  26197. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26198. */
  26199. getAlphaFromRGB: boolean;
  26200. /**
  26201. * Intensity or strength of the texture.
  26202. * It is commonly used by materials to fine tune the intensity of the texture
  26203. */
  26204. level: number;
  26205. /**
  26206. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26207. * This is part of the texture as textures usually maps to one uv set.
  26208. */
  26209. coordinatesIndex: number;
  26210. private _coordinatesMode;
  26211. /**
  26212. * How a texture is mapped.
  26213. *
  26214. * | Value | Type | Description |
  26215. * | ----- | ----------------------------------- | ----------- |
  26216. * | 0 | EXPLICIT_MODE | |
  26217. * | 1 | SPHERICAL_MODE | |
  26218. * | 2 | PLANAR_MODE | |
  26219. * | 3 | CUBIC_MODE | |
  26220. * | 4 | PROJECTION_MODE | |
  26221. * | 5 | SKYBOX_MODE | |
  26222. * | 6 | INVCUBIC_MODE | |
  26223. * | 7 | EQUIRECTANGULAR_MODE | |
  26224. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26225. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26226. */
  26227. coordinatesMode: number;
  26228. /**
  26229. * | Value | Type | Description |
  26230. * | ----- | ------------------ | ----------- |
  26231. * | 0 | CLAMP_ADDRESSMODE | |
  26232. * | 1 | WRAP_ADDRESSMODE | |
  26233. * | 2 | MIRROR_ADDRESSMODE | |
  26234. */
  26235. wrapU: number;
  26236. /**
  26237. * | Value | Type | Description |
  26238. * | ----- | ------------------ | ----------- |
  26239. * | 0 | CLAMP_ADDRESSMODE | |
  26240. * | 1 | WRAP_ADDRESSMODE | |
  26241. * | 2 | MIRROR_ADDRESSMODE | |
  26242. */
  26243. wrapV: number;
  26244. /**
  26245. * | Value | Type | Description |
  26246. * | ----- | ------------------ | ----------- |
  26247. * | 0 | CLAMP_ADDRESSMODE | |
  26248. * | 1 | WRAP_ADDRESSMODE | |
  26249. * | 2 | MIRROR_ADDRESSMODE | |
  26250. */
  26251. wrapR: number;
  26252. /**
  26253. * With compliant hardware and browser (supporting anisotropic filtering)
  26254. * this defines the level of anisotropic filtering in the texture.
  26255. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26256. */
  26257. anisotropicFilteringLevel: number;
  26258. /**
  26259. * Define if the texture is a cube texture or if false a 2d texture.
  26260. */
  26261. isCube: boolean;
  26262. /**
  26263. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26264. */
  26265. is3D: boolean;
  26266. /**
  26267. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26268. * HDR texture are usually stored in linear space.
  26269. * This only impacts the PBR and Background materials
  26270. */
  26271. gammaSpace: boolean;
  26272. /**
  26273. * Gets whether or not the texture contains RGBD data.
  26274. */
  26275. readonly isRGBD: boolean;
  26276. /**
  26277. * Is Z inverted in the texture (useful in a cube texture).
  26278. */
  26279. invertZ: boolean;
  26280. /**
  26281. * Are mip maps generated for this texture or not.
  26282. */
  26283. readonly noMipmap: boolean;
  26284. /**
  26285. * @hidden
  26286. */
  26287. lodLevelInAlpha: boolean;
  26288. /**
  26289. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26290. */
  26291. lodGenerationOffset: number;
  26292. /**
  26293. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26294. */
  26295. lodGenerationScale: number;
  26296. /**
  26297. * Define if the texture is a render target.
  26298. */
  26299. isRenderTarget: boolean;
  26300. /**
  26301. * Define the unique id of the texture in the scene.
  26302. */
  26303. readonly uid: string;
  26304. /**
  26305. * Return a string representation of the texture.
  26306. * @returns the texture as a string
  26307. */
  26308. toString(): string;
  26309. /**
  26310. * Get the class name of the texture.
  26311. * @returns "BaseTexture"
  26312. */
  26313. getClassName(): string;
  26314. /**
  26315. * Define the list of animation attached to the texture.
  26316. */
  26317. animations: import("babylonjs/Animations/animation").Animation[];
  26318. /**
  26319. * An event triggered when the texture is disposed.
  26320. */
  26321. onDisposeObservable: Observable<BaseTexture>;
  26322. private _onDisposeObserver;
  26323. /**
  26324. * Callback triggered when the texture has been disposed.
  26325. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26326. */
  26327. onDispose: () => void;
  26328. /**
  26329. * Define the current state of the loading sequence when in delayed load mode.
  26330. */
  26331. delayLoadState: number;
  26332. private _scene;
  26333. /** @hidden */
  26334. _texture: Nullable<InternalTexture>;
  26335. private _uid;
  26336. /**
  26337. * Define if the texture is preventinga material to render or not.
  26338. * If not and the texture is not ready, the engine will use a default black texture instead.
  26339. */
  26340. readonly isBlocking: boolean;
  26341. /**
  26342. * Instantiates a new BaseTexture.
  26343. * Base class of all the textures in babylon.
  26344. * It groups all the common properties the materials, post process, lights... might need
  26345. * in order to make a correct use of the texture.
  26346. * @param scene Define the scene the texture blongs to
  26347. */
  26348. constructor(scene: Nullable<Scene>);
  26349. /**
  26350. * Get the scene the texture belongs to.
  26351. * @returns the scene or null if undefined
  26352. */
  26353. getScene(): Nullable<Scene>;
  26354. /**
  26355. * Get the texture transform matrix used to offset tile the texture for istance.
  26356. * @returns the transformation matrix
  26357. */
  26358. getTextureMatrix(): Matrix;
  26359. /**
  26360. * Get the texture reflection matrix used to rotate/transform the reflection.
  26361. * @returns the reflection matrix
  26362. */
  26363. getReflectionTextureMatrix(): Matrix;
  26364. /**
  26365. * Get the underlying lower level texture from Babylon.
  26366. * @returns the insternal texture
  26367. */
  26368. getInternalTexture(): Nullable<InternalTexture>;
  26369. /**
  26370. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26371. * @returns true if ready or not blocking
  26372. */
  26373. isReadyOrNotBlocking(): boolean;
  26374. /**
  26375. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26376. * @returns true if fully ready
  26377. */
  26378. isReady(): boolean;
  26379. private _cachedSize;
  26380. /**
  26381. * Get the size of the texture.
  26382. * @returns the texture size.
  26383. */
  26384. getSize(): ISize;
  26385. /**
  26386. * Get the base size of the texture.
  26387. * It can be different from the size if the texture has been resized for POT for instance
  26388. * @returns the base size
  26389. */
  26390. getBaseSize(): ISize;
  26391. /**
  26392. * Update the sampling mode of the texture.
  26393. * Default is Trilinear mode.
  26394. *
  26395. * | Value | Type | Description |
  26396. * | ----- | ------------------ | ----------- |
  26397. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26398. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26399. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26400. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26401. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26402. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26403. * | 7 | NEAREST_LINEAR | |
  26404. * | 8 | NEAREST_NEAREST | |
  26405. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26406. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26407. * | 11 | LINEAR_LINEAR | |
  26408. * | 12 | LINEAR_NEAREST | |
  26409. *
  26410. * > _mag_: magnification filter (close to the viewer)
  26411. * > _min_: minification filter (far from the viewer)
  26412. * > _mip_: filter used between mip map levels
  26413. *@param samplingMode Define the new sampling mode of the texture
  26414. */
  26415. updateSamplingMode(samplingMode: number): void;
  26416. /**
  26417. * Scales the texture if is `canRescale()`
  26418. * @param ratio the resize factor we want to use to rescale
  26419. */
  26420. scale(ratio: number): void;
  26421. /**
  26422. * Get if the texture can rescale.
  26423. */
  26424. readonly canRescale: boolean;
  26425. /** @hidden */
  26426. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26427. /** @hidden */
  26428. _rebuild(): void;
  26429. /**
  26430. * Triggers the load sequence in delayed load mode.
  26431. */
  26432. delayLoad(): void;
  26433. /**
  26434. * Clones the texture.
  26435. * @returns the cloned texture
  26436. */
  26437. clone(): Nullable<BaseTexture>;
  26438. /**
  26439. * Get the texture underlying type (INT, FLOAT...)
  26440. */
  26441. readonly textureType: number;
  26442. /**
  26443. * Get the texture underlying format (RGB, RGBA...)
  26444. */
  26445. readonly textureFormat: number;
  26446. /**
  26447. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26448. * This will returns an RGBA array buffer containing either in values (0-255) or
  26449. * float values (0-1) depending of the underlying buffer type.
  26450. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26451. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26452. * @param buffer defines a user defined buffer to fill with data (can be null)
  26453. * @returns The Array buffer containing the pixels data.
  26454. */
  26455. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26456. /**
  26457. * Release and destroy the underlying lower level texture aka internalTexture.
  26458. */
  26459. releaseInternalTexture(): void;
  26460. /**
  26461. * Get the polynomial representation of the texture data.
  26462. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26463. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26464. */
  26465. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26466. /** @hidden */
  26467. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26468. /** @hidden */
  26469. readonly _lodTextureMid: Nullable<BaseTexture>;
  26470. /** @hidden */
  26471. readonly _lodTextureLow: Nullable<BaseTexture>;
  26472. /**
  26473. * Dispose the texture and release its associated resources.
  26474. */
  26475. dispose(): void;
  26476. /**
  26477. * Serialize the texture into a JSON representation that can be parsed later on.
  26478. * @returns the JSON representation of the texture
  26479. */
  26480. serialize(): any;
  26481. /**
  26482. * Helper function to be called back once a list of texture contains only ready textures.
  26483. * @param textures Define the list of textures to wait for
  26484. * @param callback Define the callback triggered once the entire list will be ready
  26485. */
  26486. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26487. }
  26488. }
  26489. declare module "babylonjs/Materials/uniformBuffer" {
  26490. import { Nullable, FloatArray } from "babylonjs/types";
  26491. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26492. import { Engine } from "babylonjs/Engines/engine";
  26493. import { Effect } from "babylonjs/Materials/effect";
  26494. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26495. /**
  26496. * Uniform buffer objects.
  26497. *
  26498. * Handles blocks of uniform on the GPU.
  26499. *
  26500. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26501. *
  26502. * For more information, please refer to :
  26503. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26504. */
  26505. export class UniformBuffer {
  26506. private _engine;
  26507. private _buffer;
  26508. private _data;
  26509. private _bufferData;
  26510. private _dynamic?;
  26511. private _uniformLocations;
  26512. private _uniformSizes;
  26513. private _uniformLocationPointer;
  26514. private _needSync;
  26515. private _noUBO;
  26516. private _currentEffect;
  26517. private static _MAX_UNIFORM_SIZE;
  26518. private static _tempBuffer;
  26519. /**
  26520. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26521. * This is dynamic to allow compat with webgl 1 and 2.
  26522. * You will need to pass the name of the uniform as well as the value.
  26523. */
  26524. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26525. /**
  26526. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26527. * This is dynamic to allow compat with webgl 1 and 2.
  26528. * You will need to pass the name of the uniform as well as the value.
  26529. */
  26530. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26531. /**
  26532. * Lambda to Update a single float in a uniform buffer.
  26533. * This is dynamic to allow compat with webgl 1 and 2.
  26534. * You will need to pass the name of the uniform as well as the value.
  26535. */
  26536. updateFloat: (name: string, x: number) => void;
  26537. /**
  26538. * Lambda to Update a vec2 of float in a uniform buffer.
  26539. * This is dynamic to allow compat with webgl 1 and 2.
  26540. * You will need to pass the name of the uniform as well as the value.
  26541. */
  26542. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26543. /**
  26544. * Lambda to Update a vec3 of float in a uniform buffer.
  26545. * This is dynamic to allow compat with webgl 1 and 2.
  26546. * You will need to pass the name of the uniform as well as the value.
  26547. */
  26548. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26549. /**
  26550. * Lambda to Update a vec4 of float in a uniform buffer.
  26551. * This is dynamic to allow compat with webgl 1 and 2.
  26552. * You will need to pass the name of the uniform as well as the value.
  26553. */
  26554. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26555. /**
  26556. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26557. * This is dynamic to allow compat with webgl 1 and 2.
  26558. * You will need to pass the name of the uniform as well as the value.
  26559. */
  26560. updateMatrix: (name: string, mat: Matrix) => void;
  26561. /**
  26562. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26563. * This is dynamic to allow compat with webgl 1 and 2.
  26564. * You will need to pass the name of the uniform as well as the value.
  26565. */
  26566. updateVector3: (name: string, vector: Vector3) => void;
  26567. /**
  26568. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26569. * This is dynamic to allow compat with webgl 1 and 2.
  26570. * You will need to pass the name of the uniform as well as the value.
  26571. */
  26572. updateVector4: (name: string, vector: Vector4) => void;
  26573. /**
  26574. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26575. * This is dynamic to allow compat with webgl 1 and 2.
  26576. * You will need to pass the name of the uniform as well as the value.
  26577. */
  26578. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26579. /**
  26580. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26581. * This is dynamic to allow compat with webgl 1 and 2.
  26582. * You will need to pass the name of the uniform as well as the value.
  26583. */
  26584. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26585. /**
  26586. * Instantiates a new Uniform buffer objects.
  26587. *
  26588. * Handles blocks of uniform on the GPU.
  26589. *
  26590. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26591. *
  26592. * For more information, please refer to :
  26593. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26594. * @param engine Define the engine the buffer is associated with
  26595. * @param data Define the data contained in the buffer
  26596. * @param dynamic Define if the buffer is updatable
  26597. */
  26598. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26599. /**
  26600. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26601. * or just falling back on setUniformXXX calls.
  26602. */
  26603. readonly useUbo: boolean;
  26604. /**
  26605. * Indicates if the WebGL underlying uniform buffer is in sync
  26606. * with the javascript cache data.
  26607. */
  26608. readonly isSync: boolean;
  26609. /**
  26610. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26611. * Also, a dynamic UniformBuffer will disable cache verification and always
  26612. * update the underlying WebGL uniform buffer to the GPU.
  26613. * @returns if Dynamic, otherwise false
  26614. */
  26615. isDynamic(): boolean;
  26616. /**
  26617. * The data cache on JS side.
  26618. * @returns the underlying data as a float array
  26619. */
  26620. getData(): Float32Array;
  26621. /**
  26622. * The underlying WebGL Uniform buffer.
  26623. * @returns the webgl buffer
  26624. */
  26625. getBuffer(): Nullable<WebGLBuffer>;
  26626. /**
  26627. * std140 layout specifies how to align data within an UBO structure.
  26628. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26629. * for specs.
  26630. */
  26631. private _fillAlignment;
  26632. /**
  26633. * Adds an uniform in the buffer.
  26634. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26635. * for the layout to be correct !
  26636. * @param name Name of the uniform, as used in the uniform block in the shader.
  26637. * @param size Data size, or data directly.
  26638. */
  26639. addUniform(name: string, size: number | number[]): void;
  26640. /**
  26641. * Adds a Matrix 4x4 to the uniform buffer.
  26642. * @param name Name of the uniform, as used in the uniform block in the shader.
  26643. * @param mat A 4x4 matrix.
  26644. */
  26645. addMatrix(name: string, mat: Matrix): void;
  26646. /**
  26647. * Adds a vec2 to the uniform buffer.
  26648. * @param name Name of the uniform, as used in the uniform block in the shader.
  26649. * @param x Define the x component value of the vec2
  26650. * @param y Define the y component value of the vec2
  26651. */
  26652. addFloat2(name: string, x: number, y: number): void;
  26653. /**
  26654. * Adds a vec3 to the uniform buffer.
  26655. * @param name Name of the uniform, as used in the uniform block in the shader.
  26656. * @param x Define the x component value of the vec3
  26657. * @param y Define the y component value of the vec3
  26658. * @param z Define the z component value of the vec3
  26659. */
  26660. addFloat3(name: string, x: number, y: number, z: number): void;
  26661. /**
  26662. * Adds a vec3 to the uniform buffer.
  26663. * @param name Name of the uniform, as used in the uniform block in the shader.
  26664. * @param color Define the vec3 from a Color
  26665. */
  26666. addColor3(name: string, color: Color3): void;
  26667. /**
  26668. * Adds a vec4 to the uniform buffer.
  26669. * @param name Name of the uniform, as used in the uniform block in the shader.
  26670. * @param color Define the rgb components from a Color
  26671. * @param alpha Define the a component of the vec4
  26672. */
  26673. addColor4(name: string, color: Color3, alpha: number): void;
  26674. /**
  26675. * Adds a vec3 to the uniform buffer.
  26676. * @param name Name of the uniform, as used in the uniform block in the shader.
  26677. * @param vector Define the vec3 components from a Vector
  26678. */
  26679. addVector3(name: string, vector: Vector3): void;
  26680. /**
  26681. * Adds a Matrix 3x3 to the uniform buffer.
  26682. * @param name Name of the uniform, as used in the uniform block in the shader.
  26683. */
  26684. addMatrix3x3(name: string): void;
  26685. /**
  26686. * Adds a Matrix 2x2 to the uniform buffer.
  26687. * @param name Name of the uniform, as used in the uniform block in the shader.
  26688. */
  26689. addMatrix2x2(name: string): void;
  26690. /**
  26691. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26692. */
  26693. create(): void;
  26694. /** @hidden */
  26695. _rebuild(): void;
  26696. /**
  26697. * Updates the WebGL Uniform Buffer on the GPU.
  26698. * If the `dynamic` flag is set to true, no cache comparison is done.
  26699. * Otherwise, the buffer will be updated only if the cache differs.
  26700. */
  26701. update(): void;
  26702. /**
  26703. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26704. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26705. * @param data Define the flattened data
  26706. * @param size Define the size of the data.
  26707. */
  26708. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26709. private _updateMatrix3x3ForUniform;
  26710. private _updateMatrix3x3ForEffect;
  26711. private _updateMatrix2x2ForEffect;
  26712. private _updateMatrix2x2ForUniform;
  26713. private _updateFloatForEffect;
  26714. private _updateFloatForUniform;
  26715. private _updateFloat2ForEffect;
  26716. private _updateFloat2ForUniform;
  26717. private _updateFloat3ForEffect;
  26718. private _updateFloat3ForUniform;
  26719. private _updateFloat4ForEffect;
  26720. private _updateFloat4ForUniform;
  26721. private _updateMatrixForEffect;
  26722. private _updateMatrixForUniform;
  26723. private _updateVector3ForEffect;
  26724. private _updateVector3ForUniform;
  26725. private _updateVector4ForEffect;
  26726. private _updateVector4ForUniform;
  26727. private _updateColor3ForEffect;
  26728. private _updateColor3ForUniform;
  26729. private _updateColor4ForEffect;
  26730. private _updateColor4ForUniform;
  26731. /**
  26732. * Sets a sampler uniform on the effect.
  26733. * @param name Define the name of the sampler.
  26734. * @param texture Define the texture to set in the sampler
  26735. */
  26736. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26737. /**
  26738. * Directly updates the value of the uniform in the cache AND on the GPU.
  26739. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26740. * @param data Define the flattened data
  26741. */
  26742. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26743. /**
  26744. * Binds this uniform buffer to an effect.
  26745. * @param effect Define the effect to bind the buffer to
  26746. * @param name Name of the uniform block in the shader.
  26747. */
  26748. bindToEffect(effect: Effect, name: string): void;
  26749. /**
  26750. * Disposes the uniform buffer.
  26751. */
  26752. dispose(): void;
  26753. }
  26754. }
  26755. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26756. import { Nullable } from "babylonjs/types";
  26757. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26758. /**
  26759. * This represents the required contract to create a new type of texture loader.
  26760. */
  26761. export interface IInternalTextureLoader {
  26762. /**
  26763. * Defines wether the loader supports cascade loading the different faces.
  26764. */
  26765. supportCascades: boolean;
  26766. /**
  26767. * This returns if the loader support the current file information.
  26768. * @param extension defines the file extension of the file being loaded
  26769. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26770. * @param fallback defines the fallback internal texture if any
  26771. * @param isBase64 defines whether the texture is encoded as a base64
  26772. * @param isBuffer defines whether the texture data are stored as a buffer
  26773. * @returns true if the loader can load the specified file
  26774. */
  26775. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26776. /**
  26777. * Transform the url before loading if required.
  26778. * @param rootUrl the url of the texture
  26779. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26780. * @returns the transformed texture
  26781. */
  26782. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26783. /**
  26784. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26785. * @param rootUrl the url of the texture
  26786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26787. * @returns the fallback texture
  26788. */
  26789. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26790. /**
  26791. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26792. * @param data contains the texture data
  26793. * @param texture defines the BabylonJS internal texture
  26794. * @param createPolynomials will be true if polynomials have been requested
  26795. * @param onLoad defines the callback to trigger once the texture is ready
  26796. * @param onError defines the callback to trigger in case of error
  26797. */
  26798. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26799. /**
  26800. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26801. * @param data contains the texture data
  26802. * @param texture defines the BabylonJS internal texture
  26803. * @param callback defines the method to call once ready to upload
  26804. */
  26805. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26806. }
  26807. }
  26808. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26809. import { Scene } from "babylonjs/scene";
  26810. import { Engine } from "babylonjs/Engines/engine";
  26811. import { Texture } from "babylonjs/Materials/Textures/texture";
  26812. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26813. /**
  26814. * Creation options of the multi render target texture.
  26815. */
  26816. export interface IMultiRenderTargetOptions {
  26817. /**
  26818. * Define if the texture needs to create mip maps after render.
  26819. */
  26820. generateMipMaps?: boolean;
  26821. /**
  26822. * Define the types of all the draw buffers we want to create
  26823. */
  26824. types?: number[];
  26825. /**
  26826. * Define the sampling modes of all the draw buffers we want to create
  26827. */
  26828. samplingModes?: number[];
  26829. /**
  26830. * Define if a depth buffer is required
  26831. */
  26832. generateDepthBuffer?: boolean;
  26833. /**
  26834. * Define if a stencil buffer is required
  26835. */
  26836. generateStencilBuffer?: boolean;
  26837. /**
  26838. * Define if a depth texture is required instead of a depth buffer
  26839. */
  26840. generateDepthTexture?: boolean;
  26841. /**
  26842. * Define the number of desired draw buffers
  26843. */
  26844. textureCount?: number;
  26845. /**
  26846. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26847. */
  26848. doNotChangeAspectRatio?: boolean;
  26849. /**
  26850. * Define the default type of the buffers we are creating
  26851. */
  26852. defaultType?: number;
  26853. }
  26854. /**
  26855. * A multi render target, like a render target provides the ability to render to a texture.
  26856. * Unlike the render target, it can render to several draw buffers in one draw.
  26857. * This is specially interesting in deferred rendering or for any effects requiring more than
  26858. * just one color from a single pass.
  26859. */
  26860. export class MultiRenderTarget extends RenderTargetTexture {
  26861. private _internalTextures;
  26862. private _textures;
  26863. private _multiRenderTargetOptions;
  26864. /**
  26865. * Get if draw buffers are currently supported by the used hardware and browser.
  26866. */
  26867. readonly isSupported: boolean;
  26868. /**
  26869. * Get the list of textures generated by the multi render target.
  26870. */
  26871. readonly textures: Texture[];
  26872. /**
  26873. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26874. */
  26875. readonly depthTexture: Texture;
  26876. /**
  26877. * Set the wrapping mode on U of all the textures we are rendering to.
  26878. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26879. */
  26880. wrapU: number;
  26881. /**
  26882. * Set the wrapping mode on V of all the textures we are rendering to.
  26883. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26884. */
  26885. wrapV: number;
  26886. /**
  26887. * Instantiate a new multi render target texture.
  26888. * A multi render target, like a render target provides the ability to render to a texture.
  26889. * Unlike the render target, it can render to several draw buffers in one draw.
  26890. * This is specially interesting in deferred rendering or for any effects requiring more than
  26891. * just one color from a single pass.
  26892. * @param name Define the name of the texture
  26893. * @param size Define the size of the buffers to render to
  26894. * @param count Define the number of target we are rendering into
  26895. * @param scene Define the scene the texture belongs to
  26896. * @param options Define the options used to create the multi render target
  26897. */
  26898. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26899. /** @hidden */
  26900. _rebuild(): void;
  26901. private _createInternalTextures;
  26902. private _createTextures;
  26903. /**
  26904. * Define the number of samples used if MSAA is enabled.
  26905. */
  26906. samples: number;
  26907. /**
  26908. * Resize all the textures in the multi render target.
  26909. * Be carrefull as it will recreate all the data in the new texture.
  26910. * @param size Define the new size
  26911. */
  26912. resize(size: any): void;
  26913. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26914. /**
  26915. * Dispose the render targets and their associated resources
  26916. */
  26917. dispose(): void;
  26918. /**
  26919. * Release all the underlying texture used as draw buffers.
  26920. */
  26921. releaseInternalTextures(): void;
  26922. }
  26923. }
  26924. declare module "babylonjs/Audio/analyser" {
  26925. import { Scene } from "babylonjs/scene";
  26926. /**
  26927. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26929. */
  26930. export class Analyser {
  26931. /**
  26932. * Gets or sets the smoothing
  26933. * @ignorenaming
  26934. */
  26935. SMOOTHING: number;
  26936. /**
  26937. * Gets or sets the FFT table size
  26938. * @ignorenaming
  26939. */
  26940. FFT_SIZE: number;
  26941. /**
  26942. * Gets or sets the bar graph amplitude
  26943. * @ignorenaming
  26944. */
  26945. BARGRAPHAMPLITUDE: number;
  26946. /**
  26947. * Gets or sets the position of the debug canvas
  26948. * @ignorenaming
  26949. */
  26950. DEBUGCANVASPOS: {
  26951. x: number;
  26952. y: number;
  26953. };
  26954. /**
  26955. * Gets or sets the debug canvas size
  26956. * @ignorenaming
  26957. */
  26958. DEBUGCANVASSIZE: {
  26959. width: number;
  26960. height: number;
  26961. };
  26962. private _byteFreqs;
  26963. private _byteTime;
  26964. private _floatFreqs;
  26965. private _webAudioAnalyser;
  26966. private _debugCanvas;
  26967. private _debugCanvasContext;
  26968. private _scene;
  26969. private _registerFunc;
  26970. private _audioEngine;
  26971. /**
  26972. * Creates a new analyser
  26973. * @param scene defines hosting scene
  26974. */
  26975. constructor(scene: Scene);
  26976. /**
  26977. * Get the number of data values you will have to play with for the visualization
  26978. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26979. * @returns a number
  26980. */
  26981. getFrequencyBinCount(): number;
  26982. /**
  26983. * Gets the current frequency data as a byte array
  26984. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26985. * @returns a Uint8Array
  26986. */
  26987. getByteFrequencyData(): Uint8Array;
  26988. /**
  26989. * Gets the current waveform as a byte array
  26990. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26991. * @returns a Uint8Array
  26992. */
  26993. getByteTimeDomainData(): Uint8Array;
  26994. /**
  26995. * Gets the current frequency data as a float array
  26996. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26997. * @returns a Float32Array
  26998. */
  26999. getFloatFrequencyData(): Float32Array;
  27000. /**
  27001. * Renders the debug canvas
  27002. */
  27003. drawDebugCanvas(): void;
  27004. /**
  27005. * Stops rendering the debug canvas and removes it
  27006. */
  27007. stopDebugCanvas(): void;
  27008. /**
  27009. * Connects two audio nodes
  27010. * @param inputAudioNode defines first node to connect
  27011. * @param outputAudioNode defines second node to connect
  27012. */
  27013. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27014. /**
  27015. * Releases all associated resources
  27016. */
  27017. dispose(): void;
  27018. }
  27019. }
  27020. declare module "babylonjs/Audio/audioEngine" {
  27021. import { IDisposable } from "babylonjs/scene";
  27022. import { Analyser } from "babylonjs/Audio/analyser";
  27023. import { Nullable } from "babylonjs/types";
  27024. import { Observable } from "babylonjs/Misc/observable";
  27025. /**
  27026. * This represents an audio engine and it is responsible
  27027. * to play, synchronize and analyse sounds throughout the application.
  27028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27029. */
  27030. export interface IAudioEngine extends IDisposable {
  27031. /**
  27032. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27033. */
  27034. readonly canUseWebAudio: boolean;
  27035. /**
  27036. * Gets the current AudioContext if available.
  27037. */
  27038. readonly audioContext: Nullable<AudioContext>;
  27039. /**
  27040. * The master gain node defines the global audio volume of your audio engine.
  27041. */
  27042. readonly masterGain: GainNode;
  27043. /**
  27044. * Gets whether or not mp3 are supported by your browser.
  27045. */
  27046. readonly isMP3supported: boolean;
  27047. /**
  27048. * Gets whether or not ogg are supported by your browser.
  27049. */
  27050. readonly isOGGsupported: boolean;
  27051. /**
  27052. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27053. * @ignoreNaming
  27054. */
  27055. WarnedWebAudioUnsupported: boolean;
  27056. /**
  27057. * Defines if the audio engine relies on a custom unlocked button.
  27058. * In this case, the embedded button will not be displayed.
  27059. */
  27060. useCustomUnlockedButton: boolean;
  27061. /**
  27062. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27063. */
  27064. readonly unlocked: boolean;
  27065. /**
  27066. * Event raised when audio has been unlocked on the browser.
  27067. */
  27068. onAudioUnlockedObservable: Observable<AudioEngine>;
  27069. /**
  27070. * Event raised when audio has been locked on the browser.
  27071. */
  27072. onAudioLockedObservable: Observable<AudioEngine>;
  27073. /**
  27074. * Flags the audio engine in Locked state.
  27075. * This happens due to new browser policies preventing audio to autoplay.
  27076. */
  27077. lock(): void;
  27078. /**
  27079. * Unlocks the audio engine once a user action has been done on the dom.
  27080. * This is helpful to resume play once browser policies have been satisfied.
  27081. */
  27082. unlock(): void;
  27083. }
  27084. /**
  27085. * This represents the default audio engine used in babylon.
  27086. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27088. */
  27089. export class AudioEngine implements IAudioEngine {
  27090. private _audioContext;
  27091. private _audioContextInitialized;
  27092. private _muteButton;
  27093. private _hostElement;
  27094. /**
  27095. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27096. */
  27097. canUseWebAudio: boolean;
  27098. /**
  27099. * The master gain node defines the global audio volume of your audio engine.
  27100. */
  27101. masterGain: GainNode;
  27102. /**
  27103. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27104. * @ignoreNaming
  27105. */
  27106. WarnedWebAudioUnsupported: boolean;
  27107. /**
  27108. * Gets whether or not mp3 are supported by your browser.
  27109. */
  27110. isMP3supported: boolean;
  27111. /**
  27112. * Gets whether or not ogg are supported by your browser.
  27113. */
  27114. isOGGsupported: boolean;
  27115. /**
  27116. * Gets whether audio has been unlocked on the device.
  27117. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27118. * a user interaction has happened.
  27119. */
  27120. unlocked: boolean;
  27121. /**
  27122. * Defines if the audio engine relies on a custom unlocked button.
  27123. * In this case, the embedded button will not be displayed.
  27124. */
  27125. useCustomUnlockedButton: boolean;
  27126. /**
  27127. * Event raised when audio has been unlocked on the browser.
  27128. */
  27129. onAudioUnlockedObservable: Observable<AudioEngine>;
  27130. /**
  27131. * Event raised when audio has been locked on the browser.
  27132. */
  27133. onAudioLockedObservable: Observable<AudioEngine>;
  27134. /**
  27135. * Gets the current AudioContext if available.
  27136. */
  27137. readonly audioContext: Nullable<AudioContext>;
  27138. private _connectedAnalyser;
  27139. /**
  27140. * Instantiates a new audio engine.
  27141. *
  27142. * There should be only one per page as some browsers restrict the number
  27143. * of audio contexts you can create.
  27144. * @param hostElement defines the host element where to display the mute icon if necessary
  27145. */
  27146. constructor(hostElement?: Nullable<HTMLElement>);
  27147. /**
  27148. * Flags the audio engine in Locked state.
  27149. * This happens due to new browser policies preventing audio to autoplay.
  27150. */
  27151. lock(): void;
  27152. /**
  27153. * Unlocks the audio engine once a user action has been done on the dom.
  27154. * This is helpful to resume play once browser policies have been satisfied.
  27155. */
  27156. unlock(): void;
  27157. private _resumeAudioContext;
  27158. private _initializeAudioContext;
  27159. private _tryToRun;
  27160. private _triggerRunningState;
  27161. private _triggerSuspendedState;
  27162. private _displayMuteButton;
  27163. private _moveButtonToTopLeft;
  27164. private _onResize;
  27165. private _hideMuteButton;
  27166. /**
  27167. * Destroy and release the resources associated with the audio ccontext.
  27168. */
  27169. dispose(): void;
  27170. /**
  27171. * Gets the global volume sets on the master gain.
  27172. * @returns the global volume if set or -1 otherwise
  27173. */
  27174. getGlobalVolume(): number;
  27175. /**
  27176. * Sets the global volume of your experience (sets on the master gain).
  27177. * @param newVolume Defines the new global volume of the application
  27178. */
  27179. setGlobalVolume(newVolume: number): void;
  27180. /**
  27181. * Connect the audio engine to an audio analyser allowing some amazing
  27182. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27183. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27184. * @param analyser The analyser to connect to the engine
  27185. */
  27186. connectToAnalyser(analyser: Analyser): void;
  27187. }
  27188. }
  27189. declare module "babylonjs/Loading/loadingScreen" {
  27190. /**
  27191. * Interface used to present a loading screen while loading a scene
  27192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27193. */
  27194. export interface ILoadingScreen {
  27195. /**
  27196. * Function called to display the loading screen
  27197. */
  27198. displayLoadingUI: () => void;
  27199. /**
  27200. * Function called to hide the loading screen
  27201. */
  27202. hideLoadingUI: () => void;
  27203. /**
  27204. * Gets or sets the color to use for the background
  27205. */
  27206. loadingUIBackgroundColor: string;
  27207. /**
  27208. * Gets or sets the text to display while loading
  27209. */
  27210. loadingUIText: string;
  27211. }
  27212. /**
  27213. * Class used for the default loading screen
  27214. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27215. */
  27216. export class DefaultLoadingScreen implements ILoadingScreen {
  27217. private _renderingCanvas;
  27218. private _loadingText;
  27219. private _loadingDivBackgroundColor;
  27220. private _loadingDiv;
  27221. private _loadingTextDiv;
  27222. /**
  27223. * Creates a new default loading screen
  27224. * @param _renderingCanvas defines the canvas used to render the scene
  27225. * @param _loadingText defines the default text to display
  27226. * @param _loadingDivBackgroundColor defines the default background color
  27227. */
  27228. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27229. /**
  27230. * Function called to display the loading screen
  27231. */
  27232. displayLoadingUI(): void;
  27233. /**
  27234. * Function called to hide the loading screen
  27235. */
  27236. hideLoadingUI(): void;
  27237. /**
  27238. * Gets or sets the text to display while loading
  27239. */
  27240. loadingUIText: string;
  27241. /**
  27242. * Gets or sets the color to use for the background
  27243. */
  27244. loadingUIBackgroundColor: string;
  27245. private _resizeLoadingUI;
  27246. }
  27247. }
  27248. declare module "babylonjs/Materials/Textures/videoTexture" {
  27249. import { Observable } from "babylonjs/Misc/observable";
  27250. import { Nullable } from "babylonjs/types";
  27251. import { Scene } from "babylonjs/scene";
  27252. import { Texture } from "babylonjs/Materials/Textures/texture";
  27253. /**
  27254. * Settings for finer control over video usage
  27255. */
  27256. export interface VideoTextureSettings {
  27257. /**
  27258. * Applies `autoplay` to video, if specified
  27259. */
  27260. autoPlay?: boolean;
  27261. /**
  27262. * Applies `loop` to video, if specified
  27263. */
  27264. loop?: boolean;
  27265. /**
  27266. * Automatically updates internal texture from video at every frame in the render loop
  27267. */
  27268. autoUpdateTexture: boolean;
  27269. /**
  27270. * Image src displayed during the video loading or until the user interacts with the video.
  27271. */
  27272. poster?: string;
  27273. }
  27274. /**
  27275. * If you want to display a video in your scene, this is the special texture for that.
  27276. * This special texture works similar to other textures, with the exception of a few parameters.
  27277. * @see https://doc.babylonjs.com/how_to/video_texture
  27278. */
  27279. export class VideoTexture extends Texture {
  27280. /**
  27281. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27282. */
  27283. readonly autoUpdateTexture: boolean;
  27284. /**
  27285. * The video instance used by the texture internally
  27286. */
  27287. readonly video: HTMLVideoElement;
  27288. private _onUserActionRequestedObservable;
  27289. /**
  27290. * Event triggerd when a dom action is required by the user to play the video.
  27291. * This happens due to recent changes in browser policies preventing video to auto start.
  27292. */
  27293. readonly onUserActionRequestedObservable: Observable<Texture>;
  27294. private _generateMipMaps;
  27295. private _engine;
  27296. private _stillImageCaptured;
  27297. private _displayingPosterTexture;
  27298. private _settings;
  27299. private _createInternalTextureOnEvent;
  27300. /**
  27301. * Creates a video texture.
  27302. * If you want to display a video in your scene, this is the special texture for that.
  27303. * This special texture works similar to other textures, with the exception of a few parameters.
  27304. * @see https://doc.babylonjs.com/how_to/video_texture
  27305. * @param name optional name, will detect from video source, if not defined
  27306. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27307. * @param scene is obviously the current scene.
  27308. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27309. * @param invertY is false by default but can be used to invert video on Y axis
  27310. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27311. * @param settings allows finer control over video usage
  27312. */
  27313. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27314. private _getName;
  27315. private _getVideo;
  27316. private _createInternalTexture;
  27317. private reset;
  27318. /**
  27319. * @hidden Internal method to initiate `update`.
  27320. */
  27321. _rebuild(): void;
  27322. /**
  27323. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27324. */
  27325. update(): void;
  27326. /**
  27327. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27328. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27329. */
  27330. updateTexture(isVisible: boolean): void;
  27331. protected _updateInternalTexture: () => void;
  27332. /**
  27333. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27334. * @param url New url.
  27335. */
  27336. updateURL(url: string): void;
  27337. /**
  27338. * Dispose the texture and release its associated resources.
  27339. */
  27340. dispose(): void;
  27341. /**
  27342. * Creates a video texture straight from a stream.
  27343. * @param scene Define the scene the texture should be created in
  27344. * @param stream Define the stream the texture should be created from
  27345. * @returns The created video texture as a promise
  27346. */
  27347. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27348. /**
  27349. * Creates a video texture straight from your WebCam video feed.
  27350. * @param scene Define the scene the texture should be created in
  27351. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27352. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27353. * @returns The created video texture as a promise
  27354. */
  27355. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27356. minWidth: number;
  27357. maxWidth: number;
  27358. minHeight: number;
  27359. maxHeight: number;
  27360. deviceId: string;
  27361. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27362. /**
  27363. * Creates a video texture straight from your WebCam video feed.
  27364. * @param scene Define the scene the texture should be created in
  27365. * @param onReady Define a callback to triggered once the texture will be ready
  27366. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27367. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27368. */
  27369. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27370. minWidth: number;
  27371. maxWidth: number;
  27372. minHeight: number;
  27373. maxHeight: number;
  27374. deviceId: string;
  27375. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27376. }
  27377. }
  27378. declare module "babylonjs/Engines/engine" {
  27379. import { Observable } from "babylonjs/Misc/observable";
  27380. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27381. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27382. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27383. import { Camera } from "babylonjs/Cameras/camera";
  27384. import { Scene } from "babylonjs/scene";
  27385. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27386. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27387. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27388. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27389. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27390. import { Material } from "babylonjs/Materials/material";
  27391. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27392. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27394. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27395. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27396. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27397. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27398. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27399. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27400. import { WebRequest } from "babylonjs/Misc/webRequest";
  27401. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27402. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27403. /**
  27404. * Interface for attribute information associated with buffer instanciation
  27405. */
  27406. export class InstancingAttributeInfo {
  27407. /**
  27408. * Index/offset of the attribute in the vertex shader
  27409. */
  27410. index: number;
  27411. /**
  27412. * size of the attribute, 1, 2, 3 or 4
  27413. */
  27414. attributeSize: number;
  27415. /**
  27416. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27417. * default is FLOAT
  27418. */
  27419. attribyteType: number;
  27420. /**
  27421. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27422. */
  27423. normalized: boolean;
  27424. /**
  27425. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27426. */
  27427. offset: number;
  27428. /**
  27429. * Name of the GLSL attribute, for debugging purpose only
  27430. */
  27431. attributeName: string;
  27432. }
  27433. /**
  27434. * Define options used to create a depth texture
  27435. */
  27436. export class DepthTextureCreationOptions {
  27437. /** Specifies whether or not a stencil should be allocated in the texture */
  27438. generateStencil?: boolean;
  27439. /** Specifies whether or not bilinear filtering is enable on the texture */
  27440. bilinearFiltering?: boolean;
  27441. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27442. comparisonFunction?: number;
  27443. /** Specifies if the created texture is a cube texture */
  27444. isCube?: boolean;
  27445. }
  27446. /**
  27447. * Class used to describe the capabilities of the engine relatively to the current browser
  27448. */
  27449. export class EngineCapabilities {
  27450. /** Maximum textures units per fragment shader */
  27451. maxTexturesImageUnits: number;
  27452. /** Maximum texture units per vertex shader */
  27453. maxVertexTextureImageUnits: number;
  27454. /** Maximum textures units in the entire pipeline */
  27455. maxCombinedTexturesImageUnits: number;
  27456. /** Maximum texture size */
  27457. maxTextureSize: number;
  27458. /** Maximum cube texture size */
  27459. maxCubemapTextureSize: number;
  27460. /** Maximum render texture size */
  27461. maxRenderTextureSize: number;
  27462. /** Maximum number of vertex attributes */
  27463. maxVertexAttribs: number;
  27464. /** Maximum number of varyings */
  27465. maxVaryingVectors: number;
  27466. /** Maximum number of uniforms per vertex shader */
  27467. maxVertexUniformVectors: number;
  27468. /** Maximum number of uniforms per fragment shader */
  27469. maxFragmentUniformVectors: number;
  27470. /** Defines if standard derivates (dx/dy) are supported */
  27471. standardDerivatives: boolean;
  27472. /** Defines if s3tc texture compression is supported */
  27473. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27474. /** Defines if pvrtc texture compression is supported */
  27475. pvrtc: any;
  27476. /** Defines if etc1 texture compression is supported */
  27477. etc1: any;
  27478. /** Defines if etc2 texture compression is supported */
  27479. etc2: any;
  27480. /** Defines if astc texture compression is supported */
  27481. astc: any;
  27482. /** Defines if float textures are supported */
  27483. textureFloat: boolean;
  27484. /** Defines if vertex array objects are supported */
  27485. vertexArrayObject: boolean;
  27486. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27487. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27488. /** Gets the maximum level of anisotropy supported */
  27489. maxAnisotropy: number;
  27490. /** Defines if instancing is supported */
  27491. instancedArrays: boolean;
  27492. /** Defines if 32 bits indices are supported */
  27493. uintIndices: boolean;
  27494. /** Defines if high precision shaders are supported */
  27495. highPrecisionShaderSupported: boolean;
  27496. /** Defines if depth reading in the fragment shader is supported */
  27497. fragmentDepthSupported: boolean;
  27498. /** Defines if float texture linear filtering is supported*/
  27499. textureFloatLinearFiltering: boolean;
  27500. /** Defines if rendering to float textures is supported */
  27501. textureFloatRender: boolean;
  27502. /** Defines if half float textures are supported*/
  27503. textureHalfFloat: boolean;
  27504. /** Defines if half float texture linear filtering is supported*/
  27505. textureHalfFloatLinearFiltering: boolean;
  27506. /** Defines if rendering to half float textures is supported */
  27507. textureHalfFloatRender: boolean;
  27508. /** Defines if textureLOD shader command is supported */
  27509. textureLOD: boolean;
  27510. /** Defines if draw buffers extension is supported */
  27511. drawBuffersExtension: boolean;
  27512. /** Defines if depth textures are supported */
  27513. depthTextureExtension: boolean;
  27514. /** Defines if float color buffer are supported */
  27515. colorBufferFloat: boolean;
  27516. /** Gets disjoint timer query extension (null if not supported) */
  27517. timerQuery: EXT_disjoint_timer_query;
  27518. /** Defines if timestamp can be used with timer query */
  27519. canUseTimestampForTimerQuery: boolean;
  27520. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27521. multiview: any;
  27522. /** Function used to let the system compiles shaders in background */
  27523. parallelShaderCompile: {
  27524. COMPLETION_STATUS_KHR: number;
  27525. };
  27526. }
  27527. /** Interface defining initialization parameters for Engine class */
  27528. export interface EngineOptions extends WebGLContextAttributes {
  27529. /**
  27530. * Defines if the engine should no exceed a specified device ratio
  27531. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27532. */
  27533. limitDeviceRatio?: number;
  27534. /**
  27535. * Defines if webvr should be enabled automatically
  27536. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27537. */
  27538. autoEnableWebVR?: boolean;
  27539. /**
  27540. * Defines if webgl2 should be turned off even if supported
  27541. * @see http://doc.babylonjs.com/features/webgl2
  27542. */
  27543. disableWebGL2Support?: boolean;
  27544. /**
  27545. * Defines if webaudio should be initialized as well
  27546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27547. */
  27548. audioEngine?: boolean;
  27549. /**
  27550. * Defines if animations should run using a deterministic lock step
  27551. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27552. */
  27553. deterministicLockstep?: boolean;
  27554. /** Defines the maximum steps to use with deterministic lock step mode */
  27555. lockstepMaxSteps?: number;
  27556. /**
  27557. * Defines that engine should ignore context lost events
  27558. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27559. */
  27560. doNotHandleContextLost?: boolean;
  27561. /**
  27562. * Defines that engine should ignore modifying touch action attribute and style
  27563. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27564. */
  27565. doNotHandleTouchAction?: boolean;
  27566. /**
  27567. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27568. */
  27569. useHighPrecisionFloats?: boolean;
  27570. }
  27571. /**
  27572. * Defines the interface used by display changed events
  27573. */
  27574. export interface IDisplayChangedEventArgs {
  27575. /** Gets the vrDisplay object (if any) */
  27576. vrDisplay: Nullable<any>;
  27577. /** Gets a boolean indicating if webVR is supported */
  27578. vrSupported: boolean;
  27579. }
  27580. /**
  27581. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27582. */
  27583. export class Engine {
  27584. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27585. static ExceptionList: ({
  27586. key: string;
  27587. capture: string;
  27588. captureConstraint: number;
  27589. targets: string[];
  27590. } | {
  27591. key: string;
  27592. capture: null;
  27593. captureConstraint: null;
  27594. targets: string[];
  27595. })[];
  27596. /** Gets the list of created engines */
  27597. static readonly Instances: Engine[];
  27598. /**
  27599. * Gets the latest created engine
  27600. */
  27601. static readonly LastCreatedEngine: Nullable<Engine>;
  27602. /**
  27603. * Gets the latest created scene
  27604. */
  27605. static readonly LastCreatedScene: Nullable<Scene>;
  27606. /**
  27607. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27608. * @param flag defines which part of the materials must be marked as dirty
  27609. * @param predicate defines a predicate used to filter which materials should be affected
  27610. */
  27611. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27612. /**
  27613. * Hidden
  27614. */
  27615. static _TextureLoaders: IInternalTextureLoader[];
  27616. /** Defines that alpha blending is disabled */
  27617. static readonly ALPHA_DISABLE: number;
  27618. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27619. static readonly ALPHA_ADD: number;
  27620. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27621. static readonly ALPHA_COMBINE: number;
  27622. /** Defines that alpha blending to DEST - SRC * DEST */
  27623. static readonly ALPHA_SUBTRACT: number;
  27624. /** Defines that alpha blending to SRC * DEST */
  27625. static readonly ALPHA_MULTIPLY: number;
  27626. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27627. static readonly ALPHA_MAXIMIZED: number;
  27628. /** Defines that alpha blending to SRC + DEST */
  27629. static readonly ALPHA_ONEONE: number;
  27630. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27631. static readonly ALPHA_PREMULTIPLIED: number;
  27632. /**
  27633. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27634. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27635. */
  27636. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27637. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27638. static readonly ALPHA_INTERPOLATE: number;
  27639. /**
  27640. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27641. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27642. */
  27643. static readonly ALPHA_SCREENMODE: number;
  27644. /** Defines that the ressource is not delayed*/
  27645. static readonly DELAYLOADSTATE_NONE: number;
  27646. /** Defines that the ressource was successfully delay loaded */
  27647. static readonly DELAYLOADSTATE_LOADED: number;
  27648. /** Defines that the ressource is currently delay loading */
  27649. static readonly DELAYLOADSTATE_LOADING: number;
  27650. /** Defines that the ressource is delayed and has not started loading */
  27651. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27652. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27653. static readonly NEVER: number;
  27654. /** 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 */
  27655. static readonly ALWAYS: number;
  27656. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27657. static readonly LESS: number;
  27658. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27659. static readonly EQUAL: number;
  27660. /** 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 */
  27661. static readonly LEQUAL: number;
  27662. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27663. static readonly GREATER: number;
  27664. /** 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 */
  27665. static readonly GEQUAL: number;
  27666. /** 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 */
  27667. static readonly NOTEQUAL: number;
  27668. /** Passed to stencilOperation to specify that stencil value must be kept */
  27669. static readonly KEEP: number;
  27670. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27671. static readonly REPLACE: number;
  27672. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27673. static readonly INCR: number;
  27674. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27675. static readonly DECR: number;
  27676. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27677. static readonly INVERT: number;
  27678. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27679. static readonly INCR_WRAP: number;
  27680. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27681. static readonly DECR_WRAP: number;
  27682. /** Texture is not repeating outside of 0..1 UVs */
  27683. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27684. /** Texture is repeating outside of 0..1 UVs */
  27685. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27686. /** Texture is repeating and mirrored */
  27687. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27688. /** ALPHA */
  27689. static readonly TEXTUREFORMAT_ALPHA: number;
  27690. /** LUMINANCE */
  27691. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27692. /** LUMINANCE_ALPHA */
  27693. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27694. /** RGB */
  27695. static readonly TEXTUREFORMAT_RGB: number;
  27696. /** RGBA */
  27697. static readonly TEXTUREFORMAT_RGBA: number;
  27698. /** RED */
  27699. static readonly TEXTUREFORMAT_RED: number;
  27700. /** RED (2nd reference) */
  27701. static readonly TEXTUREFORMAT_R: number;
  27702. /** RG */
  27703. static readonly TEXTUREFORMAT_RG: number;
  27704. /** RED_INTEGER */
  27705. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27706. /** RED_INTEGER (2nd reference) */
  27707. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27708. /** RG_INTEGER */
  27709. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27710. /** RGB_INTEGER */
  27711. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27712. /** RGBA_INTEGER */
  27713. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27714. /** UNSIGNED_BYTE */
  27715. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27716. /** UNSIGNED_BYTE (2nd reference) */
  27717. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27718. /** FLOAT */
  27719. static readonly TEXTURETYPE_FLOAT: number;
  27720. /** HALF_FLOAT */
  27721. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27722. /** BYTE */
  27723. static readonly TEXTURETYPE_BYTE: number;
  27724. /** SHORT */
  27725. static readonly TEXTURETYPE_SHORT: number;
  27726. /** UNSIGNED_SHORT */
  27727. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27728. /** INT */
  27729. static readonly TEXTURETYPE_INT: number;
  27730. /** UNSIGNED_INT */
  27731. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27732. /** UNSIGNED_SHORT_4_4_4_4 */
  27733. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27734. /** UNSIGNED_SHORT_5_5_5_1 */
  27735. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27736. /** UNSIGNED_SHORT_5_6_5 */
  27737. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27738. /** UNSIGNED_INT_2_10_10_10_REV */
  27739. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27740. /** UNSIGNED_INT_24_8 */
  27741. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27742. /** UNSIGNED_INT_10F_11F_11F_REV */
  27743. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27744. /** UNSIGNED_INT_5_9_9_9_REV */
  27745. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27746. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27747. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27748. /** nearest is mag = nearest and min = nearest and mip = linear */
  27749. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27750. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27751. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27752. /** Trilinear is mag = linear and min = linear and mip = linear */
  27753. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27754. /** nearest is mag = nearest and min = nearest and mip = linear */
  27755. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27756. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27757. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27758. /** Trilinear is mag = linear and min = linear and mip = linear */
  27759. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27760. /** mag = nearest and min = nearest and mip = nearest */
  27761. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27762. /** mag = nearest and min = linear and mip = nearest */
  27763. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27764. /** mag = nearest and min = linear and mip = linear */
  27765. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27766. /** mag = nearest and min = linear and mip = none */
  27767. static readonly TEXTURE_NEAREST_LINEAR: number;
  27768. /** mag = nearest and min = nearest and mip = none */
  27769. static readonly TEXTURE_NEAREST_NEAREST: number;
  27770. /** mag = linear and min = nearest and mip = nearest */
  27771. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27772. /** mag = linear and min = nearest and mip = linear */
  27773. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27774. /** mag = linear and min = linear and mip = none */
  27775. static readonly TEXTURE_LINEAR_LINEAR: number;
  27776. /** mag = linear and min = nearest and mip = none */
  27777. static readonly TEXTURE_LINEAR_NEAREST: number;
  27778. /** Explicit coordinates mode */
  27779. static readonly TEXTURE_EXPLICIT_MODE: number;
  27780. /** Spherical coordinates mode */
  27781. static readonly TEXTURE_SPHERICAL_MODE: number;
  27782. /** Planar coordinates mode */
  27783. static readonly TEXTURE_PLANAR_MODE: number;
  27784. /** Cubic coordinates mode */
  27785. static readonly TEXTURE_CUBIC_MODE: number;
  27786. /** Projection coordinates mode */
  27787. static readonly TEXTURE_PROJECTION_MODE: number;
  27788. /** Skybox coordinates mode */
  27789. static readonly TEXTURE_SKYBOX_MODE: number;
  27790. /** Inverse Cubic coordinates mode */
  27791. static readonly TEXTURE_INVCUBIC_MODE: number;
  27792. /** Equirectangular coordinates mode */
  27793. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27794. /** Equirectangular Fixed coordinates mode */
  27795. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27796. /** Equirectangular Fixed Mirrored coordinates mode */
  27797. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27798. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27799. static readonly SCALEMODE_FLOOR: number;
  27800. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27801. static readonly SCALEMODE_NEAREST: number;
  27802. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27803. static readonly SCALEMODE_CEILING: number;
  27804. /**
  27805. * Returns the current npm package of the sdk
  27806. */
  27807. static readonly NpmPackage: string;
  27808. /**
  27809. * Returns the current version of the framework
  27810. */
  27811. static readonly Version: string;
  27812. /**
  27813. * Returns a string describing the current engine
  27814. */
  27815. readonly description: string;
  27816. /**
  27817. * Gets or sets the epsilon value used by collision engine
  27818. */
  27819. static CollisionsEpsilon: number;
  27820. /**
  27821. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27822. */
  27823. static ShadersRepository: string;
  27824. /**
  27825. * Method called to create the default loading screen.
  27826. * This can be overriden in your own app.
  27827. * @param canvas The rendering canvas element
  27828. * @returns The loading screen
  27829. */
  27830. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27831. /**
  27832. * Method called to create the default rescale post process on each engine.
  27833. */
  27834. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27835. /**
  27836. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27837. */
  27838. forcePOTTextures: boolean;
  27839. /**
  27840. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27841. */
  27842. isFullscreen: boolean;
  27843. /**
  27844. * Gets a boolean indicating if the pointer is currently locked
  27845. */
  27846. isPointerLock: boolean;
  27847. /**
  27848. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27849. */
  27850. cullBackFaces: boolean;
  27851. /**
  27852. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27853. */
  27854. renderEvenInBackground: boolean;
  27855. /**
  27856. * Gets or sets a boolean indicating that cache can be kept between frames
  27857. */
  27858. preventCacheWipeBetweenFrames: boolean;
  27859. /**
  27860. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27861. **/
  27862. enableOfflineSupport: boolean;
  27863. /**
  27864. * 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)
  27865. **/
  27866. disableManifestCheck: boolean;
  27867. /**
  27868. * Gets the list of created scenes
  27869. */
  27870. scenes: Scene[];
  27871. /**
  27872. * Event raised when a new scene is created
  27873. */
  27874. onNewSceneAddedObservable: Observable<Scene>;
  27875. /**
  27876. * Gets the list of created postprocesses
  27877. */
  27878. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27879. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27880. validateShaderPrograms: boolean;
  27881. /**
  27882. * Observable event triggered each time the rendering canvas is resized
  27883. */
  27884. onResizeObservable: Observable<Engine>;
  27885. /**
  27886. * Observable event triggered each time the canvas loses focus
  27887. */
  27888. onCanvasBlurObservable: Observable<Engine>;
  27889. /**
  27890. * Observable event triggered each time the canvas gains focus
  27891. */
  27892. onCanvasFocusObservable: Observable<Engine>;
  27893. /**
  27894. * Observable event triggered each time the canvas receives pointerout event
  27895. */
  27896. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27897. /**
  27898. * Observable event triggered before each texture is initialized
  27899. */
  27900. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27901. private _vrDisplay;
  27902. private _vrSupported;
  27903. private _oldSize;
  27904. private _oldHardwareScaleFactor;
  27905. private _vrExclusivePointerMode;
  27906. private _webVRInitPromise;
  27907. /**
  27908. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27909. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27910. */
  27911. readonly isInVRExclusivePointerMode: boolean;
  27912. /**
  27913. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27914. */
  27915. disableUniformBuffers: boolean;
  27916. /** @hidden */
  27917. _uniformBuffers: UniformBuffer[];
  27918. /**
  27919. * Gets a boolean indicating that the engine supports uniform buffers
  27920. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27921. */
  27922. readonly supportsUniformBuffers: boolean;
  27923. /**
  27924. * Observable raised when the engine begins a new frame
  27925. */
  27926. onBeginFrameObservable: Observable<Engine>;
  27927. /**
  27928. * If set, will be used to request the next animation frame for the render loop
  27929. */
  27930. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27931. /**
  27932. * Observable raised when the engine ends the current frame
  27933. */
  27934. onEndFrameObservable: Observable<Engine>;
  27935. /**
  27936. * Observable raised when the engine is about to compile a shader
  27937. */
  27938. onBeforeShaderCompilationObservable: Observable<Engine>;
  27939. /**
  27940. * Observable raised when the engine has jsut compiled a shader
  27941. */
  27942. onAfterShaderCompilationObservable: Observable<Engine>;
  27943. /** @hidden */
  27944. _gl: WebGLRenderingContext;
  27945. private _renderingCanvas;
  27946. private _windowIsBackground;
  27947. private _webGLVersion;
  27948. protected _highPrecisionShadersAllowed: boolean;
  27949. /** @hidden */
  27950. readonly _shouldUseHighPrecisionShader: boolean;
  27951. /**
  27952. * Gets a boolean indicating that only power of 2 textures are supported
  27953. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27954. */
  27955. readonly needPOTTextures: boolean;
  27956. /** @hidden */
  27957. _badOS: boolean;
  27958. /** @hidden */
  27959. _badDesktopOS: boolean;
  27960. /**
  27961. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27962. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27963. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27964. */
  27965. disableTextureBindingOptimization: boolean;
  27966. /**
  27967. * Gets the audio engine
  27968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27969. * @ignorenaming
  27970. */
  27971. static audioEngine: IAudioEngine;
  27972. /**
  27973. * Default AudioEngine factory responsible of creating the Audio Engine.
  27974. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27975. */
  27976. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27977. /**
  27978. * Default offline support factory responsible of creating a tool used to store data locally.
  27979. * By default, this will create a Database object if the workload has been embedded.
  27980. */
  27981. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27982. private _onFocus;
  27983. private _onBlur;
  27984. private _onCanvasPointerOut;
  27985. private _onCanvasBlur;
  27986. private _onCanvasFocus;
  27987. private _onFullscreenChange;
  27988. private _onPointerLockChange;
  27989. private _onVRDisplayPointerRestricted;
  27990. private _onVRDisplayPointerUnrestricted;
  27991. private _onVrDisplayConnect;
  27992. private _onVrDisplayDisconnect;
  27993. private _onVrDisplayPresentChange;
  27994. /**
  27995. * Observable signaled when VR display mode changes
  27996. */
  27997. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27998. /**
  27999. * Observable signaled when VR request present is complete
  28000. */
  28001. onVRRequestPresentComplete: Observable<boolean>;
  28002. /**
  28003. * Observable signaled when VR request present starts
  28004. */
  28005. onVRRequestPresentStart: Observable<Engine>;
  28006. private _hardwareScalingLevel;
  28007. /** @hidden */
  28008. protected _caps: EngineCapabilities;
  28009. private _pointerLockRequested;
  28010. private _isStencilEnable;
  28011. private _colorWrite;
  28012. private _loadingScreen;
  28013. /** @hidden */
  28014. _drawCalls: PerfCounter;
  28015. /** @hidden */
  28016. _textureCollisions: PerfCounter;
  28017. private _glVersion;
  28018. private _glRenderer;
  28019. private _glVendor;
  28020. private _videoTextureSupported;
  28021. private _renderingQueueLaunched;
  28022. private _activeRenderLoops;
  28023. private _deterministicLockstep;
  28024. private _lockstepMaxSteps;
  28025. /**
  28026. * Observable signaled when a context lost event is raised
  28027. */
  28028. onContextLostObservable: Observable<Engine>;
  28029. /**
  28030. * Observable signaled when a context restored event is raised
  28031. */
  28032. onContextRestoredObservable: Observable<Engine>;
  28033. private _onContextLost;
  28034. private _onContextRestored;
  28035. private _contextWasLost;
  28036. private _doNotHandleContextLost;
  28037. /**
  28038. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28040. */
  28041. doNotHandleContextLost: boolean;
  28042. private _performanceMonitor;
  28043. private _fps;
  28044. private _deltaTime;
  28045. /**
  28046. * Turn this value on if you want to pause FPS computation when in background
  28047. */
  28048. disablePerformanceMonitorInBackground: boolean;
  28049. /**
  28050. * Gets the performance monitor attached to this engine
  28051. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28052. */
  28053. readonly performanceMonitor: PerformanceMonitor;
  28054. /**
  28055. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28056. */
  28057. disableVertexArrayObjects: boolean;
  28058. /** @hidden */
  28059. protected _depthCullingState: _DepthCullingState;
  28060. /** @hidden */
  28061. protected _stencilState: _StencilState;
  28062. /** @hidden */
  28063. protected _alphaState: _AlphaState;
  28064. /** @hidden */
  28065. protected _alphaMode: number;
  28066. protected _internalTexturesCache: InternalTexture[];
  28067. /** @hidden */
  28068. protected _activeChannel: number;
  28069. private _currentTextureChannel;
  28070. /** @hidden */
  28071. protected _boundTexturesCache: {
  28072. [key: string]: Nullable<InternalTexture>;
  28073. };
  28074. /** @hidden */
  28075. protected _currentEffect: Nullable<Effect>;
  28076. /** @hidden */
  28077. protected _currentProgram: Nullable<WebGLProgram>;
  28078. private _compiledEffects;
  28079. private _vertexAttribArraysEnabled;
  28080. /** @hidden */
  28081. protected _cachedViewport: Nullable<Viewport>;
  28082. private _cachedVertexArrayObject;
  28083. /** @hidden */
  28084. protected _cachedVertexBuffers: any;
  28085. /** @hidden */
  28086. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28087. /** @hidden */
  28088. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28089. /** @hidden */
  28090. protected _currentRenderTarget: Nullable<InternalTexture>;
  28091. private _uintIndicesCurrentlySet;
  28092. private _currentBoundBuffer;
  28093. /** @hidden */
  28094. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28095. private _currentBufferPointers;
  28096. private _currentInstanceLocations;
  28097. private _currentInstanceBuffers;
  28098. private _textureUnits;
  28099. private _firstBoundInternalTextureTracker;
  28100. private _lastBoundInternalTextureTracker;
  28101. private _workingCanvas;
  28102. private _workingContext;
  28103. private _rescalePostProcess;
  28104. private _dummyFramebuffer;
  28105. private _externalData;
  28106. private _bindedRenderFunction;
  28107. private _vaoRecordInProgress;
  28108. private _mustWipeVertexAttributes;
  28109. private _emptyTexture;
  28110. private _emptyCubeTexture;
  28111. private _emptyTexture3D;
  28112. /** @hidden */
  28113. _frameHandler: number;
  28114. private _nextFreeTextureSlots;
  28115. private _maxSimultaneousTextures;
  28116. private _activeRequests;
  28117. private _texturesSupported;
  28118. private _textureFormatInUse;
  28119. /**
  28120. * Gets the list of texture formats supported
  28121. */
  28122. readonly texturesSupported: Array<string>;
  28123. /**
  28124. * Gets the list of texture formats in use
  28125. */
  28126. readonly textureFormatInUse: Nullable<string>;
  28127. /**
  28128. * Gets the current viewport
  28129. */
  28130. readonly currentViewport: Nullable<Viewport>;
  28131. /**
  28132. * Gets the default empty texture
  28133. */
  28134. readonly emptyTexture: InternalTexture;
  28135. /**
  28136. * Gets the default empty 3D texture
  28137. */
  28138. readonly emptyTexture3D: InternalTexture;
  28139. /**
  28140. * Gets the default empty cube texture
  28141. */
  28142. readonly emptyCubeTexture: InternalTexture;
  28143. /**
  28144. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28145. */
  28146. readonly premultipliedAlpha: boolean;
  28147. /**
  28148. * Creates a new engine
  28149. * @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
  28150. * @param antialias defines enable antialiasing (default: false)
  28151. * @param options defines further options to be sent to the getContext() function
  28152. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28153. */
  28154. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28155. private _disableTouchAction;
  28156. private _rebuildInternalTextures;
  28157. private _rebuildEffects;
  28158. /**
  28159. * Gets a boolean indicating if all created effects are ready
  28160. * @returns true if all effects are ready
  28161. */
  28162. areAllEffectsReady(): boolean;
  28163. private _rebuildBuffers;
  28164. private _initGLContext;
  28165. /**
  28166. * Gets version of the current webGL context
  28167. */
  28168. readonly webGLVersion: number;
  28169. /**
  28170. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28171. */
  28172. readonly isStencilEnable: boolean;
  28173. private _prepareWorkingCanvas;
  28174. /**
  28175. * Reset the texture cache to empty state
  28176. */
  28177. resetTextureCache(): void;
  28178. /**
  28179. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28180. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28181. * @returns true if engine is in deterministic lock step mode
  28182. */
  28183. isDeterministicLockStep(): boolean;
  28184. /**
  28185. * Gets the max steps when engine is running in deterministic lock step
  28186. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28187. * @returns the max steps
  28188. */
  28189. getLockstepMaxSteps(): number;
  28190. /**
  28191. * Gets an object containing information about the current webGL context
  28192. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28193. */
  28194. getGlInfo(): {
  28195. vendor: string;
  28196. renderer: string;
  28197. version: string;
  28198. };
  28199. /**
  28200. * Gets current aspect ratio
  28201. * @param camera defines the camera to use to get the aspect ratio
  28202. * @param useScreen defines if screen size must be used (or the current render target if any)
  28203. * @returns a number defining the aspect ratio
  28204. */
  28205. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28206. /**
  28207. * Gets current screen aspect ratio
  28208. * @returns a number defining the aspect ratio
  28209. */
  28210. getScreenAspectRatio(): number;
  28211. /**
  28212. * Gets the current render width
  28213. * @param useScreen defines if screen size must be used (or the current render target if any)
  28214. * @returns a number defining the current render width
  28215. */
  28216. getRenderWidth(useScreen?: boolean): number;
  28217. /**
  28218. * Gets the current render height
  28219. * @param useScreen defines if screen size must be used (or the current render target if any)
  28220. * @returns a number defining the current render height
  28221. */
  28222. getRenderHeight(useScreen?: boolean): number;
  28223. /**
  28224. * Gets the HTML canvas attached with the current webGL context
  28225. * @returns a HTML canvas
  28226. */
  28227. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28228. /**
  28229. * Gets the client rect of the HTML canvas attached with the current webGL context
  28230. * @returns a client rectanglee
  28231. */
  28232. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28233. /**
  28234. * Defines the hardware scaling level.
  28235. * By default the hardware scaling level is computed from the window device ratio.
  28236. * 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.
  28237. * @param level defines the level to use
  28238. */
  28239. setHardwareScalingLevel(level: number): void;
  28240. /**
  28241. * Gets the current hardware scaling level.
  28242. * By default the hardware scaling level is computed from the window device ratio.
  28243. * 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.
  28244. * @returns a number indicating the current hardware scaling level
  28245. */
  28246. getHardwareScalingLevel(): number;
  28247. /**
  28248. * Gets the list of loaded textures
  28249. * @returns an array containing all loaded textures
  28250. */
  28251. getLoadedTexturesCache(): InternalTexture[];
  28252. /**
  28253. * Gets the object containing all engine capabilities
  28254. * @returns the EngineCapabilities object
  28255. */
  28256. getCaps(): EngineCapabilities;
  28257. /**
  28258. * Gets the current depth function
  28259. * @returns a number defining the depth function
  28260. */
  28261. getDepthFunction(): Nullable<number>;
  28262. /**
  28263. * Sets the current depth function
  28264. * @param depthFunc defines the function to use
  28265. */
  28266. setDepthFunction(depthFunc: number): void;
  28267. /**
  28268. * Sets the current depth function to GREATER
  28269. */
  28270. setDepthFunctionToGreater(): void;
  28271. /**
  28272. * Sets the current depth function to GEQUAL
  28273. */
  28274. setDepthFunctionToGreaterOrEqual(): void;
  28275. /**
  28276. * Sets the current depth function to LESS
  28277. */
  28278. setDepthFunctionToLess(): void;
  28279. private _cachedStencilBuffer;
  28280. private _cachedStencilFunction;
  28281. private _cachedStencilMask;
  28282. private _cachedStencilOperationPass;
  28283. private _cachedStencilOperationFail;
  28284. private _cachedStencilOperationDepthFail;
  28285. private _cachedStencilReference;
  28286. /**
  28287. * Caches the the state of the stencil buffer
  28288. */
  28289. cacheStencilState(): void;
  28290. /**
  28291. * Restores the state of the stencil buffer
  28292. */
  28293. restoreStencilState(): void;
  28294. /**
  28295. * Sets the current depth function to LEQUAL
  28296. */
  28297. setDepthFunctionToLessOrEqual(): void;
  28298. /**
  28299. * Gets a boolean indicating if stencil buffer is enabled
  28300. * @returns the current stencil buffer state
  28301. */
  28302. getStencilBuffer(): boolean;
  28303. /**
  28304. * Enable or disable the stencil buffer
  28305. * @param enable defines if the stencil buffer must be enabled or disabled
  28306. */
  28307. setStencilBuffer(enable: boolean): void;
  28308. /**
  28309. * Gets the current stencil mask
  28310. * @returns a number defining the new stencil mask to use
  28311. */
  28312. getStencilMask(): number;
  28313. /**
  28314. * Sets the current stencil mask
  28315. * @param mask defines the new stencil mask to use
  28316. */
  28317. setStencilMask(mask: number): void;
  28318. /**
  28319. * Gets the current stencil function
  28320. * @returns a number defining the stencil function to use
  28321. */
  28322. getStencilFunction(): number;
  28323. /**
  28324. * Gets the current stencil reference value
  28325. * @returns a number defining the stencil reference value to use
  28326. */
  28327. getStencilFunctionReference(): number;
  28328. /**
  28329. * Gets the current stencil mask
  28330. * @returns a number defining the stencil mask to use
  28331. */
  28332. getStencilFunctionMask(): number;
  28333. /**
  28334. * Sets the current stencil function
  28335. * @param stencilFunc defines the new stencil function to use
  28336. */
  28337. setStencilFunction(stencilFunc: number): void;
  28338. /**
  28339. * Sets the current stencil reference
  28340. * @param reference defines the new stencil reference to use
  28341. */
  28342. setStencilFunctionReference(reference: number): void;
  28343. /**
  28344. * Sets the current stencil mask
  28345. * @param mask defines the new stencil mask to use
  28346. */
  28347. setStencilFunctionMask(mask: number): void;
  28348. /**
  28349. * Gets the current stencil operation when stencil fails
  28350. * @returns a number defining stencil operation to use when stencil fails
  28351. */
  28352. getStencilOperationFail(): number;
  28353. /**
  28354. * Gets the current stencil operation when depth fails
  28355. * @returns a number defining stencil operation to use when depth fails
  28356. */
  28357. getStencilOperationDepthFail(): number;
  28358. /**
  28359. * Gets the current stencil operation when stencil passes
  28360. * @returns a number defining stencil operation to use when stencil passes
  28361. */
  28362. getStencilOperationPass(): number;
  28363. /**
  28364. * Sets the stencil operation to use when stencil fails
  28365. * @param operation defines the stencil operation to use when stencil fails
  28366. */
  28367. setStencilOperationFail(operation: number): void;
  28368. /**
  28369. * Sets the stencil operation to use when depth fails
  28370. * @param operation defines the stencil operation to use when depth fails
  28371. */
  28372. setStencilOperationDepthFail(operation: number): void;
  28373. /**
  28374. * Sets the stencil operation to use when stencil passes
  28375. * @param operation defines the stencil operation to use when stencil passes
  28376. */
  28377. setStencilOperationPass(operation: number): void;
  28378. /**
  28379. * Sets a boolean indicating if the dithering state is enabled or disabled
  28380. * @param value defines the dithering state
  28381. */
  28382. setDitheringState(value: boolean): void;
  28383. /**
  28384. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28385. * @param value defines the rasterizer state
  28386. */
  28387. setRasterizerState(value: boolean): void;
  28388. /**
  28389. * stop executing a render loop function and remove it from the execution array
  28390. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28391. */
  28392. stopRenderLoop(renderFunction?: () => void): void;
  28393. /** @hidden */
  28394. _renderLoop(): void;
  28395. /**
  28396. * Register and execute a render loop. The engine can have more than one render function
  28397. * @param renderFunction defines the function to continuously execute
  28398. */
  28399. runRenderLoop(renderFunction: () => void): void;
  28400. /**
  28401. * Toggle full screen mode
  28402. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28403. */
  28404. switchFullscreen(requestPointerLock: boolean): void;
  28405. /**
  28406. * Enters full screen mode
  28407. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28408. */
  28409. enterFullscreen(requestPointerLock: boolean): void;
  28410. /**
  28411. * Exits full screen mode
  28412. */
  28413. exitFullscreen(): void;
  28414. /**
  28415. * Clear the current render buffer or the current render target (if any is set up)
  28416. * @param color defines the color to use
  28417. * @param backBuffer defines if the back buffer must be cleared
  28418. * @param depth defines if the depth buffer must be cleared
  28419. * @param stencil defines if the stencil buffer must be cleared
  28420. */
  28421. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28422. /**
  28423. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28424. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28425. * @param y defines the y-coordinate of the corner of the clear rectangle
  28426. * @param width defines the width of the clear rectangle
  28427. * @param height defines the height of the clear rectangle
  28428. * @param clearColor defines the clear color
  28429. */
  28430. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28431. /**
  28432. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28433. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28434. * @param y defines the y-coordinate of the corner of the clear rectangle
  28435. * @param width defines the width of the clear rectangle
  28436. * @param height defines the height of the clear rectangle
  28437. */
  28438. enableScissor(x: number, y: number, width: number, height: number): void;
  28439. /**
  28440. * Disable previously set scissor test rectangle
  28441. */
  28442. disableScissor(): void;
  28443. private _viewportCached;
  28444. /** @hidden */
  28445. _viewport(x: number, y: number, width: number, height: number): void;
  28446. /**
  28447. * Set the WebGL's viewport
  28448. * @param viewport defines the viewport element to be used
  28449. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28450. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28451. */
  28452. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28453. /**
  28454. * Directly set the WebGL Viewport
  28455. * @param x defines the x coordinate of the viewport (in screen space)
  28456. * @param y defines the y coordinate of the viewport (in screen space)
  28457. * @param width defines the width of the viewport (in screen space)
  28458. * @param height defines the height of the viewport (in screen space)
  28459. * @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
  28460. */
  28461. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28462. /**
  28463. * Begin a new frame
  28464. */
  28465. beginFrame(): void;
  28466. /**
  28467. * Enf the current frame
  28468. */
  28469. endFrame(): void;
  28470. /**
  28471. * Resize the view according to the canvas' size
  28472. */
  28473. resize(): void;
  28474. /**
  28475. * Force a specific size of the canvas
  28476. * @param width defines the new canvas' width
  28477. * @param height defines the new canvas' height
  28478. */
  28479. setSize(width: number, height: number): void;
  28480. /**
  28481. * Gets a boolean indicating if a webVR device was detected
  28482. * @returns true if a webVR device was detected
  28483. */
  28484. isVRDevicePresent(): boolean;
  28485. /**
  28486. * Gets the current webVR device
  28487. * @returns the current webVR device (or null)
  28488. */
  28489. getVRDevice(): any;
  28490. /**
  28491. * Initializes a webVR display and starts listening to display change events
  28492. * The onVRDisplayChangedObservable will be notified upon these changes
  28493. * @returns The onVRDisplayChangedObservable
  28494. */
  28495. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28496. /**
  28497. * Initializes a webVR display and starts listening to display change events
  28498. * The onVRDisplayChangedObservable will be notified upon these changes
  28499. * @returns A promise containing a VRDisplay and if vr is supported
  28500. */
  28501. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28502. /**
  28503. * Call this function to switch to webVR mode
  28504. * Will do nothing if webVR is not supported or if there is no webVR device
  28505. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28506. */
  28507. enableVR(): void;
  28508. /**
  28509. * Call this function to leave webVR mode
  28510. * Will do nothing if webVR is not supported or if there is no webVR device
  28511. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28512. */
  28513. disableVR(): void;
  28514. private _onVRFullScreenTriggered;
  28515. private _getVRDisplaysAsync;
  28516. /**
  28517. * Binds the frame buffer to the specified texture.
  28518. * @param texture The texture to render to or null for the default canvas
  28519. * @param faceIndex The face of the texture to render to in case of cube texture
  28520. * @param requiredWidth The width of the target to render to
  28521. * @param requiredHeight The height of the target to render to
  28522. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28523. * @param depthStencilTexture The depth stencil texture to use to render
  28524. * @param lodLevel defines le lod level to bind to the frame buffer
  28525. */
  28526. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28527. private bindUnboundFramebuffer;
  28528. /**
  28529. * Unbind the current render target texture from the webGL context
  28530. * @param texture defines the render target texture to unbind
  28531. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28532. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28533. */
  28534. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28535. /**
  28536. * Unbind a list of render target textures from the webGL context
  28537. * This is used only when drawBuffer extension or webGL2 are active
  28538. * @param textures defines the render target textures to unbind
  28539. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28540. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28541. */
  28542. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28543. /**
  28544. * Force the mipmap generation for the given render target texture
  28545. * @param texture defines the render target texture to use
  28546. */
  28547. generateMipMapsForCubemap(texture: InternalTexture): void;
  28548. /**
  28549. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28550. */
  28551. flushFramebuffer(): void;
  28552. /**
  28553. * Unbind the current render target and bind the default framebuffer
  28554. */
  28555. restoreDefaultFramebuffer(): void;
  28556. /**
  28557. * Create an uniform buffer
  28558. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28559. * @param elements defines the content of the uniform buffer
  28560. * @returns the webGL uniform buffer
  28561. */
  28562. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28563. /**
  28564. * Create a dynamic uniform buffer
  28565. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28566. * @param elements defines the content of the uniform buffer
  28567. * @returns the webGL uniform buffer
  28568. */
  28569. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28570. /**
  28571. * Update an existing uniform buffer
  28572. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28573. * @param uniformBuffer defines the target uniform buffer
  28574. * @param elements defines the content to update
  28575. * @param offset defines the offset in the uniform buffer where update should start
  28576. * @param count defines the size of the data to update
  28577. */
  28578. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28579. private _resetVertexBufferBinding;
  28580. /**
  28581. * Creates a vertex buffer
  28582. * @param data the data for the vertex buffer
  28583. * @returns the new WebGL static buffer
  28584. */
  28585. createVertexBuffer(data: DataArray): WebGLBuffer;
  28586. /**
  28587. * Creates a dynamic vertex buffer
  28588. * @param data the data for the dynamic vertex buffer
  28589. * @returns the new WebGL dynamic buffer
  28590. */
  28591. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28592. /**
  28593. * Update a dynamic index buffer
  28594. * @param indexBuffer defines the target index buffer
  28595. * @param indices defines the data to update
  28596. * @param offset defines the offset in the target index buffer where update should start
  28597. */
  28598. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28599. /**
  28600. * Updates a dynamic vertex buffer.
  28601. * @param vertexBuffer the vertex buffer to update
  28602. * @param data the data used to update the vertex buffer
  28603. * @param byteOffset the byte offset of the data
  28604. * @param byteLength the byte length of the data
  28605. */
  28606. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28607. private _resetIndexBufferBinding;
  28608. /**
  28609. * Creates a new index buffer
  28610. * @param indices defines the content of the index buffer
  28611. * @param updatable defines if the index buffer must be updatable
  28612. * @returns a new webGL buffer
  28613. */
  28614. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28615. /**
  28616. * Bind a webGL buffer to the webGL context
  28617. * @param buffer defines the buffer to bind
  28618. */
  28619. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28620. /**
  28621. * Bind an uniform buffer to the current webGL context
  28622. * @param buffer defines the buffer to bind
  28623. */
  28624. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28625. /**
  28626. * Bind a buffer to the current webGL context at a given location
  28627. * @param buffer defines the buffer to bind
  28628. * @param location defines the index where to bind the buffer
  28629. */
  28630. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28631. /**
  28632. * Bind a specific block at a given index in a specific shader program
  28633. * @param shaderProgram defines the shader program
  28634. * @param blockName defines the block name
  28635. * @param index defines the index where to bind the block
  28636. */
  28637. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28638. private bindIndexBuffer;
  28639. private bindBuffer;
  28640. /**
  28641. * update the bound buffer with the given data
  28642. * @param data defines the data to update
  28643. */
  28644. updateArrayBuffer(data: Float32Array): void;
  28645. private _vertexAttribPointer;
  28646. private _bindIndexBufferWithCache;
  28647. private _bindVertexBuffersAttributes;
  28648. /**
  28649. * Records a vertex array object
  28650. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28651. * @param vertexBuffers defines the list of vertex buffers to store
  28652. * @param indexBuffer defines the index buffer to store
  28653. * @param effect defines the effect to store
  28654. * @returns the new vertex array object
  28655. */
  28656. recordVertexArrayObject(vertexBuffers: {
  28657. [key: string]: VertexBuffer;
  28658. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28659. /**
  28660. * Bind a specific vertex array object
  28661. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28662. * @param vertexArrayObject defines the vertex array object to bind
  28663. * @param indexBuffer defines the index buffer to bind
  28664. */
  28665. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28666. /**
  28667. * Bind webGl buffers directly to the webGL context
  28668. * @param vertexBuffer defines the vertex buffer to bind
  28669. * @param indexBuffer defines the index buffer to bind
  28670. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28671. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28672. * @param effect defines the effect associated with the vertex buffer
  28673. */
  28674. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28675. private _unbindVertexArrayObject;
  28676. /**
  28677. * Bind a list of vertex buffers to the webGL context
  28678. * @param vertexBuffers defines the list of vertex buffers to bind
  28679. * @param indexBuffer defines the index buffer to bind
  28680. * @param effect defines the effect associated with the vertex buffers
  28681. */
  28682. bindBuffers(vertexBuffers: {
  28683. [key: string]: Nullable<VertexBuffer>;
  28684. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28685. /**
  28686. * Unbind all instance attributes
  28687. */
  28688. unbindInstanceAttributes(): void;
  28689. /**
  28690. * Release and free the memory of a vertex array object
  28691. * @param vao defines the vertex array object to delete
  28692. */
  28693. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28694. /** @hidden */
  28695. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28696. /**
  28697. * Creates a webGL buffer to use with instanciation
  28698. * @param capacity defines the size of the buffer
  28699. * @returns the webGL buffer
  28700. */
  28701. createInstancesBuffer(capacity: number): WebGLBuffer;
  28702. /**
  28703. * Delete a webGL buffer used with instanciation
  28704. * @param buffer defines the webGL buffer to delete
  28705. */
  28706. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28707. /**
  28708. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28709. * @param instancesBuffer defines the webGL buffer to update and bind
  28710. * @param data defines the data to store in the buffer
  28711. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28712. */
  28713. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28714. /**
  28715. * Apply all cached states (depth, culling, stencil and alpha)
  28716. */
  28717. applyStates(): void;
  28718. /**
  28719. * Send a draw order
  28720. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28721. * @param indexStart defines the starting index
  28722. * @param indexCount defines the number of index to draw
  28723. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28724. */
  28725. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28726. /**
  28727. * Draw a list of points
  28728. * @param verticesStart defines the index of first vertex to draw
  28729. * @param verticesCount defines the count of vertices to draw
  28730. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28731. */
  28732. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28733. /**
  28734. * Draw a list of unindexed primitives
  28735. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28736. * @param verticesStart defines the index of first vertex to draw
  28737. * @param verticesCount defines the count of vertices to draw
  28738. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28739. */
  28740. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28741. /**
  28742. * Draw a list of indexed primitives
  28743. * @param fillMode defines the primitive to use
  28744. * @param indexStart defines the starting index
  28745. * @param indexCount defines the number of index to draw
  28746. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28747. */
  28748. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28749. /**
  28750. * Draw a list of unindexed primitives
  28751. * @param fillMode defines the primitive to use
  28752. * @param verticesStart defines the index of first vertex to draw
  28753. * @param verticesCount defines the count of vertices to draw
  28754. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28755. */
  28756. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28757. private _drawMode;
  28758. /** @hidden */
  28759. _releaseEffect(effect: Effect): void;
  28760. /** @hidden */
  28761. _deleteProgram(program: WebGLProgram): void;
  28762. /**
  28763. * Create a new effect (used to store vertex/fragment shaders)
  28764. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28765. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28766. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28767. * @param samplers defines an array of string used to represent textures
  28768. * @param defines defines the string containing the defines to use to compile the shaders
  28769. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28770. * @param onCompiled defines a function to call when the effect creation is successful
  28771. * @param onError defines a function to call when the effect creation has failed
  28772. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28773. * @returns the new Effect
  28774. */
  28775. 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;
  28776. private _compileShader;
  28777. private _compileRawShader;
  28778. /**
  28779. * Directly creates a webGL program
  28780. * @param vertexCode defines the vertex shader code to use
  28781. * @param fragmentCode defines the fragment shader code to use
  28782. * @param context defines the webGL context to use (if not set, the current one will be used)
  28783. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28784. * @returns the new webGL program
  28785. */
  28786. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28787. /**
  28788. * Creates a webGL program
  28789. * @param vertexCode defines the vertex shader code to use
  28790. * @param fragmentCode defines the fragment shader code to use
  28791. * @param defines defines the string containing the defines to use to compile the shaders
  28792. * @param context defines the webGL context to use (if not set, the current one will be used)
  28793. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28794. * @returns the new webGL program
  28795. */
  28796. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28797. private _createShaderProgram;
  28798. private _finalizeProgram;
  28799. /** @hidden */
  28800. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28801. /** @hidden */
  28802. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28803. /**
  28804. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28805. * @param shaderProgram defines the webGL program to use
  28806. * @param uniformsNames defines the list of uniform names
  28807. * @returns an array of webGL uniform locations
  28808. */
  28809. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28810. /**
  28811. * Gets the lsit of active attributes for a given webGL program
  28812. * @param shaderProgram defines the webGL program to use
  28813. * @param attributesNames defines the list of attribute names to get
  28814. * @returns an array of indices indicating the offset of each attribute
  28815. */
  28816. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28817. /**
  28818. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28819. * @param effect defines the effect to activate
  28820. */
  28821. enableEffect(effect: Nullable<Effect>): void;
  28822. /**
  28823. * Set the value of an uniform to an array of int32
  28824. * @param uniform defines the webGL uniform location where to store the value
  28825. * @param array defines the array of int32 to store
  28826. */
  28827. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28828. /**
  28829. * Set the value of an uniform to an array of int32 (stored as vec2)
  28830. * @param uniform defines the webGL uniform location where to store the value
  28831. * @param array defines the array of int32 to store
  28832. */
  28833. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28834. /**
  28835. * Set the value of an uniform to an array of int32 (stored as vec3)
  28836. * @param uniform defines the webGL uniform location where to store the value
  28837. * @param array defines the array of int32 to store
  28838. */
  28839. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28840. /**
  28841. * Set the value of an uniform to an array of int32 (stored as vec4)
  28842. * @param uniform defines the webGL uniform location where to store the value
  28843. * @param array defines the array of int32 to store
  28844. */
  28845. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28846. /**
  28847. * Set the value of an uniform to an array of float32
  28848. * @param uniform defines the webGL uniform location where to store the value
  28849. * @param array defines the array of float32 to store
  28850. */
  28851. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28852. /**
  28853. * Set the value of an uniform to an array of float32 (stored as vec2)
  28854. * @param uniform defines the webGL uniform location where to store the value
  28855. * @param array defines the array of float32 to store
  28856. */
  28857. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28858. /**
  28859. * Set the value of an uniform to an array of float32 (stored as vec3)
  28860. * @param uniform defines the webGL uniform location where to store the value
  28861. * @param array defines the array of float32 to store
  28862. */
  28863. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28864. /**
  28865. * Set the value of an uniform to an array of float32 (stored as vec4)
  28866. * @param uniform defines the webGL uniform location where to store the value
  28867. * @param array defines the array of float32 to store
  28868. */
  28869. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28870. /**
  28871. * Set the value of an uniform to an array of number
  28872. * @param uniform defines the webGL uniform location where to store the value
  28873. * @param array defines the array of number to store
  28874. */
  28875. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28876. /**
  28877. * Set the value of an uniform to an array of number (stored as vec2)
  28878. * @param uniform defines the webGL uniform location where to store the value
  28879. * @param array defines the array of number to store
  28880. */
  28881. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28882. /**
  28883. * Set the value of an uniform to an array of number (stored as vec3)
  28884. * @param uniform defines the webGL uniform location where to store the value
  28885. * @param array defines the array of number to store
  28886. */
  28887. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28888. /**
  28889. * Set the value of an uniform to an array of number (stored as vec4)
  28890. * @param uniform defines the webGL uniform location where to store the value
  28891. * @param array defines the array of number to store
  28892. */
  28893. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28894. /**
  28895. * Set the value of an uniform to an array of float32 (stored as matrices)
  28896. * @param uniform defines the webGL uniform location where to store the value
  28897. * @param matrices defines the array of float32 to store
  28898. */
  28899. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28900. /**
  28901. * Set the value of an uniform to a matrix
  28902. * @param uniform defines the webGL uniform location where to store the value
  28903. * @param matrix defines the matrix to store
  28904. */
  28905. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28906. /**
  28907. * Set the value of an uniform to a matrix (3x3)
  28908. * @param uniform defines the webGL uniform location where to store the value
  28909. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28910. */
  28911. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28912. /**
  28913. * Set the value of an uniform to a matrix (2x2)
  28914. * @param uniform defines the webGL uniform location where to store the value
  28915. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28916. */
  28917. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28918. /**
  28919. * Set the value of an uniform to a number (int)
  28920. * @param uniform defines the webGL uniform location where to store the value
  28921. * @param value defines the int number to store
  28922. */
  28923. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28924. /**
  28925. * Set the value of an uniform to a number (float)
  28926. * @param uniform defines the webGL uniform location where to store the value
  28927. * @param value defines the float number to store
  28928. */
  28929. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28930. /**
  28931. * Set the value of an uniform to a vec2
  28932. * @param uniform defines the webGL uniform location where to store the value
  28933. * @param x defines the 1st component of the value
  28934. * @param y defines the 2nd component of the value
  28935. */
  28936. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28937. /**
  28938. * Set the value of an uniform to a vec3
  28939. * @param uniform defines the webGL uniform location where to store the value
  28940. * @param x defines the 1st component of the value
  28941. * @param y defines the 2nd component of the value
  28942. * @param z defines the 3rd component of the value
  28943. */
  28944. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28945. /**
  28946. * Set the value of an uniform to a boolean
  28947. * @param uniform defines the webGL uniform location where to store the value
  28948. * @param bool defines the boolean to store
  28949. */
  28950. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28951. /**
  28952. * Set the value of an uniform to a vec4
  28953. * @param uniform defines the webGL uniform location where to store the value
  28954. * @param x defines the 1st component of the value
  28955. * @param y defines the 2nd component of the value
  28956. * @param z defines the 3rd component of the value
  28957. * @param w defines the 4th component of the value
  28958. */
  28959. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28960. /**
  28961. * Set the value of an uniform to a Color3
  28962. * @param uniform defines the webGL uniform location where to store the value
  28963. * @param color3 defines the color to store
  28964. */
  28965. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28966. /**
  28967. * Set the value of an uniform to a Color3 and an alpha value
  28968. * @param uniform defines the webGL uniform location where to store the value
  28969. * @param color3 defines the color to store
  28970. * @param alpha defines the alpha component to store
  28971. */
  28972. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28973. /**
  28974. * Sets a Color4 on a uniform variable
  28975. * @param uniform defines the uniform location
  28976. * @param color4 defines the value to be set
  28977. */
  28978. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28979. /**
  28980. * Set various states to the webGL context
  28981. * @param culling defines backface culling state
  28982. * @param zOffset defines the value to apply to zOffset (0 by default)
  28983. * @param force defines if states must be applied even if cache is up to date
  28984. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28985. */
  28986. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28987. /**
  28988. * Set the z offset to apply to current rendering
  28989. * @param value defines the offset to apply
  28990. */
  28991. setZOffset(value: number): void;
  28992. /**
  28993. * Gets the current value of the zOffset
  28994. * @returns the current zOffset state
  28995. */
  28996. getZOffset(): number;
  28997. /**
  28998. * Enable or disable depth buffering
  28999. * @param enable defines the state to set
  29000. */
  29001. setDepthBuffer(enable: boolean): void;
  29002. /**
  29003. * Gets a boolean indicating if depth writing is enabled
  29004. * @returns the current depth writing state
  29005. */
  29006. getDepthWrite(): boolean;
  29007. /**
  29008. * Enable or disable depth writing
  29009. * @param enable defines the state to set
  29010. */
  29011. setDepthWrite(enable: boolean): void;
  29012. /**
  29013. * Enable or disable color writing
  29014. * @param enable defines the state to set
  29015. */
  29016. setColorWrite(enable: boolean): void;
  29017. /**
  29018. * Gets a boolean indicating if color writing is enabled
  29019. * @returns the current color writing state
  29020. */
  29021. getColorWrite(): boolean;
  29022. /**
  29023. * Sets alpha constants used by some alpha blending modes
  29024. * @param r defines the red component
  29025. * @param g defines the green component
  29026. * @param b defines the blue component
  29027. * @param a defines the alpha component
  29028. */
  29029. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29030. /**
  29031. * Sets the current alpha mode
  29032. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29033. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29034. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29035. */
  29036. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29037. /**
  29038. * Gets the current alpha mode
  29039. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29040. * @returns the current alpha mode
  29041. */
  29042. getAlphaMode(): number;
  29043. /**
  29044. * Clears the list of texture accessible through engine.
  29045. * This can help preventing texture load conflict due to name collision.
  29046. */
  29047. clearInternalTexturesCache(): void;
  29048. /**
  29049. * Force the entire cache to be cleared
  29050. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29051. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29052. */
  29053. wipeCaches(bruteForce?: boolean): void;
  29054. /**
  29055. * Set the compressed texture format to use, based on the formats you have, and the formats
  29056. * supported by the hardware / browser.
  29057. *
  29058. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29059. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29060. * to API arguments needed to compressed textures. This puts the burden on the container
  29061. * generator to house the arcane code for determining these for current & future formats.
  29062. *
  29063. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29064. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29065. *
  29066. * Note: The result of this call is not taken into account when a texture is base64.
  29067. *
  29068. * @param formatsAvailable defines the list of those format families you have created
  29069. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29070. *
  29071. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29072. * @returns The extension selected.
  29073. */
  29074. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29075. private _getSamplingParameters;
  29076. private _partialLoadImg;
  29077. private _cascadeLoadImgs;
  29078. /** @hidden */
  29079. _createTexture(): WebGLTexture;
  29080. /**
  29081. * Usually called from Texture.ts.
  29082. * Passed information to create a WebGLTexture
  29083. * @param urlArg defines a value which contains one of the following:
  29084. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29085. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29086. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29087. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29088. * @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)
  29089. * @param scene needed for loading to the correct scene
  29090. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29091. * @param onLoad optional callback to be called upon successful completion
  29092. * @param onError optional callback to be called upon failure
  29093. * @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
  29094. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29095. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29096. * @param forcedExtension defines the extension to use to pick the right loader
  29097. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29098. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29099. */
  29100. 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;
  29101. private _rescaleTexture;
  29102. /**
  29103. * Update a raw texture
  29104. * @param texture defines the texture to update
  29105. * @param data defines the data to store in the texture
  29106. * @param format defines the format of the data
  29107. * @param invertY defines if data must be stored with Y axis inverted
  29108. * @param compression defines the compression used (null by default)
  29109. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29110. */
  29111. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29112. /**
  29113. * Creates a raw texture
  29114. * @param data defines the data to store in the texture
  29115. * @param width defines the width of the texture
  29116. * @param height defines the height of the texture
  29117. * @param format defines the format of the data
  29118. * @param generateMipMaps defines if the engine should generate the mip levels
  29119. * @param invertY defines if data must be stored with Y axis inverted
  29120. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29121. * @param compression defines the compression used (null by default)
  29122. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29123. * @returns the raw texture inside an InternalTexture
  29124. */
  29125. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29126. private _unpackFlipYCached;
  29127. /**
  29128. * In case you are sharing the context with other applications, it might
  29129. * be interested to not cache the unpack flip y state to ensure a consistent
  29130. * value would be set.
  29131. */
  29132. enableUnpackFlipYCached: boolean;
  29133. /** @hidden */
  29134. _unpackFlipY(value: boolean): void;
  29135. /** @hidden */
  29136. _getUnpackAlignement(): number;
  29137. /**
  29138. * Creates a dynamic texture
  29139. * @param width defines the width of the texture
  29140. * @param height defines the height of the texture
  29141. * @param generateMipMaps defines if the engine should generate the mip levels
  29142. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29143. * @returns the dynamic texture inside an InternalTexture
  29144. */
  29145. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29146. /**
  29147. * Update the sampling mode of a given texture
  29148. * @param samplingMode defines the required sampling mode
  29149. * @param texture defines the texture to update
  29150. */
  29151. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29152. /**
  29153. * Update the content of a dynamic texture
  29154. * @param texture defines the texture to update
  29155. * @param canvas defines the canvas containing the source
  29156. * @param invertY defines if data must be stored with Y axis inverted
  29157. * @param premulAlpha defines if alpha is stored as premultiplied
  29158. * @param format defines the format of the data
  29159. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29160. */
  29161. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29162. /**
  29163. * Update a video texture
  29164. * @param texture defines the texture to update
  29165. * @param video defines the video element to use
  29166. * @param invertY defines if data must be stored with Y axis inverted
  29167. */
  29168. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29169. /**
  29170. * Updates a depth texture Comparison Mode and Function.
  29171. * If the comparison Function is equal to 0, the mode will be set to none.
  29172. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29173. * @param texture The texture to set the comparison function for
  29174. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29175. */
  29176. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29177. private _setupDepthStencilTexture;
  29178. /**
  29179. * Creates a depth stencil texture.
  29180. * This is only available in WebGL 2 or with the depth texture extension available.
  29181. * @param size The size of face edge in the texture.
  29182. * @param options The options defining the texture.
  29183. * @returns The texture
  29184. */
  29185. createDepthStencilTexture(size: number | {
  29186. width: number;
  29187. height: number;
  29188. }, options: DepthTextureCreationOptions): InternalTexture;
  29189. /**
  29190. * Creates a depth stencil texture.
  29191. * This is only available in WebGL 2 or with the depth texture extension available.
  29192. * @param size The size of face edge in the texture.
  29193. * @param options The options defining the texture.
  29194. * @returns The texture
  29195. */
  29196. private _createDepthStencilTexture;
  29197. /**
  29198. * Creates a depth stencil cube texture.
  29199. * This is only available in WebGL 2.
  29200. * @param size The size of face edge in the cube texture.
  29201. * @param options The options defining the cube texture.
  29202. * @returns The cube texture
  29203. */
  29204. private _createDepthStencilCubeTexture;
  29205. /**
  29206. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29207. * @param renderTarget The render target to set the frame buffer for
  29208. */
  29209. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29210. /**
  29211. * Creates a new render target texture
  29212. * @param size defines the size of the texture
  29213. * @param options defines the options used to create the texture
  29214. * @returns a new render target texture stored in an InternalTexture
  29215. */
  29216. createRenderTargetTexture(size: number | {
  29217. width: number;
  29218. height: number;
  29219. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29220. /**
  29221. * Create a multi render target texture
  29222. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29223. * @param size defines the size of the texture
  29224. * @param options defines the creation options
  29225. * @returns the cube texture as an InternalTexture
  29226. */
  29227. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29228. private _setupFramebufferDepthAttachments;
  29229. /**
  29230. * Updates the sample count of a render target texture
  29231. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29232. * @param texture defines the texture to update
  29233. * @param samples defines the sample count to set
  29234. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29235. */
  29236. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29237. /**
  29238. * Update the sample count for a given multiple render target texture
  29239. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29240. * @param textures defines the textures to update
  29241. * @param samples defines the sample count to set
  29242. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29243. */
  29244. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29245. /** @hidden */
  29246. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29247. /** @hidden */
  29248. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29249. /** @hidden */
  29250. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29251. /** @hidden */
  29252. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29253. /**
  29254. * Creates a new render target cube texture
  29255. * @param size defines the size of the texture
  29256. * @param options defines the options used to create the texture
  29257. * @returns a new render target cube texture stored in an InternalTexture
  29258. */
  29259. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29260. /**
  29261. * Creates a cube texture
  29262. * @param rootUrl defines the url where the files to load is located
  29263. * @param scene defines the current scene
  29264. * @param files defines the list of files to load (1 per face)
  29265. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29266. * @param onLoad defines an optional callback raised when the texture is loaded
  29267. * @param onError defines an optional callback raised if there is an issue to load the texture
  29268. * @param format defines the format of the data
  29269. * @param forcedExtension defines the extension to use to pick the right loader
  29270. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29271. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29272. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29273. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29274. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29275. * @returns the cube texture as an InternalTexture
  29276. */
  29277. 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;
  29278. /**
  29279. * @hidden
  29280. */
  29281. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29282. /**
  29283. * Update a raw cube texture
  29284. * @param texture defines the texture to udpdate
  29285. * @param data defines the data to store
  29286. * @param format defines the data format
  29287. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29288. * @param invertY defines if data must be stored with Y axis inverted
  29289. * @param compression defines the compression used (null by default)
  29290. * @param level defines which level of the texture to update
  29291. */
  29292. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29293. /**
  29294. * Creates a new raw cube texture
  29295. * @param data defines the array of data to use to create each face
  29296. * @param size defines the size of the textures
  29297. * @param format defines the format of the data
  29298. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29299. * @param generateMipMaps defines if the engine should generate the mip levels
  29300. * @param invertY defines if data must be stored with Y axis inverted
  29301. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29302. * @param compression defines the compression used (null by default)
  29303. * @returns the cube texture as an InternalTexture
  29304. */
  29305. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29306. /**
  29307. * Creates a new raw cube texture from a specified url
  29308. * @param url defines the url where the data is located
  29309. * @param scene defines the current scene
  29310. * @param size defines the size of the textures
  29311. * @param format defines the format of the data
  29312. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29313. * @param noMipmap defines if the engine should avoid generating the mip levels
  29314. * @param callback defines a callback used to extract texture data from loaded data
  29315. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29316. * @param onLoad defines a callback called when texture is loaded
  29317. * @param onError defines a callback called if there is an error
  29318. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29319. * @param invertY defines if data must be stored with Y axis inverted
  29320. * @returns the cube texture as an InternalTexture
  29321. */
  29322. 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;
  29323. /**
  29324. * Update a raw 3D texture
  29325. * @param texture defines the texture to update
  29326. * @param data defines the data to store
  29327. * @param format defines the data format
  29328. * @param invertY defines if data must be stored with Y axis inverted
  29329. * @param compression defines the used compression (can be null)
  29330. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29331. */
  29332. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29333. /**
  29334. * Creates a new raw 3D texture
  29335. * @param data defines the data used to create the texture
  29336. * @param width defines the width of the texture
  29337. * @param height defines the height of the texture
  29338. * @param depth defines the depth of the texture
  29339. * @param format defines the format of the texture
  29340. * @param generateMipMaps defines if the engine must generate mip levels
  29341. * @param invertY defines if data must be stored with Y axis inverted
  29342. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29343. * @param compression defines the compressed used (can be null)
  29344. * @param textureType defines the compressed used (can be null)
  29345. * @returns a new raw 3D texture (stored in an InternalTexture)
  29346. */
  29347. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29348. private _prepareWebGLTextureContinuation;
  29349. private _prepareWebGLTexture;
  29350. private _convertRGBtoRGBATextureData;
  29351. /** @hidden */
  29352. _releaseFramebufferObjects(texture: InternalTexture): void;
  29353. /** @hidden */
  29354. _releaseTexture(texture: InternalTexture): void;
  29355. private setProgram;
  29356. private _boundUniforms;
  29357. /**
  29358. * Binds an effect to the webGL context
  29359. * @param effect defines the effect to bind
  29360. */
  29361. bindSamplers(effect: Effect): void;
  29362. private _moveBoundTextureOnTop;
  29363. private _getCorrectTextureChannel;
  29364. private _linkTrackers;
  29365. private _removeDesignatedSlot;
  29366. private _activateCurrentTexture;
  29367. /** @hidden */
  29368. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29369. /** @hidden */
  29370. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29371. /**
  29372. * Sets a texture to the webGL context from a postprocess
  29373. * @param channel defines the channel to use
  29374. * @param postProcess defines the source postprocess
  29375. */
  29376. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29377. /**
  29378. * Binds the output of the passed in post process to the texture channel specified
  29379. * @param channel The channel the texture should be bound to
  29380. * @param postProcess The post process which's output should be bound
  29381. */
  29382. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29383. /**
  29384. * Unbind all textures from the webGL context
  29385. */
  29386. unbindAllTextures(): void;
  29387. /**
  29388. * Sets a texture to the according uniform.
  29389. * @param channel The texture channel
  29390. * @param uniform The uniform to set
  29391. * @param texture The texture to apply
  29392. */
  29393. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29394. /**
  29395. * Sets a depth stencil texture from a render target to the according uniform.
  29396. * @param channel The texture channel
  29397. * @param uniform The uniform to set
  29398. * @param texture The render target texture containing the depth stencil texture to apply
  29399. */
  29400. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29401. private _bindSamplerUniformToChannel;
  29402. private _getTextureWrapMode;
  29403. private _setTexture;
  29404. /**
  29405. * Sets an array of texture to the webGL context
  29406. * @param channel defines the channel where the texture array must be set
  29407. * @param uniform defines the associated uniform location
  29408. * @param textures defines the array of textures to bind
  29409. */
  29410. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29411. /** @hidden */
  29412. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29413. private _setTextureParameterFloat;
  29414. private _setTextureParameterInteger;
  29415. /**
  29416. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29417. * @param x defines the x coordinate of the rectangle where pixels must be read
  29418. * @param y defines the y coordinate of the rectangle where pixels must be read
  29419. * @param width defines the width of the rectangle where pixels must be read
  29420. * @param height defines the height of the rectangle where pixels must be read
  29421. * @returns a Uint8Array containing RGBA colors
  29422. */
  29423. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29424. /**
  29425. * Add an externaly attached data from its key.
  29426. * This method call will fail and return false, if such key already exists.
  29427. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29428. * @param key the unique key that identifies the data
  29429. * @param data the data object to associate to the key for this Engine instance
  29430. * @return true if no such key were already present and the data was added successfully, false otherwise
  29431. */
  29432. addExternalData<T>(key: string, data: T): boolean;
  29433. /**
  29434. * Get an externaly attached data from its key
  29435. * @param key the unique key that identifies the data
  29436. * @return the associated data, if present (can be null), or undefined if not present
  29437. */
  29438. getExternalData<T>(key: string): T;
  29439. /**
  29440. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29441. * @param key the unique key that identifies the data
  29442. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29443. * @return the associated data, can be null if the factory returned null.
  29444. */
  29445. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29446. /**
  29447. * Remove an externaly attached data from the Engine instance
  29448. * @param key the unique key that identifies the data
  29449. * @return true if the data was successfully removed, false if it doesn't exist
  29450. */
  29451. removeExternalData(key: string): boolean;
  29452. /**
  29453. * Unbind all vertex attributes from the webGL context
  29454. */
  29455. unbindAllAttributes(): void;
  29456. /**
  29457. * 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
  29458. */
  29459. releaseEffects(): void;
  29460. /**
  29461. * Dispose and release all associated resources
  29462. */
  29463. dispose(): void;
  29464. /**
  29465. * Display the loading screen
  29466. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29467. */
  29468. displayLoadingUI(): void;
  29469. /**
  29470. * Hide the loading screen
  29471. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29472. */
  29473. hideLoadingUI(): void;
  29474. /**
  29475. * Gets the current loading screen object
  29476. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29477. */
  29478. /**
  29479. * Sets the current loading screen object
  29480. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29481. */
  29482. loadingScreen: ILoadingScreen;
  29483. /**
  29484. * Sets the current loading screen text
  29485. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29486. */
  29487. loadingUIText: string;
  29488. /**
  29489. * Sets the current loading screen background color
  29490. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29491. */
  29492. loadingUIBackgroundColor: string;
  29493. /**
  29494. * Attach a new callback raised when context lost event is fired
  29495. * @param callback defines the callback to call
  29496. */
  29497. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29498. /**
  29499. * Attach a new callback raised when context restored event is fired
  29500. * @param callback defines the callback to call
  29501. */
  29502. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29503. /**
  29504. * Gets the source code of the vertex shader associated with a specific webGL program
  29505. * @param program defines the program to use
  29506. * @returns a string containing the source code of the vertex shader associated with the program
  29507. */
  29508. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29509. /**
  29510. * Gets the source code of the fragment shader associated with a specific webGL program
  29511. * @param program defines the program to use
  29512. * @returns a string containing the source code of the fragment shader associated with the program
  29513. */
  29514. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29515. /**
  29516. * Get the current error code of the webGL context
  29517. * @returns the error code
  29518. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29519. */
  29520. getError(): number;
  29521. /**
  29522. * Gets the current framerate
  29523. * @returns a number representing the framerate
  29524. */
  29525. getFps(): number;
  29526. /**
  29527. * Gets the time spent between current and previous frame
  29528. * @returns a number representing the delta time in ms
  29529. */
  29530. getDeltaTime(): number;
  29531. private _measureFps;
  29532. /** @hidden */
  29533. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29534. private _canRenderToFloatFramebuffer;
  29535. private _canRenderToHalfFloatFramebuffer;
  29536. private _canRenderToFramebuffer;
  29537. /** @hidden */
  29538. _getWebGLTextureType(type: number): number;
  29539. private _getInternalFormat;
  29540. /** @hidden */
  29541. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29542. /** @hidden */
  29543. _getRGBAMultiSampleBufferFormat(type: number): number;
  29544. /** @hidden */
  29545. _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;
  29546. /** @hidden */
  29547. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29548. private _partialLoadFile;
  29549. private _cascadeLoadFiles;
  29550. /**
  29551. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29552. * @returns true if the engine can be created
  29553. * @ignorenaming
  29554. */
  29555. static isSupported(): boolean;
  29556. }
  29557. }
  29558. declare module "babylonjs/Materials/effect" {
  29559. import { Observable } from "babylonjs/Misc/observable";
  29560. import { Nullable } from "babylonjs/types";
  29561. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29562. import { Engine } from "babylonjs/Engines/engine";
  29563. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29564. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29565. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29566. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29568. /**
  29569. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29570. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29571. */
  29572. export class EffectFallbacks {
  29573. private _defines;
  29574. private _currentRank;
  29575. private _maxRank;
  29576. private _mesh;
  29577. /**
  29578. * Removes the fallback from the bound mesh.
  29579. */
  29580. unBindMesh(): void;
  29581. /**
  29582. * Adds a fallback on the specified property.
  29583. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29584. * @param define The name of the define in the shader
  29585. */
  29586. addFallback(rank: number, define: string): void;
  29587. /**
  29588. * Sets the mesh to use CPU skinning when needing to fallback.
  29589. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29590. * @param mesh The mesh to use the fallbacks.
  29591. */
  29592. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29593. /**
  29594. * Checks to see if more fallbacks are still availible.
  29595. */
  29596. readonly isMoreFallbacks: boolean;
  29597. /**
  29598. * Removes the defines that shoould be removed when falling back.
  29599. * @param currentDefines defines the current define statements for the shader.
  29600. * @param effect defines the current effect we try to compile
  29601. * @returns The resulting defines with defines of the current rank removed.
  29602. */
  29603. reduce(currentDefines: string, effect: Effect): string;
  29604. }
  29605. /**
  29606. * Options to be used when creating an effect.
  29607. */
  29608. export class EffectCreationOptions {
  29609. /**
  29610. * Atrributes that will be used in the shader.
  29611. */
  29612. attributes: string[];
  29613. /**
  29614. * Uniform varible names that will be set in the shader.
  29615. */
  29616. uniformsNames: string[];
  29617. /**
  29618. * Uniform buffer varible names that will be set in the shader.
  29619. */
  29620. uniformBuffersNames: string[];
  29621. /**
  29622. * Sampler texture variable names that will be set in the shader.
  29623. */
  29624. samplers: string[];
  29625. /**
  29626. * Define statements that will be set in the shader.
  29627. */
  29628. defines: any;
  29629. /**
  29630. * Possible fallbacks for this effect to improve performance when needed.
  29631. */
  29632. fallbacks: Nullable<EffectFallbacks>;
  29633. /**
  29634. * Callback that will be called when the shader is compiled.
  29635. */
  29636. onCompiled: Nullable<(effect: Effect) => void>;
  29637. /**
  29638. * Callback that will be called if an error occurs during shader compilation.
  29639. */
  29640. onError: Nullable<(effect: Effect, errors: string) => void>;
  29641. /**
  29642. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29643. */
  29644. indexParameters: any;
  29645. /**
  29646. * Max number of lights that can be used in the shader.
  29647. */
  29648. maxSimultaneousLights: number;
  29649. /**
  29650. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29651. */
  29652. transformFeedbackVaryings: Nullable<string[]>;
  29653. }
  29654. /**
  29655. * Effect containing vertex and fragment shader that can be executed on an object.
  29656. */
  29657. export class Effect {
  29658. /**
  29659. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29660. */
  29661. static ShadersRepository: string;
  29662. /**
  29663. * Name of the effect.
  29664. */
  29665. name: any;
  29666. /**
  29667. * String container all the define statements that should be set on the shader.
  29668. */
  29669. defines: string;
  29670. /**
  29671. * Callback that will be called when the shader is compiled.
  29672. */
  29673. onCompiled: Nullable<(effect: Effect) => void>;
  29674. /**
  29675. * Callback that will be called if an error occurs during shader compilation.
  29676. */
  29677. onError: Nullable<(effect: Effect, errors: string) => void>;
  29678. /**
  29679. * Callback that will be called when effect is bound.
  29680. */
  29681. onBind: Nullable<(effect: Effect) => void>;
  29682. /**
  29683. * Unique ID of the effect.
  29684. */
  29685. uniqueId: number;
  29686. /**
  29687. * Observable that will be called when the shader is compiled.
  29688. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29689. */
  29690. onCompileObservable: Observable<Effect>;
  29691. /**
  29692. * Observable that will be called if an error occurs during shader compilation.
  29693. */
  29694. onErrorObservable: Observable<Effect>;
  29695. /** @hidden */
  29696. _onBindObservable: Nullable<Observable<Effect>>;
  29697. /**
  29698. * Observable that will be called when effect is bound.
  29699. */
  29700. readonly onBindObservable: Observable<Effect>;
  29701. /** @hidden */
  29702. _bonesComputationForcedToCPU: boolean;
  29703. private static _uniqueIdSeed;
  29704. private _engine;
  29705. private _uniformBuffersNames;
  29706. private _uniformsNames;
  29707. private _samplers;
  29708. private _isReady;
  29709. private _compilationError;
  29710. private _attributesNames;
  29711. private _attributes;
  29712. private _uniforms;
  29713. /**
  29714. * Key for the effect.
  29715. * @hidden
  29716. */
  29717. _key: string;
  29718. private _indexParameters;
  29719. private _fallbacks;
  29720. private _vertexSourceCode;
  29721. private _fragmentSourceCode;
  29722. private _vertexSourceCodeOverride;
  29723. private _fragmentSourceCodeOverride;
  29724. private _transformFeedbackVaryings;
  29725. /**
  29726. * Compiled shader to webGL program.
  29727. * @hidden
  29728. */
  29729. _program: WebGLProgram;
  29730. private _valueCache;
  29731. private static _baseCache;
  29732. /**
  29733. * Instantiates an effect.
  29734. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29735. * @param baseName Name of the effect.
  29736. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29737. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29738. * @param samplers List of sampler variables that will be passed to the shader.
  29739. * @param engine Engine to be used to render the effect
  29740. * @param defines Define statements to be added to the shader.
  29741. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29742. * @param onCompiled Callback that will be called when the shader is compiled.
  29743. * @param onError Callback that will be called if an error occurs during shader compilation.
  29744. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29745. */
  29746. 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);
  29747. /**
  29748. * Unique key for this effect
  29749. */
  29750. readonly key: string;
  29751. /**
  29752. * If the effect has been compiled and prepared.
  29753. * @returns if the effect is compiled and prepared.
  29754. */
  29755. isReady(): boolean;
  29756. /**
  29757. * The engine the effect was initialized with.
  29758. * @returns the engine.
  29759. */
  29760. getEngine(): Engine;
  29761. /**
  29762. * The compiled webGL program for the effect
  29763. * @returns the webGL program.
  29764. */
  29765. getProgram(): WebGLProgram;
  29766. /**
  29767. * The set of names of attribute variables for the shader.
  29768. * @returns An array of attribute names.
  29769. */
  29770. getAttributesNames(): string[];
  29771. /**
  29772. * Returns the attribute at the given index.
  29773. * @param index The index of the attribute.
  29774. * @returns The location of the attribute.
  29775. */
  29776. getAttributeLocation(index: number): number;
  29777. /**
  29778. * Returns the attribute based on the name of the variable.
  29779. * @param name of the attribute to look up.
  29780. * @returns the attribute location.
  29781. */
  29782. getAttributeLocationByName(name: string): number;
  29783. /**
  29784. * The number of attributes.
  29785. * @returns the numnber of attributes.
  29786. */
  29787. getAttributesCount(): number;
  29788. /**
  29789. * Gets the index of a uniform variable.
  29790. * @param uniformName of the uniform to look up.
  29791. * @returns the index.
  29792. */
  29793. getUniformIndex(uniformName: string): number;
  29794. /**
  29795. * Returns the attribute based on the name of the variable.
  29796. * @param uniformName of the uniform to look up.
  29797. * @returns the location of the uniform.
  29798. */
  29799. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29800. /**
  29801. * Returns an array of sampler variable names
  29802. * @returns The array of sampler variable neames.
  29803. */
  29804. getSamplers(): string[];
  29805. /**
  29806. * The error from the last compilation.
  29807. * @returns the error string.
  29808. */
  29809. getCompilationError(): string;
  29810. /**
  29811. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29812. * @param func The callback to be used.
  29813. */
  29814. executeWhenCompiled(func: (effect: Effect) => void): void;
  29815. private _checkIsReady;
  29816. /** @hidden */
  29817. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29818. /** @hidden */
  29819. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29820. /** @hidden */
  29821. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29822. private _processShaderConversion;
  29823. private _processIncludes;
  29824. private _processPrecision;
  29825. /**
  29826. * Recompiles the webGL program
  29827. * @param vertexSourceCode The source code for the vertex shader.
  29828. * @param fragmentSourceCode The source code for the fragment shader.
  29829. * @param onCompiled Callback called when completed.
  29830. * @param onError Callback called on error.
  29831. * @hidden
  29832. */
  29833. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29834. /**
  29835. * Gets the uniform locations of the the specified variable names
  29836. * @param names THe names of the variables to lookup.
  29837. * @returns Array of locations in the same order as variable names.
  29838. */
  29839. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29840. /**
  29841. * Prepares the effect
  29842. * @hidden
  29843. */
  29844. _prepareEffect(): void;
  29845. /**
  29846. * Checks if the effect is supported. (Must be called after compilation)
  29847. */
  29848. readonly isSupported: boolean;
  29849. /**
  29850. * Binds a texture to the engine to be used as output of the shader.
  29851. * @param channel Name of the output variable.
  29852. * @param texture Texture to bind.
  29853. * @hidden
  29854. */
  29855. _bindTexture(channel: string, texture: InternalTexture): void;
  29856. /**
  29857. * Sets a texture on the engine to be used in the shader.
  29858. * @param channel Name of the sampler variable.
  29859. * @param texture Texture to set.
  29860. */
  29861. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29862. /**
  29863. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29864. * @param channel Name of the sampler variable.
  29865. * @param texture Texture to set.
  29866. */
  29867. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29868. /**
  29869. * Sets an array of textures on the engine to be used in the shader.
  29870. * @param channel Name of the variable.
  29871. * @param textures Textures to set.
  29872. */
  29873. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29874. /**
  29875. * 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)
  29876. * @param channel Name of the sampler variable.
  29877. * @param postProcess Post process to get the input texture from.
  29878. */
  29879. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29880. /**
  29881. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29882. * 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)
  29883. * @param channel Name of the sampler variable.
  29884. * @param postProcess Post process to get the output texture from.
  29885. */
  29886. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29887. /** @hidden */
  29888. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29889. /** @hidden */
  29890. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29891. /** @hidden */
  29892. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29893. /** @hidden */
  29894. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29895. /**
  29896. * Binds a buffer to a uniform.
  29897. * @param buffer Buffer to bind.
  29898. * @param name Name of the uniform variable to bind to.
  29899. */
  29900. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29901. /**
  29902. * Binds block to a uniform.
  29903. * @param blockName Name of the block to bind.
  29904. * @param index Index to bind.
  29905. */
  29906. bindUniformBlock(blockName: string, index: number): void;
  29907. /**
  29908. * Sets an interger value on a uniform variable.
  29909. * @param uniformName Name of the variable.
  29910. * @param value Value to be set.
  29911. * @returns this effect.
  29912. */
  29913. setInt(uniformName: string, value: number): Effect;
  29914. /**
  29915. * Sets an int array on a uniform variable.
  29916. * @param uniformName Name of the variable.
  29917. * @param array array to be set.
  29918. * @returns this effect.
  29919. */
  29920. setIntArray(uniformName: string, array: Int32Array): Effect;
  29921. /**
  29922. * 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)
  29923. * @param uniformName Name of the variable.
  29924. * @param array array to be set.
  29925. * @returns this effect.
  29926. */
  29927. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29928. /**
  29929. * 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)
  29930. * @param uniformName Name of the variable.
  29931. * @param array array to be set.
  29932. * @returns this effect.
  29933. */
  29934. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29935. /**
  29936. * 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)
  29937. * @param uniformName Name of the variable.
  29938. * @param array array to be set.
  29939. * @returns this effect.
  29940. */
  29941. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29942. /**
  29943. * Sets an float array on a uniform variable.
  29944. * @param uniformName Name of the variable.
  29945. * @param array array to be set.
  29946. * @returns this effect.
  29947. */
  29948. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29949. /**
  29950. * 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)
  29951. * @param uniformName Name of the variable.
  29952. * @param array array to be set.
  29953. * @returns this effect.
  29954. */
  29955. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29956. /**
  29957. * 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)
  29958. * @param uniformName Name of the variable.
  29959. * @param array array to be set.
  29960. * @returns this effect.
  29961. */
  29962. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29963. /**
  29964. * 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)
  29965. * @param uniformName Name of the variable.
  29966. * @param array array to be set.
  29967. * @returns this effect.
  29968. */
  29969. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29970. /**
  29971. * Sets an array on a uniform variable.
  29972. * @param uniformName Name of the variable.
  29973. * @param array array to be set.
  29974. * @returns this effect.
  29975. */
  29976. setArray(uniformName: string, array: number[]): Effect;
  29977. /**
  29978. * 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)
  29979. * @param uniformName Name of the variable.
  29980. * @param array array to be set.
  29981. * @returns this effect.
  29982. */
  29983. setArray2(uniformName: string, array: number[]): Effect;
  29984. /**
  29985. * 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)
  29986. * @param uniformName Name of the variable.
  29987. * @param array array to be set.
  29988. * @returns this effect.
  29989. */
  29990. setArray3(uniformName: string, array: number[]): Effect;
  29991. /**
  29992. * 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)
  29993. * @param uniformName Name of the variable.
  29994. * @param array array to be set.
  29995. * @returns this effect.
  29996. */
  29997. setArray4(uniformName: string, array: number[]): Effect;
  29998. /**
  29999. * Sets matrices on a uniform variable.
  30000. * @param uniformName Name of the variable.
  30001. * @param matrices matrices to be set.
  30002. * @returns this effect.
  30003. */
  30004. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30005. /**
  30006. * Sets matrix on a uniform variable.
  30007. * @param uniformName Name of the variable.
  30008. * @param matrix matrix to be set.
  30009. * @returns this effect.
  30010. */
  30011. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30012. /**
  30013. * 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)
  30014. * @param uniformName Name of the variable.
  30015. * @param matrix matrix to be set.
  30016. * @returns this effect.
  30017. */
  30018. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30019. /**
  30020. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30021. * @param uniformName Name of the variable.
  30022. * @param matrix matrix to be set.
  30023. * @returns this effect.
  30024. */
  30025. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30026. /**
  30027. * Sets a float on a uniform variable.
  30028. * @param uniformName Name of the variable.
  30029. * @param value value to be set.
  30030. * @returns this effect.
  30031. */
  30032. setFloat(uniformName: string, value: number): Effect;
  30033. /**
  30034. * Sets a boolean on a uniform variable.
  30035. * @param uniformName Name of the variable.
  30036. * @param bool value to be set.
  30037. * @returns this effect.
  30038. */
  30039. setBool(uniformName: string, bool: boolean): Effect;
  30040. /**
  30041. * Sets a Vector2 on a uniform variable.
  30042. * @param uniformName Name of the variable.
  30043. * @param vector2 vector2 to be set.
  30044. * @returns this effect.
  30045. */
  30046. setVector2(uniformName: string, vector2: Vector2): Effect;
  30047. /**
  30048. * Sets a float2 on a uniform variable.
  30049. * @param uniformName Name of the variable.
  30050. * @param x First float in float2.
  30051. * @param y Second float in float2.
  30052. * @returns this effect.
  30053. */
  30054. setFloat2(uniformName: string, x: number, y: number): Effect;
  30055. /**
  30056. * Sets a Vector3 on a uniform variable.
  30057. * @param uniformName Name of the variable.
  30058. * @param vector3 Value to be set.
  30059. * @returns this effect.
  30060. */
  30061. setVector3(uniformName: string, vector3: Vector3): Effect;
  30062. /**
  30063. * Sets a float3 on a uniform variable.
  30064. * @param uniformName Name of the variable.
  30065. * @param x First float in float3.
  30066. * @param y Second float in float3.
  30067. * @param z Third float in float3.
  30068. * @returns this effect.
  30069. */
  30070. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30071. /**
  30072. * Sets a Vector4 on a uniform variable.
  30073. * @param uniformName Name of the variable.
  30074. * @param vector4 Value to be set.
  30075. * @returns this effect.
  30076. */
  30077. setVector4(uniformName: string, vector4: Vector4): Effect;
  30078. /**
  30079. * Sets a float4 on a uniform variable.
  30080. * @param uniformName Name of the variable.
  30081. * @param x First float in float4.
  30082. * @param y Second float in float4.
  30083. * @param z Third float in float4.
  30084. * @param w Fourth float in float4.
  30085. * @returns this effect.
  30086. */
  30087. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30088. /**
  30089. * Sets a Color3 on a uniform variable.
  30090. * @param uniformName Name of the variable.
  30091. * @param color3 Value to be set.
  30092. * @returns this effect.
  30093. */
  30094. setColor3(uniformName: string, color3: Color3): Effect;
  30095. /**
  30096. * Sets a Color4 on a uniform variable.
  30097. * @param uniformName Name of the variable.
  30098. * @param color3 Value to be set.
  30099. * @param alpha Alpha value to be set.
  30100. * @returns this effect.
  30101. */
  30102. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30103. /**
  30104. * Sets a Color4 on a uniform variable
  30105. * @param uniformName defines the name of the variable
  30106. * @param color4 defines the value to be set
  30107. * @returns this effect.
  30108. */
  30109. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30110. /**
  30111. * This function will add a new shader to the shader store
  30112. * @param name the name of the shader
  30113. * @param pixelShader optional pixel shader content
  30114. * @param vertexShader optional vertex shader content
  30115. */
  30116. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30117. /**
  30118. * Store of each shader (The can be looked up using effect.key)
  30119. */
  30120. static ShadersStore: {
  30121. [key: string]: string;
  30122. };
  30123. /**
  30124. * Store of each included file for a shader (The can be looked up using effect.key)
  30125. */
  30126. static IncludesShadersStore: {
  30127. [key: string]: string;
  30128. };
  30129. /**
  30130. * Resets the cache of effects.
  30131. */
  30132. static ResetCache(): void;
  30133. }
  30134. }
  30135. declare module "babylonjs/Materials/colorCurves" {
  30136. import { Effect } from "babylonjs/Materials/effect";
  30137. /**
  30138. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30139. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30140. * 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;
  30141. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30142. */
  30143. export class ColorCurves {
  30144. private _dirty;
  30145. private _tempColor;
  30146. private _globalCurve;
  30147. private _highlightsCurve;
  30148. private _midtonesCurve;
  30149. private _shadowsCurve;
  30150. private _positiveCurve;
  30151. private _negativeCurve;
  30152. private _globalHue;
  30153. private _globalDensity;
  30154. private _globalSaturation;
  30155. private _globalExposure;
  30156. /**
  30157. * Gets the global Hue value.
  30158. * 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).
  30159. */
  30160. /**
  30161. * Sets the global Hue value.
  30162. * 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).
  30163. */
  30164. globalHue: number;
  30165. /**
  30166. * Gets the global Density value.
  30167. * 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.
  30168. * Values less than zero provide a filter of opposite hue.
  30169. */
  30170. /**
  30171. * Sets the global Density value.
  30172. * 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.
  30173. * Values less than zero provide a filter of opposite hue.
  30174. */
  30175. globalDensity: number;
  30176. /**
  30177. * Gets the global Saturation value.
  30178. * 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.
  30179. */
  30180. /**
  30181. * Sets the global Saturation value.
  30182. * 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.
  30183. */
  30184. globalSaturation: number;
  30185. /**
  30186. * Gets the global Exposure value.
  30187. * 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.
  30188. */
  30189. /**
  30190. * Sets the global Exposure value.
  30191. * 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.
  30192. */
  30193. globalExposure: number;
  30194. private _highlightsHue;
  30195. private _highlightsDensity;
  30196. private _highlightsSaturation;
  30197. private _highlightsExposure;
  30198. /**
  30199. * Gets the highlights Hue value.
  30200. * 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).
  30201. */
  30202. /**
  30203. * Sets the highlights Hue value.
  30204. * 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).
  30205. */
  30206. highlightsHue: number;
  30207. /**
  30208. * Gets the highlights Density value.
  30209. * 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.
  30210. * Values less than zero provide a filter of opposite hue.
  30211. */
  30212. /**
  30213. * Sets the highlights Density value.
  30214. * 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.
  30215. * Values less than zero provide a filter of opposite hue.
  30216. */
  30217. highlightsDensity: number;
  30218. /**
  30219. * Gets the highlights Saturation value.
  30220. * 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.
  30221. */
  30222. /**
  30223. * Sets the highlights Saturation value.
  30224. * 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.
  30225. */
  30226. highlightsSaturation: number;
  30227. /**
  30228. * Gets the highlights Exposure value.
  30229. * 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.
  30230. */
  30231. /**
  30232. * Sets the highlights Exposure value.
  30233. * 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.
  30234. */
  30235. highlightsExposure: number;
  30236. private _midtonesHue;
  30237. private _midtonesDensity;
  30238. private _midtonesSaturation;
  30239. private _midtonesExposure;
  30240. /**
  30241. * Gets the midtones Hue value.
  30242. * 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).
  30243. */
  30244. /**
  30245. * Sets the midtones Hue value.
  30246. * 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).
  30247. */
  30248. midtonesHue: number;
  30249. /**
  30250. * Gets the midtones Density value.
  30251. * 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.
  30252. * Values less than zero provide a filter of opposite hue.
  30253. */
  30254. /**
  30255. * Sets the midtones Density value.
  30256. * 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.
  30257. * Values less than zero provide a filter of opposite hue.
  30258. */
  30259. midtonesDensity: number;
  30260. /**
  30261. * Gets the midtones Saturation value.
  30262. * 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.
  30263. */
  30264. /**
  30265. * Sets the midtones Saturation value.
  30266. * 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.
  30267. */
  30268. midtonesSaturation: number;
  30269. /**
  30270. * Gets the midtones Exposure value.
  30271. * 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.
  30272. */
  30273. /**
  30274. * Sets the midtones Exposure value.
  30275. * 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.
  30276. */
  30277. midtonesExposure: number;
  30278. private _shadowsHue;
  30279. private _shadowsDensity;
  30280. private _shadowsSaturation;
  30281. private _shadowsExposure;
  30282. /**
  30283. * Gets the shadows Hue value.
  30284. * 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).
  30285. */
  30286. /**
  30287. * Sets the shadows Hue value.
  30288. * 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).
  30289. */
  30290. shadowsHue: number;
  30291. /**
  30292. * Gets the shadows Density value.
  30293. * 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.
  30294. * Values less than zero provide a filter of opposite hue.
  30295. */
  30296. /**
  30297. * Sets the shadows Density value.
  30298. * 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.
  30299. * Values less than zero provide a filter of opposite hue.
  30300. */
  30301. shadowsDensity: number;
  30302. /**
  30303. * Gets the shadows Saturation value.
  30304. * 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.
  30305. */
  30306. /**
  30307. * Sets the shadows Saturation value.
  30308. * 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.
  30309. */
  30310. shadowsSaturation: number;
  30311. /**
  30312. * Gets the shadows Exposure value.
  30313. * 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.
  30314. */
  30315. /**
  30316. * Sets the shadows Exposure value.
  30317. * 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.
  30318. */
  30319. shadowsExposure: number;
  30320. /**
  30321. * Returns the class name
  30322. * @returns The class name
  30323. */
  30324. getClassName(): string;
  30325. /**
  30326. * Binds the color curves to the shader.
  30327. * @param colorCurves The color curve to bind
  30328. * @param effect The effect to bind to
  30329. * @param positiveUniform The positive uniform shader parameter
  30330. * @param neutralUniform The neutral uniform shader parameter
  30331. * @param negativeUniform The negative uniform shader parameter
  30332. */
  30333. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30334. /**
  30335. * Prepare the list of uniforms associated with the ColorCurves effects.
  30336. * @param uniformsList The list of uniforms used in the effect
  30337. */
  30338. static PrepareUniforms(uniformsList: string[]): void;
  30339. /**
  30340. * Returns color grading data based on a hue, density, saturation and exposure value.
  30341. * @param filterHue The hue of the color filter.
  30342. * @param filterDensity The density of the color filter.
  30343. * @param saturation The saturation.
  30344. * @param exposure The exposure.
  30345. * @param result The result data container.
  30346. */
  30347. private getColorGradingDataToRef;
  30348. /**
  30349. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30350. * @param value The input slider value in range [-100,100].
  30351. * @returns Adjusted value.
  30352. */
  30353. private static applyColorGradingSliderNonlinear;
  30354. /**
  30355. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30356. * @param hue The hue (H) input.
  30357. * @param saturation The saturation (S) input.
  30358. * @param brightness The brightness (B) input.
  30359. * @result An RGBA color represented as Vector4.
  30360. */
  30361. private static fromHSBToRef;
  30362. /**
  30363. * Returns a value clamped between min and max
  30364. * @param value The value to clamp
  30365. * @param min The minimum of value
  30366. * @param max The maximum of value
  30367. * @returns The clamped value.
  30368. */
  30369. private static clamp;
  30370. /**
  30371. * Clones the current color curve instance.
  30372. * @return The cloned curves
  30373. */
  30374. clone(): ColorCurves;
  30375. /**
  30376. * Serializes the current color curve instance to a json representation.
  30377. * @return a JSON representation
  30378. */
  30379. serialize(): any;
  30380. /**
  30381. * Parses the color curve from a json representation.
  30382. * @param source the JSON source to parse
  30383. * @return The parsed curves
  30384. */
  30385. static Parse(source: any): ColorCurves;
  30386. }
  30387. }
  30388. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30389. import { Observable } from "babylonjs/Misc/observable";
  30390. import { Nullable } from "babylonjs/types";
  30391. import { Color4 } from "babylonjs/Maths/math";
  30392. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30393. import { Effect } from "babylonjs/Materials/effect";
  30394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30395. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30396. /**
  30397. * Interface to follow in your material defines to integrate easily the
  30398. * Image proccessing functions.
  30399. * @hidden
  30400. */
  30401. export interface IImageProcessingConfigurationDefines {
  30402. IMAGEPROCESSING: boolean;
  30403. VIGNETTE: boolean;
  30404. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30405. VIGNETTEBLENDMODEOPAQUE: boolean;
  30406. TONEMAPPING: boolean;
  30407. TONEMAPPING_ACES: boolean;
  30408. CONTRAST: boolean;
  30409. EXPOSURE: boolean;
  30410. COLORCURVES: boolean;
  30411. COLORGRADING: boolean;
  30412. COLORGRADING3D: boolean;
  30413. SAMPLER3DGREENDEPTH: boolean;
  30414. SAMPLER3DBGRMAP: boolean;
  30415. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30416. }
  30417. /**
  30418. * @hidden
  30419. */
  30420. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30421. IMAGEPROCESSING: boolean;
  30422. VIGNETTE: boolean;
  30423. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30424. VIGNETTEBLENDMODEOPAQUE: boolean;
  30425. TONEMAPPING: boolean;
  30426. TONEMAPPING_ACES: boolean;
  30427. CONTRAST: boolean;
  30428. COLORCURVES: boolean;
  30429. COLORGRADING: boolean;
  30430. COLORGRADING3D: boolean;
  30431. SAMPLER3DGREENDEPTH: boolean;
  30432. SAMPLER3DBGRMAP: boolean;
  30433. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30434. EXPOSURE: boolean;
  30435. constructor();
  30436. }
  30437. /**
  30438. * This groups together the common properties used for image processing either in direct forward pass
  30439. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30440. * or not.
  30441. */
  30442. export class ImageProcessingConfiguration {
  30443. /**
  30444. * Default tone mapping applied in BabylonJS.
  30445. */
  30446. static readonly TONEMAPPING_STANDARD: number;
  30447. /**
  30448. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30449. * to other engines rendering to increase portability.
  30450. */
  30451. static readonly TONEMAPPING_ACES: number;
  30452. /**
  30453. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30454. */
  30455. colorCurves: Nullable<ColorCurves>;
  30456. private _colorCurvesEnabled;
  30457. /**
  30458. * Gets wether the color curves effect is enabled.
  30459. */
  30460. /**
  30461. * Sets wether the color curves effect is enabled.
  30462. */
  30463. colorCurvesEnabled: boolean;
  30464. private _colorGradingTexture;
  30465. /**
  30466. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30467. */
  30468. /**
  30469. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30470. */
  30471. colorGradingTexture: Nullable<BaseTexture>;
  30472. private _colorGradingEnabled;
  30473. /**
  30474. * Gets wether the color grading effect is enabled.
  30475. */
  30476. /**
  30477. * Sets wether the color grading effect is enabled.
  30478. */
  30479. colorGradingEnabled: boolean;
  30480. private _colorGradingWithGreenDepth;
  30481. /**
  30482. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30483. */
  30484. /**
  30485. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30486. */
  30487. colorGradingWithGreenDepth: boolean;
  30488. private _colorGradingBGR;
  30489. /**
  30490. * Gets wether the color grading texture contains BGR values.
  30491. */
  30492. /**
  30493. * Sets wether the color grading texture contains BGR values.
  30494. */
  30495. colorGradingBGR: boolean;
  30496. /** @hidden */
  30497. _exposure: number;
  30498. /**
  30499. * Gets the Exposure used in the effect.
  30500. */
  30501. /**
  30502. * Sets the Exposure used in the effect.
  30503. */
  30504. exposure: number;
  30505. private _toneMappingEnabled;
  30506. /**
  30507. * Gets wether the tone mapping effect is enabled.
  30508. */
  30509. /**
  30510. * Sets wether the tone mapping effect is enabled.
  30511. */
  30512. toneMappingEnabled: boolean;
  30513. private _toneMappingType;
  30514. /**
  30515. * Gets the type of tone mapping effect.
  30516. */
  30517. /**
  30518. * Sets the type of tone mapping effect used in BabylonJS.
  30519. */
  30520. toneMappingType: number;
  30521. protected _contrast: number;
  30522. /**
  30523. * Gets the contrast used in the effect.
  30524. */
  30525. /**
  30526. * Sets the contrast used in the effect.
  30527. */
  30528. contrast: number;
  30529. /**
  30530. * Vignette stretch size.
  30531. */
  30532. vignetteStretch: number;
  30533. /**
  30534. * Vignette centre X Offset.
  30535. */
  30536. vignetteCentreX: number;
  30537. /**
  30538. * Vignette centre Y Offset.
  30539. */
  30540. vignetteCentreY: number;
  30541. /**
  30542. * Vignette weight or intensity of the vignette effect.
  30543. */
  30544. vignetteWeight: number;
  30545. /**
  30546. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30547. * if vignetteEnabled is set to true.
  30548. */
  30549. vignetteColor: Color4;
  30550. /**
  30551. * Camera field of view used by the Vignette effect.
  30552. */
  30553. vignetteCameraFov: number;
  30554. private _vignetteBlendMode;
  30555. /**
  30556. * Gets the vignette blend mode allowing different kind of effect.
  30557. */
  30558. /**
  30559. * Sets the vignette blend mode allowing different kind of effect.
  30560. */
  30561. vignetteBlendMode: number;
  30562. private _vignetteEnabled;
  30563. /**
  30564. * Gets wether the vignette effect is enabled.
  30565. */
  30566. /**
  30567. * Sets wether the vignette effect is enabled.
  30568. */
  30569. vignetteEnabled: boolean;
  30570. private _applyByPostProcess;
  30571. /**
  30572. * Gets wether the image processing is applied through a post process or not.
  30573. */
  30574. /**
  30575. * Sets wether the image processing is applied through a post process or not.
  30576. */
  30577. applyByPostProcess: boolean;
  30578. private _isEnabled;
  30579. /**
  30580. * Gets wether the image processing is enabled or not.
  30581. */
  30582. /**
  30583. * Sets wether the image processing is enabled or not.
  30584. */
  30585. isEnabled: boolean;
  30586. /**
  30587. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30588. */
  30589. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30590. /**
  30591. * Method called each time the image processing information changes requires to recompile the effect.
  30592. */
  30593. protected _updateParameters(): void;
  30594. /**
  30595. * Gets the current class name.
  30596. * @return "ImageProcessingConfiguration"
  30597. */
  30598. getClassName(): string;
  30599. /**
  30600. * Prepare the list of uniforms associated with the Image Processing effects.
  30601. * @param uniforms The list of uniforms used in the effect
  30602. * @param defines the list of defines currently in use
  30603. */
  30604. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30605. /**
  30606. * Prepare the list of samplers associated with the Image Processing effects.
  30607. * @param samplersList The list of uniforms used in the effect
  30608. * @param defines the list of defines currently in use
  30609. */
  30610. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30611. /**
  30612. * Prepare the list of defines associated to the shader.
  30613. * @param defines the list of defines to complete
  30614. * @param forPostProcess Define if we are currently in post process mode or not
  30615. */
  30616. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30617. /**
  30618. * Returns true if all the image processing information are ready.
  30619. * @returns True if ready, otherwise, false
  30620. */
  30621. isReady(): boolean;
  30622. /**
  30623. * Binds the image processing to the shader.
  30624. * @param effect The effect to bind to
  30625. * @param aspectRatio Define the current aspect ratio of the effect
  30626. */
  30627. bind(effect: Effect, aspectRatio?: number): void;
  30628. /**
  30629. * Clones the current image processing instance.
  30630. * @return The cloned image processing
  30631. */
  30632. clone(): ImageProcessingConfiguration;
  30633. /**
  30634. * Serializes the current image processing instance to a json representation.
  30635. * @return a JSON representation
  30636. */
  30637. serialize(): any;
  30638. /**
  30639. * Parses the image processing from a json representation.
  30640. * @param source the JSON source to parse
  30641. * @return The parsed image processing
  30642. */
  30643. static Parse(source: any): ImageProcessingConfiguration;
  30644. private static _VIGNETTEMODE_MULTIPLY;
  30645. private static _VIGNETTEMODE_OPAQUE;
  30646. /**
  30647. * Used to apply the vignette as a mix with the pixel color.
  30648. */
  30649. static readonly VIGNETTEMODE_MULTIPLY: number;
  30650. /**
  30651. * Used to apply the vignette as a replacement of the pixel color.
  30652. */
  30653. static readonly VIGNETTEMODE_OPAQUE: number;
  30654. }
  30655. }
  30656. declare module "babylonjs/Materials/fresnelParameters" {
  30657. import { Color3 } from "babylonjs/Maths/math";
  30658. /**
  30659. * This represents all the required information to add a fresnel effect on a material:
  30660. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30661. */
  30662. export class FresnelParameters {
  30663. private _isEnabled;
  30664. /**
  30665. * Define if the fresnel effect is enable or not.
  30666. */
  30667. isEnabled: boolean;
  30668. /**
  30669. * Define the color used on edges (grazing angle)
  30670. */
  30671. leftColor: Color3;
  30672. /**
  30673. * Define the color used on center
  30674. */
  30675. rightColor: Color3;
  30676. /**
  30677. * Define bias applied to computed fresnel term
  30678. */
  30679. bias: number;
  30680. /**
  30681. * Defined the power exponent applied to fresnel term
  30682. */
  30683. power: number;
  30684. /**
  30685. * Clones the current fresnel and its valuues
  30686. * @returns a clone fresnel configuration
  30687. */
  30688. clone(): FresnelParameters;
  30689. /**
  30690. * Serializes the current fresnel parameters to a JSON representation.
  30691. * @return the JSON serialization
  30692. */
  30693. serialize(): any;
  30694. /**
  30695. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30696. * @param parsedFresnelParameters Define the JSON representation
  30697. * @returns the parsed parameters
  30698. */
  30699. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30700. }
  30701. }
  30702. declare module "babylonjs/Misc/decorators" {
  30703. import { Nullable } from "babylonjs/types";
  30704. import { Scene } from "babylonjs/scene";
  30705. import { IAnimatable } from "babylonjs/Misc/tools";
  30706. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30707. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30708. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30709. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30710. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30711. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30712. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30713. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30714. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30715. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30716. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30717. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30718. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30719. /**
  30720. * Decorator used to define property that can be serialized as reference to a camera
  30721. * @param sourceName defines the name of the property to decorate
  30722. */
  30723. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30724. /**
  30725. * Class used to help serialization objects
  30726. */
  30727. export class SerializationHelper {
  30728. /** hidden */
  30729. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30730. /** hidden */
  30731. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30732. /** hidden */
  30733. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30734. /** hidden */
  30735. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30736. /**
  30737. * Appends the serialized animations from the source animations
  30738. * @param source Source containing the animations
  30739. * @param destination Target to store the animations
  30740. */
  30741. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30742. /**
  30743. * Static function used to serialized a specific entity
  30744. * @param entity defines the entity to serialize
  30745. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30746. * @returns a JSON compatible object representing the serialization of the entity
  30747. */
  30748. static Serialize<T>(entity: T, serializationObject?: any): any;
  30749. /**
  30750. * Creates a new entity from a serialization data object
  30751. * @param creationFunction defines a function used to instanciated the new entity
  30752. * @param source defines the source serialization data
  30753. * @param scene defines the hosting scene
  30754. * @param rootUrl defines the root url for resources
  30755. * @returns a new entity
  30756. */
  30757. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30758. /**
  30759. * Clones an object
  30760. * @param creationFunction defines the function used to instanciate the new object
  30761. * @param source defines the source object
  30762. * @returns the cloned object
  30763. */
  30764. static Clone<T>(creationFunction: () => T, source: T): T;
  30765. /**
  30766. * Instanciates a new object based on a source one (some data will be shared between both object)
  30767. * @param creationFunction defines the function used to instanciate the new object
  30768. * @param source defines the source object
  30769. * @returns the new object
  30770. */
  30771. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30772. }
  30773. }
  30774. declare module "babylonjs/Cameras/camera" {
  30775. import { SmartArray } from "babylonjs/Misc/smartArray";
  30776. import { Observable } from "babylonjs/Misc/observable";
  30777. import { Nullable } from "babylonjs/types";
  30778. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30779. import { Scene } from "babylonjs/scene";
  30780. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30781. import { Node } from "babylonjs/node";
  30782. import { Mesh } from "babylonjs/Meshes/mesh";
  30783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30784. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30785. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30786. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30787. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30788. import { Ray } from "babylonjs/Culling/ray";
  30789. /**
  30790. * This is the base class of all the camera used in the application.
  30791. * @see http://doc.babylonjs.com/features/cameras
  30792. */
  30793. export class Camera extends Node {
  30794. /** @hidden */
  30795. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30796. /**
  30797. * This is the default projection mode used by the cameras.
  30798. * It helps recreating a feeling of perspective and better appreciate depth.
  30799. * This is the best way to simulate real life cameras.
  30800. */
  30801. static readonly PERSPECTIVE_CAMERA: number;
  30802. /**
  30803. * This helps creating camera with an orthographic mode.
  30804. * 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.
  30805. */
  30806. static readonly ORTHOGRAPHIC_CAMERA: number;
  30807. /**
  30808. * This is the default FOV mode for perspective cameras.
  30809. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30810. */
  30811. static readonly FOVMODE_VERTICAL_FIXED: number;
  30812. /**
  30813. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30814. */
  30815. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30816. /**
  30817. * This specifies ther is no need for a camera rig.
  30818. * Basically only one eye is rendered corresponding to the camera.
  30819. */
  30820. static readonly RIG_MODE_NONE: number;
  30821. /**
  30822. * Simulates a camera Rig with one blue eye and one red eye.
  30823. * This can be use with 3d blue and red glasses.
  30824. */
  30825. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30826. /**
  30827. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30828. */
  30829. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30830. /**
  30831. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30832. */
  30833. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30834. /**
  30835. * Defines that both eyes of the camera will be rendered over under each other.
  30836. */
  30837. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30838. /**
  30839. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30840. */
  30841. static readonly RIG_MODE_VR: number;
  30842. /**
  30843. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30844. */
  30845. static readonly RIG_MODE_WEBVR: number;
  30846. /**
  30847. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30848. */
  30849. static readonly RIG_MODE_CUSTOM: number;
  30850. /**
  30851. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30852. */
  30853. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30854. /**
  30855. * Define the input manager associated with the camera.
  30856. */
  30857. inputs: CameraInputsManager<Camera>;
  30858. /** @hidden */
  30859. _position: Vector3;
  30860. /**
  30861. * Define the current local position of the camera in the scene
  30862. */
  30863. position: Vector3;
  30864. /**
  30865. * The vector the camera should consider as up.
  30866. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30867. */
  30868. upVector: Vector3;
  30869. /**
  30870. * Define the current limit on the left side for an orthographic camera
  30871. * In scene unit
  30872. */
  30873. orthoLeft: Nullable<number>;
  30874. /**
  30875. * Define the current limit on the right side for an orthographic camera
  30876. * In scene unit
  30877. */
  30878. orthoRight: Nullable<number>;
  30879. /**
  30880. * Define the current limit on the bottom side for an orthographic camera
  30881. * In scene unit
  30882. */
  30883. orthoBottom: Nullable<number>;
  30884. /**
  30885. * Define the current limit on the top side for an orthographic camera
  30886. * In scene unit
  30887. */
  30888. orthoTop: Nullable<number>;
  30889. /**
  30890. * Field Of View is set in Radians. (default is 0.8)
  30891. */
  30892. fov: number;
  30893. /**
  30894. * Define the minimum distance the camera can see from.
  30895. * This is important to note that the depth buffer are not infinite and the closer it starts
  30896. * the more your scene might encounter depth fighting issue.
  30897. */
  30898. minZ: number;
  30899. /**
  30900. * Define the maximum distance the camera can see to.
  30901. * This is important to note that the depth buffer are not infinite and the further it end
  30902. * the more your scene might encounter depth fighting issue.
  30903. */
  30904. maxZ: number;
  30905. /**
  30906. * Define the default inertia of the camera.
  30907. * This helps giving a smooth feeling to the camera movement.
  30908. */
  30909. inertia: number;
  30910. /**
  30911. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30912. */
  30913. mode: number;
  30914. /**
  30915. * Define wether the camera is intermediate.
  30916. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30917. */
  30918. isIntermediate: boolean;
  30919. /**
  30920. * Define the viewport of the camera.
  30921. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30922. */
  30923. viewport: Viewport;
  30924. /**
  30925. * Restricts the camera to viewing objects with the same layerMask.
  30926. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30927. */
  30928. layerMask: number;
  30929. /**
  30930. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30931. */
  30932. fovMode: number;
  30933. /**
  30934. * Rig mode of the camera.
  30935. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30936. * This is normally controlled byt the camera themselves as internal use.
  30937. */
  30938. cameraRigMode: number;
  30939. /**
  30940. * Defines the distance between both "eyes" in case of a RIG
  30941. */
  30942. interaxialDistance: number;
  30943. /**
  30944. * Defines if stereoscopic rendering is done side by side or over under.
  30945. */
  30946. isStereoscopicSideBySide: boolean;
  30947. /**
  30948. * 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
  30949. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30950. * else in the scene.
  30951. */
  30952. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30953. /**
  30954. * When set, the camera will render to this render target instead of the default canvas
  30955. */
  30956. outputRenderTarget: Nullable<RenderTargetTexture>;
  30957. /**
  30958. * Observable triggered when the camera view matrix has changed.
  30959. */
  30960. onViewMatrixChangedObservable: Observable<Camera>;
  30961. /**
  30962. * Observable triggered when the camera Projection matrix has changed.
  30963. */
  30964. onProjectionMatrixChangedObservable: Observable<Camera>;
  30965. /**
  30966. * Observable triggered when the inputs have been processed.
  30967. */
  30968. onAfterCheckInputsObservable: Observable<Camera>;
  30969. /**
  30970. * Observable triggered when reset has been called and applied to the camera.
  30971. */
  30972. onRestoreStateObservable: Observable<Camera>;
  30973. /** @hidden */
  30974. _cameraRigParams: any;
  30975. /** @hidden */
  30976. _rigCameras: Camera[];
  30977. /** @hidden */
  30978. _rigPostProcess: Nullable<PostProcess>;
  30979. protected _webvrViewMatrix: Matrix;
  30980. /** @hidden */
  30981. _skipRendering: boolean;
  30982. /** @hidden */
  30983. _projectionMatrix: Matrix;
  30984. /** @hidden */
  30985. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30986. /** @hidden */
  30987. _activeMeshes: SmartArray<AbstractMesh>;
  30988. protected _globalPosition: Vector3;
  30989. /** hidden */
  30990. _computedViewMatrix: Matrix;
  30991. private _doNotComputeProjectionMatrix;
  30992. private _transformMatrix;
  30993. private _frustumPlanes;
  30994. private _refreshFrustumPlanes;
  30995. private _storedFov;
  30996. private _stateStored;
  30997. /**
  30998. * Instantiates a new camera object.
  30999. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31000. * @see http://doc.babylonjs.com/features/cameras
  31001. * @param name Defines the name of the camera in the scene
  31002. * @param position Defines the position of the camera
  31003. * @param scene Defines the scene the camera belongs too
  31004. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31005. */
  31006. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31007. /**
  31008. * Store current camera state (fov, position, etc..)
  31009. * @returns the camera
  31010. */
  31011. storeState(): Camera;
  31012. /**
  31013. * Restores the camera state values if it has been stored. You must call storeState() first
  31014. */
  31015. protected _restoreStateValues(): boolean;
  31016. /**
  31017. * Restored camera state. You must call storeState() first.
  31018. * @returns true if restored and false otherwise
  31019. */
  31020. restoreState(): boolean;
  31021. /**
  31022. * Gets the class name of the camera.
  31023. * @returns the class name
  31024. */
  31025. getClassName(): string;
  31026. /** @hidden */
  31027. readonly _isCamera: boolean;
  31028. /**
  31029. * Gets a string representation of the camera useful for debug purpose.
  31030. * @param fullDetails Defines that a more verboe level of logging is required
  31031. * @returns the string representation
  31032. */
  31033. toString(fullDetails?: boolean): string;
  31034. /**
  31035. * Gets the current world space position of the camera.
  31036. */
  31037. readonly globalPosition: Vector3;
  31038. /**
  31039. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31040. * @returns the active meshe list
  31041. */
  31042. getActiveMeshes(): SmartArray<AbstractMesh>;
  31043. /**
  31044. * Check wether a mesh is part of the current active mesh list of the camera
  31045. * @param mesh Defines the mesh to check
  31046. * @returns true if active, false otherwise
  31047. */
  31048. isActiveMesh(mesh: Mesh): boolean;
  31049. /**
  31050. * Is this camera ready to be used/rendered
  31051. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31052. * @return true if the camera is ready
  31053. */
  31054. isReady(completeCheck?: boolean): boolean;
  31055. /** @hidden */
  31056. _initCache(): void;
  31057. /** @hidden */
  31058. _updateCache(ignoreParentClass?: boolean): void;
  31059. /** @hidden */
  31060. _isSynchronized(): boolean;
  31061. /** @hidden */
  31062. _isSynchronizedViewMatrix(): boolean;
  31063. /** @hidden */
  31064. _isSynchronizedProjectionMatrix(): boolean;
  31065. /**
  31066. * Attach the input controls to a specific dom element to get the input from.
  31067. * @param element Defines the element the controls should be listened from
  31068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31069. */
  31070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31071. /**
  31072. * Detach the current controls from the specified dom element.
  31073. * @param element Defines the element to stop listening the inputs from
  31074. */
  31075. detachControl(element: HTMLElement): void;
  31076. /**
  31077. * Update the camera state according to the different inputs gathered during the frame.
  31078. */
  31079. update(): void;
  31080. /** @hidden */
  31081. _checkInputs(): void;
  31082. /** @hidden */
  31083. readonly rigCameras: Camera[];
  31084. /**
  31085. * Gets the post process used by the rig cameras
  31086. */
  31087. readonly rigPostProcess: Nullable<PostProcess>;
  31088. /**
  31089. * Internal, gets the first post proces.
  31090. * @returns the first post process to be run on this camera.
  31091. */
  31092. _getFirstPostProcess(): Nullable<PostProcess>;
  31093. private _cascadePostProcessesToRigCams;
  31094. /**
  31095. * Attach a post process to the camera.
  31096. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31097. * @param postProcess The post process to attach to the camera
  31098. * @param insertAt The position of the post process in case several of them are in use in the scene
  31099. * @returns the position the post process has been inserted at
  31100. */
  31101. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31102. /**
  31103. * Detach a post process to the camera.
  31104. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31105. * @param postProcess The post process to detach from the camera
  31106. */
  31107. detachPostProcess(postProcess: PostProcess): void;
  31108. /**
  31109. * Gets the current world matrix of the camera
  31110. */
  31111. getWorldMatrix(): Matrix;
  31112. /** @hidden */
  31113. _getViewMatrix(): Matrix;
  31114. /**
  31115. * Gets the current view matrix of the camera.
  31116. * @param force forces the camera to recompute the matrix without looking at the cached state
  31117. * @returns the view matrix
  31118. */
  31119. getViewMatrix(force?: boolean): Matrix;
  31120. /**
  31121. * Freeze the projection matrix.
  31122. * It will prevent the cache check of the camera projection compute and can speed up perf
  31123. * if no parameter of the camera are meant to change
  31124. * @param projection Defines manually a projection if necessary
  31125. */
  31126. freezeProjectionMatrix(projection?: Matrix): void;
  31127. /**
  31128. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31129. */
  31130. unfreezeProjectionMatrix(): void;
  31131. /**
  31132. * Gets the current projection matrix of the camera.
  31133. * @param force forces the camera to recompute the matrix without looking at the cached state
  31134. * @returns the projection matrix
  31135. */
  31136. getProjectionMatrix(force?: boolean): Matrix;
  31137. /**
  31138. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31139. * @returns a Matrix
  31140. */
  31141. getTransformationMatrix(): Matrix;
  31142. private _updateFrustumPlanes;
  31143. /**
  31144. * Checks if a cullable object (mesh...) is in the camera frustum
  31145. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31146. * @param target The object to check
  31147. * @returns true if the object is in frustum otherwise false
  31148. */
  31149. isInFrustum(target: ICullable): boolean;
  31150. /**
  31151. * Checks if a cullable object (mesh...) is in the camera frustum
  31152. * Unlike isInFrustum this cheks the full bounding box
  31153. * @param target The object to check
  31154. * @returns true if the object is in frustum otherwise false
  31155. */
  31156. isCompletelyInFrustum(target: ICullable): boolean;
  31157. /**
  31158. * Gets a ray in the forward direction from the camera.
  31159. * @param length Defines the length of the ray to create
  31160. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31161. * @param origin Defines the start point of the ray which defaults to the camera position
  31162. * @returns the forward ray
  31163. */
  31164. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31165. /**
  31166. * Releases resources associated with this node.
  31167. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31168. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31169. */
  31170. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31171. /** @hidden */
  31172. _isLeftCamera: boolean;
  31173. /**
  31174. * Gets the left camera of a rig setup in case of Rigged Camera
  31175. */
  31176. readonly isLeftCamera: boolean;
  31177. /** @hidden */
  31178. _isRightCamera: boolean;
  31179. /**
  31180. * Gets the right camera of a rig setup in case of Rigged Camera
  31181. */
  31182. readonly isRightCamera: boolean;
  31183. /**
  31184. * Gets the left camera of a rig setup in case of Rigged Camera
  31185. */
  31186. readonly leftCamera: Nullable<FreeCamera>;
  31187. /**
  31188. * Gets the right camera of a rig setup in case of Rigged Camera
  31189. */
  31190. readonly rightCamera: Nullable<FreeCamera>;
  31191. /**
  31192. * Gets the left camera target of a rig setup in case of Rigged Camera
  31193. * @returns the target position
  31194. */
  31195. getLeftTarget(): Nullable<Vector3>;
  31196. /**
  31197. * Gets the right camera target of a rig setup in case of Rigged Camera
  31198. * @returns the target position
  31199. */
  31200. getRightTarget(): Nullable<Vector3>;
  31201. /**
  31202. * @hidden
  31203. */
  31204. setCameraRigMode(mode: number, rigParams: any): void;
  31205. /** @hidden */
  31206. static _setStereoscopicRigMode(camera: Camera): void;
  31207. /** @hidden */
  31208. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31209. /** @hidden */
  31210. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31211. /** @hidden */
  31212. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31213. /** @hidden */
  31214. _getVRProjectionMatrix(): Matrix;
  31215. protected _updateCameraRotationMatrix(): void;
  31216. protected _updateWebVRCameraRotationMatrix(): void;
  31217. /**
  31218. * This function MUST be overwritten by the different WebVR cameras available.
  31219. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31220. * @hidden
  31221. */
  31222. _getWebVRProjectionMatrix(): Matrix;
  31223. /**
  31224. * This function MUST be overwritten by the different WebVR cameras available.
  31225. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31226. * @hidden
  31227. */
  31228. _getWebVRViewMatrix(): Matrix;
  31229. /** @hidden */
  31230. setCameraRigParameter(name: string, value: any): void;
  31231. /**
  31232. * needs to be overridden by children so sub has required properties to be copied
  31233. * @hidden
  31234. */
  31235. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31236. /**
  31237. * May need to be overridden by children
  31238. * @hidden
  31239. */
  31240. _updateRigCameras(): void;
  31241. /** @hidden */
  31242. _setupInputs(): void;
  31243. /**
  31244. * Serialiaze the camera setup to a json represention
  31245. * @returns the JSON representation
  31246. */
  31247. serialize(): any;
  31248. /**
  31249. * Clones the current camera.
  31250. * @param name The cloned camera name
  31251. * @returns the cloned camera
  31252. */
  31253. clone(name: string): Camera;
  31254. /**
  31255. * Gets the direction of the camera relative to a given local axis.
  31256. * @param localAxis Defines the reference axis to provide a relative direction.
  31257. * @return the direction
  31258. */
  31259. getDirection(localAxis: Vector3): Vector3;
  31260. /**
  31261. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31262. * @param localAxis Defines the reference axis to provide a relative direction.
  31263. * @param result Defines the vector to store the result in
  31264. */
  31265. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31266. /**
  31267. * Gets a camera constructor for a given camera type
  31268. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31269. * @param name The name of the camera the result will be able to instantiate
  31270. * @param scene The scene the result will construct the camera in
  31271. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31272. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31273. * @returns a factory method to construc the camera
  31274. */
  31275. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31276. /**
  31277. * Compute the world matrix of the camera.
  31278. * @returns the camera workd matrix
  31279. */
  31280. computeWorldMatrix(): Matrix;
  31281. /**
  31282. * Parse a JSON and creates the camera from the parsed information
  31283. * @param parsedCamera The JSON to parse
  31284. * @param scene The scene to instantiate the camera in
  31285. * @returns the newly constructed camera
  31286. */
  31287. static Parse(parsedCamera: any, scene: Scene): Camera;
  31288. }
  31289. }
  31290. declare module "babylonjs/Misc/tools" {
  31291. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31292. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31293. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31294. import { Observable } from "babylonjs/Misc/observable";
  31295. import { DomManagement } from "babylonjs/Misc/domManagement";
  31296. import { WebRequest } from "babylonjs/Misc/webRequest";
  31297. import { Camera } from "babylonjs/Cameras/camera";
  31298. import { Engine } from "babylonjs/Engines/engine";
  31299. import { Animation } from "babylonjs/Animations/animation";
  31300. /**
  31301. * Interface for any object that can request an animation frame
  31302. */
  31303. export interface ICustomAnimationFrameRequester {
  31304. /**
  31305. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31306. */
  31307. renderFunction?: Function;
  31308. /**
  31309. * Called to request the next frame to render to
  31310. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31311. */
  31312. requestAnimationFrame: Function;
  31313. /**
  31314. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31315. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31316. */
  31317. requestID?: number;
  31318. }
  31319. /**
  31320. * Interface containing an array of animations
  31321. */
  31322. export interface IAnimatable {
  31323. /**
  31324. * Array of animations
  31325. */
  31326. animations: Array<Animation>;
  31327. }
  31328. /** Interface used by value gradients (color, factor, ...) */
  31329. export interface IValueGradient {
  31330. /**
  31331. * Gets or sets the gradient value (between 0 and 1)
  31332. */
  31333. gradient: number;
  31334. }
  31335. /** Class used to store color4 gradient */
  31336. export class ColorGradient implements IValueGradient {
  31337. /**
  31338. * Gets or sets the gradient value (between 0 and 1)
  31339. */
  31340. gradient: number;
  31341. /**
  31342. * Gets or sets first associated color
  31343. */
  31344. color1: Color4;
  31345. /**
  31346. * Gets or sets second associated color
  31347. */
  31348. color2?: Color4;
  31349. /**
  31350. * Will get a color picked randomly between color1 and color2.
  31351. * If color2 is undefined then color1 will be used
  31352. * @param result defines the target Color4 to store the result in
  31353. */
  31354. getColorToRef(result: Color4): void;
  31355. }
  31356. /** Class used to store color 3 gradient */
  31357. export class Color3Gradient implements IValueGradient {
  31358. /**
  31359. * Gets or sets the gradient value (between 0 and 1)
  31360. */
  31361. gradient: number;
  31362. /**
  31363. * Gets or sets the associated color
  31364. */
  31365. color: Color3;
  31366. }
  31367. /** Class used to store factor gradient */
  31368. export class FactorGradient implements IValueGradient {
  31369. /**
  31370. * Gets or sets the gradient value (between 0 and 1)
  31371. */
  31372. gradient: number;
  31373. /**
  31374. * Gets or sets first associated factor
  31375. */
  31376. factor1: number;
  31377. /**
  31378. * Gets or sets second associated factor
  31379. */
  31380. factor2?: number;
  31381. /**
  31382. * Will get a number picked randomly between factor1 and factor2.
  31383. * If factor2 is undefined then factor1 will be used
  31384. * @returns the picked number
  31385. */
  31386. getFactor(): number;
  31387. }
  31388. /**
  31389. * @ignore
  31390. * Application error to support additional information when loading a file
  31391. */
  31392. export class LoadFileError extends Error {
  31393. /** defines the optional web request */
  31394. request?: WebRequest | undefined;
  31395. private static _setPrototypeOf;
  31396. /**
  31397. * Creates a new LoadFileError
  31398. * @param message defines the message of the error
  31399. * @param request defines the optional web request
  31400. */
  31401. constructor(message: string,
  31402. /** defines the optional web request */
  31403. request?: WebRequest | undefined);
  31404. }
  31405. /**
  31406. * Class used to define a retry strategy when error happens while loading assets
  31407. */
  31408. export class RetryStrategy {
  31409. /**
  31410. * Function used to defines an exponential back off strategy
  31411. * @param maxRetries defines the maximum number of retries (3 by default)
  31412. * @param baseInterval defines the interval between retries
  31413. * @returns the strategy function to use
  31414. */
  31415. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31416. }
  31417. /**
  31418. * File request interface
  31419. */
  31420. export interface IFileRequest {
  31421. /**
  31422. * Raised when the request is complete (success or error).
  31423. */
  31424. onCompleteObservable: Observable<IFileRequest>;
  31425. /**
  31426. * Aborts the request for a file.
  31427. */
  31428. abort: () => void;
  31429. }
  31430. /**
  31431. * Class containing a set of static utilities functions
  31432. */
  31433. export class Tools {
  31434. /**
  31435. * Gets or sets the base URL to use to load assets
  31436. */
  31437. static BaseUrl: string;
  31438. /**
  31439. * Enable/Disable Custom HTTP Request Headers globally.
  31440. * default = false
  31441. * @see CustomRequestHeaders
  31442. */
  31443. static UseCustomRequestHeaders: boolean;
  31444. /**
  31445. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31446. * i.e. when loading files, where the server/service expects an Authorization header
  31447. */
  31448. static CustomRequestHeaders: {
  31449. [key: string]: string;
  31450. };
  31451. /**
  31452. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31453. */
  31454. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31455. /**
  31456. * Default behaviour for cors in the application.
  31457. * It can be a string if the expected behavior is identical in the entire app.
  31458. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31459. */
  31460. static CorsBehavior: string | ((url: string | string[]) => string);
  31461. /**
  31462. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31463. * @ignorenaming
  31464. */
  31465. static UseFallbackTexture: boolean;
  31466. /**
  31467. * Use this object to register external classes like custom textures or material
  31468. * to allow the laoders to instantiate them
  31469. */
  31470. static RegisteredExternalClasses: {
  31471. [key: string]: Object;
  31472. };
  31473. /**
  31474. * Texture content used if a texture cannot loaded
  31475. * @ignorenaming
  31476. */
  31477. static fallbackTexture: string;
  31478. /**
  31479. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31480. * @param u defines the coordinate on X axis
  31481. * @param v defines the coordinate on Y axis
  31482. * @param width defines the width of the source data
  31483. * @param height defines the height of the source data
  31484. * @param pixels defines the source byte array
  31485. * @param color defines the output color
  31486. */
  31487. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31488. /**
  31489. * Interpolates between a and b via alpha
  31490. * @param a The lower value (returned when alpha = 0)
  31491. * @param b The upper value (returned when alpha = 1)
  31492. * @param alpha The interpolation-factor
  31493. * @return The mixed value
  31494. */
  31495. static Mix(a: number, b: number, alpha: number): number;
  31496. /**
  31497. * Tries to instantiate a new object from a given class name
  31498. * @param className defines the class name to instantiate
  31499. * @returns the new object or null if the system was not able to do the instantiation
  31500. */
  31501. static Instantiate(className: string): any;
  31502. /**
  31503. * Provides a slice function that will work even on IE
  31504. * @param data defines the array to slice
  31505. * @param start defines the start of the data (optional)
  31506. * @param end defines the end of the data (optional)
  31507. * @returns the new sliced array
  31508. */
  31509. static Slice<T>(data: T, start?: number, end?: number): T;
  31510. /**
  31511. * Polyfill for setImmediate
  31512. * @param action defines the action to execute after the current execution block
  31513. */
  31514. static SetImmediate(action: () => void): void;
  31515. /**
  31516. * Function indicating if a number is an exponent of 2
  31517. * @param value defines the value to test
  31518. * @returns true if the value is an exponent of 2
  31519. */
  31520. static IsExponentOfTwo(value: number): boolean;
  31521. private static _tmpFloatArray;
  31522. /**
  31523. * Returns the nearest 32-bit single precision float representation of a Number
  31524. * @param value A Number. If the parameter is of a different type, it will get converted
  31525. * to a number or to NaN if it cannot be converted
  31526. * @returns number
  31527. */
  31528. static FloatRound(value: number): number;
  31529. /**
  31530. * Find the next highest power of two.
  31531. * @param x Number to start search from.
  31532. * @return Next highest power of two.
  31533. */
  31534. static CeilingPOT(x: number): number;
  31535. /**
  31536. * Find the next lowest power of two.
  31537. * @param x Number to start search from.
  31538. * @return Next lowest power of two.
  31539. */
  31540. static FloorPOT(x: number): number;
  31541. /**
  31542. * Find the nearest power of two.
  31543. * @param x Number to start search from.
  31544. * @return Next nearest power of two.
  31545. */
  31546. static NearestPOT(x: number): number;
  31547. /**
  31548. * Get the closest exponent of two
  31549. * @param value defines the value to approximate
  31550. * @param max defines the maximum value to return
  31551. * @param mode defines how to define the closest value
  31552. * @returns closest exponent of two of the given value
  31553. */
  31554. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31555. /**
  31556. * Extracts the filename from a path
  31557. * @param path defines the path to use
  31558. * @returns the filename
  31559. */
  31560. static GetFilename(path: string): string;
  31561. /**
  31562. * Extracts the "folder" part of a path (everything before the filename).
  31563. * @param uri The URI to extract the info from
  31564. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31565. * @returns The "folder" part of the path
  31566. */
  31567. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31568. /**
  31569. * Extracts text content from a DOM element hierarchy
  31570. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31571. */
  31572. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31573. /**
  31574. * Convert an angle in radians to degrees
  31575. * @param angle defines the angle to convert
  31576. * @returns the angle in degrees
  31577. */
  31578. static ToDegrees(angle: number): number;
  31579. /**
  31580. * Convert an angle in degrees to radians
  31581. * @param angle defines the angle to convert
  31582. * @returns the angle in radians
  31583. */
  31584. static ToRadians(angle: number): number;
  31585. /**
  31586. * Encode a buffer to a base64 string
  31587. * @param buffer defines the buffer to encode
  31588. * @returns the encoded string
  31589. */
  31590. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31591. /**
  31592. * Extracts minimum and maximum values from a list of indexed positions
  31593. * @param positions defines the positions to use
  31594. * @param indices defines the indices to the positions
  31595. * @param indexStart defines the start index
  31596. * @param indexCount defines the end index
  31597. * @param bias defines bias value to add to the result
  31598. * @return minimum and maximum values
  31599. */
  31600. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31601. minimum: Vector3;
  31602. maximum: Vector3;
  31603. };
  31604. /**
  31605. * Extracts minimum and maximum values from a list of positions
  31606. * @param positions defines the positions to use
  31607. * @param start defines the start index in the positions array
  31608. * @param count defines the number of positions to handle
  31609. * @param bias defines bias value to add to the result
  31610. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31611. * @return minimum and maximum values
  31612. */
  31613. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31614. minimum: Vector3;
  31615. maximum: Vector3;
  31616. };
  31617. /**
  31618. * Returns an array if obj is not an array
  31619. * @param obj defines the object to evaluate as an array
  31620. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31621. * @returns either obj directly if obj is an array or a new array containing obj
  31622. */
  31623. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31624. /**
  31625. * Gets the pointer prefix to use
  31626. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31627. */
  31628. static GetPointerPrefix(): string;
  31629. /**
  31630. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31631. * @param func - the function to be called
  31632. * @param requester - the object that will request the next frame. Falls back to window.
  31633. * @returns frame number
  31634. */
  31635. static QueueNewFrame(func: () => void, requester?: any): number;
  31636. /**
  31637. * Ask the browser to promote the current element to fullscreen rendering mode
  31638. * @param element defines the DOM element to promote
  31639. */
  31640. static RequestFullscreen(element: HTMLElement): void;
  31641. /**
  31642. * Asks the browser to exit fullscreen mode
  31643. */
  31644. static ExitFullscreen(): void;
  31645. /**
  31646. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31647. * @param url define the url we are trying
  31648. * @param element define the dom element where to configure the cors policy
  31649. */
  31650. static SetCorsBehavior(url: string | string[], element: {
  31651. crossOrigin: string | null;
  31652. }): void;
  31653. /**
  31654. * Removes unwanted characters from an url
  31655. * @param url defines the url to clean
  31656. * @returns the cleaned url
  31657. */
  31658. static CleanUrl(url: string): string;
  31659. /**
  31660. * Gets or sets a function used to pre-process url before using them to load assets
  31661. */
  31662. static PreprocessUrl: (url: string) => string;
  31663. /**
  31664. * Loads an image as an HTMLImageElement.
  31665. * @param input url string, ArrayBuffer, or Blob to load
  31666. * @param onLoad callback called when the image successfully loads
  31667. * @param onError callback called when the image fails to load
  31668. * @param offlineProvider offline provider for caching
  31669. * @returns the HTMLImageElement of the loaded image
  31670. */
  31671. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31672. /**
  31673. * Loads a file
  31674. * @param url url string, ArrayBuffer, or Blob to load
  31675. * @param onSuccess callback called when the file successfully loads
  31676. * @param onProgress callback called while file is loading (if the server supports this mode)
  31677. * @param offlineProvider defines the offline provider for caching
  31678. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31679. * @param onError callback called when the file fails to load
  31680. * @returns a file request object
  31681. */
  31682. 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;
  31683. /**
  31684. * Load a script (identified by an url). When the url returns, the
  31685. * content of this file is added into a new script element, attached to the DOM (body element)
  31686. * @param scriptUrl defines the url of the script to laod
  31687. * @param onSuccess defines the callback called when the script is loaded
  31688. * @param onError defines the callback to call if an error occurs
  31689. * @param scriptId defines the id of the script element
  31690. */
  31691. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31692. /**
  31693. * Load an asynchronous script (identified by an url). When the url returns, the
  31694. * content of this file is added into a new script element, attached to the DOM (body element)
  31695. * @param scriptUrl defines the url of the script to laod
  31696. * @param scriptId defines the id of the script element
  31697. * @returns a promise request object
  31698. */
  31699. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31700. /**
  31701. * Loads a file from a blob
  31702. * @param fileToLoad defines the blob to use
  31703. * @param callback defines the callback to call when data is loaded
  31704. * @param progressCallback defines the callback to call during loading process
  31705. * @returns a file request object
  31706. */
  31707. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31708. /**
  31709. * Loads a file
  31710. * @param fileToLoad defines the file to load
  31711. * @param callback defines the callback to call when data is loaded
  31712. * @param progressCallBack defines the callback to call during loading process
  31713. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31714. * @returns a file request object
  31715. */
  31716. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31717. /**
  31718. * Creates a data url from a given string content
  31719. * @param content defines the content to convert
  31720. * @returns the new data url link
  31721. */
  31722. static FileAsURL(content: string): string;
  31723. /**
  31724. * Format the given number to a specific decimal format
  31725. * @param value defines the number to format
  31726. * @param decimals defines the number of decimals to use
  31727. * @returns the formatted string
  31728. */
  31729. static Format(value: number, decimals?: number): string;
  31730. /**
  31731. * Checks if a given vector is inside a specific range
  31732. * @param v defines the vector to test
  31733. * @param min defines the minimum range
  31734. * @param max defines the maximum range
  31735. */
  31736. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31737. /**
  31738. * Tries to copy an object by duplicating every property
  31739. * @param source defines the source object
  31740. * @param destination defines the target object
  31741. * @param doNotCopyList defines a list of properties to avoid
  31742. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31743. */
  31744. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31745. /**
  31746. * Gets a boolean indicating if the given object has no own property
  31747. * @param obj defines the object to test
  31748. * @returns true if object has no own property
  31749. */
  31750. static IsEmpty(obj: any): boolean;
  31751. /**
  31752. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31753. * @param str Source string
  31754. * @param suffix Suffix to search for in the source string
  31755. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31756. */
  31757. static EndsWith(str: string, suffix: string): boolean;
  31758. /**
  31759. * Function used to register events at window level
  31760. * @param events defines the events to register
  31761. */
  31762. static RegisterTopRootEvents(events: {
  31763. name: string;
  31764. handler: Nullable<(e: FocusEvent) => any>;
  31765. }[]): void;
  31766. /**
  31767. * Function used to unregister events from window level
  31768. * @param events defines the events to unregister
  31769. */
  31770. static UnregisterTopRootEvents(events: {
  31771. name: string;
  31772. handler: Nullable<(e: FocusEvent) => any>;
  31773. }[]): void;
  31774. /**
  31775. * @ignore
  31776. */
  31777. static _ScreenshotCanvas: HTMLCanvasElement;
  31778. /**
  31779. * Dumps the current bound framebuffer
  31780. * @param width defines the rendering width
  31781. * @param height defines the rendering height
  31782. * @param engine defines the hosting engine
  31783. * @param successCallback defines the callback triggered once the data are available
  31784. * @param mimeType defines the mime type of the result
  31785. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31786. */
  31787. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31788. /**
  31789. * Converts the canvas data to blob.
  31790. * This acts as a polyfill for browsers not supporting the to blob function.
  31791. * @param canvas Defines the canvas to extract the data from
  31792. * @param successCallback Defines the callback triggered once the data are available
  31793. * @param mimeType Defines the mime type of the result
  31794. */
  31795. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31796. /**
  31797. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31798. * @param successCallback defines the callback triggered once the data are available
  31799. * @param mimeType defines the mime type of the result
  31800. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31801. */
  31802. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31803. /**
  31804. * Downloads a blob in the browser
  31805. * @param blob defines the blob to download
  31806. * @param fileName defines the name of the downloaded file
  31807. */
  31808. static Download(blob: Blob, fileName: string): void;
  31809. /**
  31810. * Captures a screenshot of the current rendering
  31811. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31812. * @param engine defines the rendering engine
  31813. * @param camera defines the source camera
  31814. * @param size This parameter can be set to a single number or to an object with the
  31815. * following (optional) properties: precision, width, height. If a single number is passed,
  31816. * it will be used for both width and height. If an object is passed, the screenshot size
  31817. * will be derived from the parameters. The precision property is a multiplier allowing
  31818. * rendering at a higher or lower resolution
  31819. * @param successCallback defines the callback receives a single parameter which contains the
  31820. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31821. * src parameter of an <img> to display it
  31822. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31823. * Check your browser for supported MIME types
  31824. */
  31825. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31826. /**
  31827. * Generates an image screenshot from the specified camera.
  31828. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31829. * @param engine The engine to use for rendering
  31830. * @param camera The camera to use for rendering
  31831. * @param size This parameter can be set to a single number or to an object with the
  31832. * following (optional) properties: precision, width, height. If a single number is passed,
  31833. * it will be used for both width and height. If an object is passed, the screenshot size
  31834. * will be derived from the parameters. The precision property is a multiplier allowing
  31835. * rendering at a higher or lower resolution
  31836. * @param successCallback The callback receives a single parameter which contains the
  31837. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31838. * src parameter of an <img> to display it
  31839. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31840. * Check your browser for supported MIME types
  31841. * @param samples Texture samples (default: 1)
  31842. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31843. * @param fileName A name for for the downloaded file.
  31844. */
  31845. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31846. /**
  31847. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31848. * Be aware Math.random() could cause collisions, but:
  31849. * "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"
  31850. * @returns a pseudo random id
  31851. */
  31852. static RandomId(): string;
  31853. /**
  31854. * Test if the given uri is a base64 string
  31855. * @param uri The uri to test
  31856. * @return True if the uri is a base64 string or false otherwise
  31857. */
  31858. static IsBase64(uri: string): boolean;
  31859. /**
  31860. * Decode the given base64 uri.
  31861. * @param uri The uri to decode
  31862. * @return The decoded base64 data.
  31863. */
  31864. static DecodeBase64(uri: string): ArrayBuffer;
  31865. /**
  31866. * No log
  31867. */
  31868. static readonly NoneLogLevel: number;
  31869. /**
  31870. * Only message logs
  31871. */
  31872. static readonly MessageLogLevel: number;
  31873. /**
  31874. * Only warning logs
  31875. */
  31876. static readonly WarningLogLevel: number;
  31877. /**
  31878. * Only error logs
  31879. */
  31880. static readonly ErrorLogLevel: number;
  31881. /**
  31882. * All logs
  31883. */
  31884. static readonly AllLogLevel: number;
  31885. /**
  31886. * Gets a value indicating the number of loading errors
  31887. * @ignorenaming
  31888. */
  31889. static readonly errorsCount: number;
  31890. /**
  31891. * Callback called when a new log is added
  31892. */
  31893. static OnNewCacheEntry: (entry: string) => void;
  31894. /**
  31895. * Log a message to the console
  31896. * @param message defines the message to log
  31897. */
  31898. static Log(message: string): void;
  31899. /**
  31900. * Write a warning message to the console
  31901. * @param message defines the message to log
  31902. */
  31903. static Warn(message: string): void;
  31904. /**
  31905. * Write an error message to the console
  31906. * @param message defines the message to log
  31907. */
  31908. static Error(message: string): void;
  31909. /**
  31910. * Gets current log cache (list of logs)
  31911. */
  31912. static readonly LogCache: string;
  31913. /**
  31914. * Clears the log cache
  31915. */
  31916. static ClearLogCache(): void;
  31917. /**
  31918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31919. */
  31920. static LogLevels: number;
  31921. /**
  31922. * Checks if the loaded document was accessed via `file:`-Protocol.
  31923. * @returns boolean
  31924. */
  31925. static IsFileURL(): boolean;
  31926. /**
  31927. * Checks if the window object exists
  31928. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31929. */
  31930. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31931. /**
  31932. * No performance log
  31933. */
  31934. static readonly PerformanceNoneLogLevel: number;
  31935. /**
  31936. * Use user marks to log performance
  31937. */
  31938. static readonly PerformanceUserMarkLogLevel: number;
  31939. /**
  31940. * Log performance to the console
  31941. */
  31942. static readonly PerformanceConsoleLogLevel: number;
  31943. private static _performance;
  31944. /**
  31945. * Sets the current performance log level
  31946. */
  31947. static PerformanceLogLevel: number;
  31948. private static _StartPerformanceCounterDisabled;
  31949. private static _EndPerformanceCounterDisabled;
  31950. private static _StartUserMark;
  31951. private static _EndUserMark;
  31952. private static _StartPerformanceConsole;
  31953. private static _EndPerformanceConsole;
  31954. /**
  31955. * Starts a performance counter
  31956. */
  31957. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31958. /**
  31959. * Ends a specific performance coutner
  31960. */
  31961. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31962. /**
  31963. * Gets either window.performance.now() if supported or Date.now() else
  31964. */
  31965. static readonly Now: number;
  31966. /**
  31967. * This method will return the name of the class used to create the instance of the given object.
  31968. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31969. * @param object the object to get the class name from
  31970. * @param isType defines if the object is actually a type
  31971. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31972. */
  31973. static GetClassName(object: any, isType?: boolean): string;
  31974. /**
  31975. * Gets the first element of an array satisfying a given predicate
  31976. * @param array defines the array to browse
  31977. * @param predicate defines the predicate to use
  31978. * @returns null if not found or the element
  31979. */
  31980. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31981. /**
  31982. * This method will return the name of the full name of the class, including its owning module (if any).
  31983. * 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).
  31984. * @param object the object to get the class name from
  31985. * @param isType defines if the object is actually a type
  31986. * @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.
  31987. * @ignorenaming
  31988. */
  31989. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31990. /**
  31991. * Returns a promise that resolves after the given amount of time.
  31992. * @param delay Number of milliseconds to delay
  31993. * @returns Promise that resolves after the given amount of time
  31994. */
  31995. static DelayAsync(delay: number): Promise<void>;
  31996. /**
  31997. * Gets the current gradient from an array of IValueGradient
  31998. * @param ratio defines the current ratio to get
  31999. * @param gradients defines the array of IValueGradient
  32000. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32001. */
  32002. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32003. }
  32004. /**
  32005. * This class is used to track a performance counter which is number based.
  32006. * The user has access to many properties which give statistics of different nature.
  32007. *
  32008. * The implementer can track two kinds of Performance Counter: time and count.
  32009. * 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.
  32010. * 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.
  32011. */
  32012. export class PerfCounter {
  32013. /**
  32014. * Gets or sets a global boolean to turn on and off all the counters
  32015. */
  32016. static Enabled: boolean;
  32017. /**
  32018. * Returns the smallest value ever
  32019. */
  32020. readonly min: number;
  32021. /**
  32022. * Returns the biggest value ever
  32023. */
  32024. readonly max: number;
  32025. /**
  32026. * Returns the average value since the performance counter is running
  32027. */
  32028. readonly average: number;
  32029. /**
  32030. * Returns the average value of the last second the counter was monitored
  32031. */
  32032. readonly lastSecAverage: number;
  32033. /**
  32034. * Returns the current value
  32035. */
  32036. readonly current: number;
  32037. /**
  32038. * Gets the accumulated total
  32039. */
  32040. readonly total: number;
  32041. /**
  32042. * Gets the total value count
  32043. */
  32044. readonly count: number;
  32045. /**
  32046. * Creates a new counter
  32047. */
  32048. constructor();
  32049. /**
  32050. * Call this method to start monitoring a new frame.
  32051. * 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.
  32052. */
  32053. fetchNewFrame(): void;
  32054. /**
  32055. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32056. * @param newCount the count value to add to the monitored count
  32057. * @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.
  32058. */
  32059. addCount(newCount: number, fetchResult: boolean): void;
  32060. /**
  32061. * Start monitoring this performance counter
  32062. */
  32063. beginMonitoring(): void;
  32064. /**
  32065. * Compute the time lapsed since the previous beginMonitoring() call.
  32066. * @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
  32067. */
  32068. endMonitoring(newFrame?: boolean): void;
  32069. private _fetchResult;
  32070. private _startMonitoringTime;
  32071. private _min;
  32072. private _max;
  32073. private _average;
  32074. private _current;
  32075. private _totalValueCount;
  32076. private _totalAccumulated;
  32077. private _lastSecAverage;
  32078. private _lastSecAccumulated;
  32079. private _lastSecTime;
  32080. private _lastSecValueCount;
  32081. }
  32082. /**
  32083. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32084. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32085. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32086. * @param name The name of the class, case should be preserved
  32087. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32088. */
  32089. export function className(name: string, module?: string): (target: Object) => void;
  32090. /**
  32091. * An implementation of a loop for asynchronous functions.
  32092. */
  32093. export class AsyncLoop {
  32094. /**
  32095. * Defines the number of iterations for the loop
  32096. */
  32097. iterations: number;
  32098. /**
  32099. * Defines the current index of the loop.
  32100. */
  32101. index: number;
  32102. private _done;
  32103. private _fn;
  32104. private _successCallback;
  32105. /**
  32106. * Constructor.
  32107. * @param iterations the number of iterations.
  32108. * @param func the function to run each iteration
  32109. * @param successCallback the callback that will be called upon succesful execution
  32110. * @param offset starting offset.
  32111. */
  32112. constructor(
  32113. /**
  32114. * Defines the number of iterations for the loop
  32115. */
  32116. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32117. /**
  32118. * Execute the next iteration. Must be called after the last iteration was finished.
  32119. */
  32120. executeNext(): void;
  32121. /**
  32122. * Break the loop and run the success callback.
  32123. */
  32124. breakLoop(): void;
  32125. /**
  32126. * Create and run an async loop.
  32127. * @param iterations the number of iterations.
  32128. * @param fn the function to run each iteration
  32129. * @param successCallback the callback that will be called upon succesful execution
  32130. * @param offset starting offset.
  32131. * @returns the created async loop object
  32132. */
  32133. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32134. /**
  32135. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32136. * @param iterations total number of iterations
  32137. * @param syncedIterations number of synchronous iterations in each async iteration.
  32138. * @param fn the function to call each iteration.
  32139. * @param callback a success call back that will be called when iterating stops.
  32140. * @param breakFunction a break condition (optional)
  32141. * @param timeout timeout settings for the setTimeout function. default - 0.
  32142. * @returns the created async loop object
  32143. */
  32144. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32145. }
  32146. }
  32147. declare module "babylonjs/Collisions/collisionCoordinator" {
  32148. import { Nullable } from "babylonjs/types";
  32149. import { Scene } from "babylonjs/scene";
  32150. import { Vector3 } from "babylonjs/Maths/math";
  32151. import { Collider } from "babylonjs/Collisions/collider";
  32152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32153. /** @hidden */
  32154. export interface ICollisionCoordinator {
  32155. createCollider(): Collider;
  32156. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32157. init(scene: Scene): void;
  32158. }
  32159. /** @hidden */
  32160. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32161. private _scene;
  32162. private _scaledPosition;
  32163. private _scaledVelocity;
  32164. private _finalPosition;
  32165. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32166. createCollider(): Collider;
  32167. init(scene: Scene): void;
  32168. private _collideWithWorld;
  32169. }
  32170. }
  32171. declare module "babylonjs/Animations/animationGroup" {
  32172. import { Animatable } from "babylonjs/Animations/animatable";
  32173. import { Animation } from "babylonjs/Animations/animation";
  32174. import { Scene, IDisposable } from "babylonjs/scene";
  32175. import { Observable } from "babylonjs/Misc/observable";
  32176. import { Nullable } from "babylonjs/types";
  32177. /**
  32178. * This class defines the direct association between an animation and a target
  32179. */
  32180. export class TargetedAnimation {
  32181. /**
  32182. * Animation to perform
  32183. */
  32184. animation: Animation;
  32185. /**
  32186. * Target to animate
  32187. */
  32188. target: any;
  32189. }
  32190. /**
  32191. * Use this class to create coordinated animations on multiple targets
  32192. */
  32193. export class AnimationGroup implements IDisposable {
  32194. /** The name of the animation group */
  32195. name: string;
  32196. private _scene;
  32197. private _targetedAnimations;
  32198. private _animatables;
  32199. private _from;
  32200. private _to;
  32201. private _isStarted;
  32202. private _isPaused;
  32203. private _speedRatio;
  32204. /**
  32205. * Gets or sets the unique id of the node
  32206. */
  32207. uniqueId: number;
  32208. /**
  32209. * This observable will notify when one animation have ended
  32210. */
  32211. onAnimationEndObservable: Observable<TargetedAnimation>;
  32212. /**
  32213. * Observer raised when one animation loops
  32214. */
  32215. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32216. /**
  32217. * This observable will notify when all animations have ended.
  32218. */
  32219. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32220. /**
  32221. * This observable will notify when all animations have paused.
  32222. */
  32223. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32224. /**
  32225. * This observable will notify when all animations are playing.
  32226. */
  32227. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32228. /**
  32229. * Gets the first frame
  32230. */
  32231. readonly from: number;
  32232. /**
  32233. * Gets the last frame
  32234. */
  32235. readonly to: number;
  32236. /**
  32237. * Define if the animations are started
  32238. */
  32239. readonly isStarted: boolean;
  32240. /**
  32241. * Gets a value indicating that the current group is playing
  32242. */
  32243. readonly isPlaying: boolean;
  32244. /**
  32245. * Gets or sets the speed ratio to use for all animations
  32246. */
  32247. /**
  32248. * Gets or sets the speed ratio to use for all animations
  32249. */
  32250. speedRatio: number;
  32251. /**
  32252. * Gets the targeted animations for this animation group
  32253. */
  32254. readonly targetedAnimations: Array<TargetedAnimation>;
  32255. /**
  32256. * returning the list of animatables controlled by this animation group.
  32257. */
  32258. readonly animatables: Array<Animatable>;
  32259. /**
  32260. * Instantiates a new Animation Group.
  32261. * This helps managing several animations at once.
  32262. * @see http://doc.babylonjs.com/how_to/group
  32263. * @param name Defines the name of the group
  32264. * @param scene Defines the scene the group belongs to
  32265. */
  32266. constructor(
  32267. /** The name of the animation group */
  32268. name: string, scene?: Nullable<Scene>);
  32269. /**
  32270. * Add an animation (with its target) in the group
  32271. * @param animation defines the animation we want to add
  32272. * @param target defines the target of the animation
  32273. * @returns the TargetedAnimation object
  32274. */
  32275. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32276. /**
  32277. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32278. * It can add constant keys at begin or end
  32279. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32280. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32281. * @returns the animation group
  32282. */
  32283. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32284. /**
  32285. * Start all animations on given targets
  32286. * @param loop defines if animations must loop
  32287. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32288. * @param from defines the from key (optional)
  32289. * @param to defines the to key (optional)
  32290. * @returns the current animation group
  32291. */
  32292. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32293. /**
  32294. * Pause all animations
  32295. * @returns the animation group
  32296. */
  32297. pause(): AnimationGroup;
  32298. /**
  32299. * Play all animations to initial state
  32300. * This function will start() the animations if they were not started or will restart() them if they were paused
  32301. * @param loop defines if animations must loop
  32302. * @returns the animation group
  32303. */
  32304. play(loop?: boolean): AnimationGroup;
  32305. /**
  32306. * Reset all animations to initial state
  32307. * @returns the animation group
  32308. */
  32309. reset(): AnimationGroup;
  32310. /**
  32311. * Restart animations from key 0
  32312. * @returns the animation group
  32313. */
  32314. restart(): AnimationGroup;
  32315. /**
  32316. * Stop all animations
  32317. * @returns the animation group
  32318. */
  32319. stop(): AnimationGroup;
  32320. /**
  32321. * Set animation weight for all animatables
  32322. * @param weight defines the weight to use
  32323. * @return the animationGroup
  32324. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32325. */
  32326. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32327. /**
  32328. * Synchronize and normalize all animatables with a source animatable
  32329. * @param root defines the root animatable to synchronize with
  32330. * @return the animationGroup
  32331. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32332. */
  32333. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32334. /**
  32335. * Goes to a specific frame in this animation group
  32336. * @param frame the frame number to go to
  32337. * @return the animationGroup
  32338. */
  32339. goToFrame(frame: number): AnimationGroup;
  32340. /**
  32341. * Dispose all associated resources
  32342. */
  32343. dispose(): void;
  32344. private _checkAnimationGroupEnded;
  32345. /**
  32346. * Clone the current animation group and returns a copy
  32347. * @param newName defines the name of the new group
  32348. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32349. * @returns the new aniamtion group
  32350. */
  32351. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32352. /**
  32353. * Returns a new AnimationGroup object parsed from the source provided.
  32354. * @param parsedAnimationGroup defines the source
  32355. * @param scene defines the scene that will receive the animationGroup
  32356. * @returns a new AnimationGroup
  32357. */
  32358. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32359. /**
  32360. * Returns the string "AnimationGroup"
  32361. * @returns "AnimationGroup"
  32362. */
  32363. getClassName(): string;
  32364. /**
  32365. * Creates a detailled string about the object
  32366. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32367. * @returns a string representing the object
  32368. */
  32369. toString(fullDetails?: boolean): string;
  32370. }
  32371. }
  32372. declare module "babylonjs/scene" {
  32373. import { Nullable } from "babylonjs/types";
  32374. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32375. import { Observable } from "babylonjs/Misc/observable";
  32376. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32377. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32378. import { Geometry } from "babylonjs/Meshes/geometry";
  32379. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32382. import { Mesh } from "babylonjs/Meshes/mesh";
  32383. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32384. import { Bone } from "babylonjs/Bones/bone";
  32385. import { Skeleton } from "babylonjs/Bones/skeleton";
  32386. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32387. import { Camera } from "babylonjs/Cameras/camera";
  32388. import { AbstractScene } from "babylonjs/abstractScene";
  32389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32390. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32391. import { Material } from "babylonjs/Materials/material";
  32392. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32393. import { Effect } from "babylonjs/Materials/effect";
  32394. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32395. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32396. import { Light } from "babylonjs/Lights/light";
  32397. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32398. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32399. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32400. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32401. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32402. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32403. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32404. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32405. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32406. import { Engine } from "babylonjs/Engines/engine";
  32407. import { Node } from "babylonjs/node";
  32408. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32409. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32410. import { WebRequest } from "babylonjs/Misc/webRequest";
  32411. import { Ray } from "babylonjs/Culling/ray";
  32412. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32413. import { Animation } from "babylonjs/Animations/animation";
  32414. import { Animatable } from "babylonjs/Animations/animatable";
  32415. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32416. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32417. import { Collider } from "babylonjs/Collisions/collider";
  32418. /**
  32419. * Define an interface for all classes that will hold resources
  32420. */
  32421. export interface IDisposable {
  32422. /**
  32423. * Releases all held resources
  32424. */
  32425. dispose(): void;
  32426. }
  32427. /** Interface defining initialization parameters for Scene class */
  32428. export interface SceneOptions {
  32429. /**
  32430. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32431. * It will improve performance when the number of geometries becomes important.
  32432. */
  32433. useGeometryUniqueIdsMap?: boolean;
  32434. /**
  32435. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32436. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32437. */
  32438. useMaterialMeshMap?: boolean;
  32439. /**
  32440. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32441. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32442. */
  32443. useClonedMeshhMap?: boolean;
  32444. }
  32445. /**
  32446. * Represents a scene to be rendered by the engine.
  32447. * @see http://doc.babylonjs.com/features/scene
  32448. */
  32449. export class Scene extends AbstractScene implements IAnimatable {
  32450. private static _uniqueIdCounter;
  32451. /** The fog is deactivated */
  32452. static readonly FOGMODE_NONE: number;
  32453. /** The fog density is following an exponential function */
  32454. static readonly FOGMODE_EXP: number;
  32455. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32456. static readonly FOGMODE_EXP2: number;
  32457. /** The fog density is following a linear function. */
  32458. static readonly FOGMODE_LINEAR: number;
  32459. /**
  32460. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32461. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32462. */
  32463. static MinDeltaTime: number;
  32464. /**
  32465. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32467. */
  32468. static MaxDeltaTime: number;
  32469. /**
  32470. * Factory used to create the default material.
  32471. * @param name The name of the material to create
  32472. * @param scene The scene to create the material for
  32473. * @returns The default material
  32474. */
  32475. static DefaultMaterialFactory(scene: Scene): Material;
  32476. /**
  32477. * Factory used to create the a collision coordinator.
  32478. * @returns The collision coordinator
  32479. */
  32480. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32481. /** @hidden */
  32482. readonly _isScene: boolean;
  32483. /**
  32484. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32485. */
  32486. autoClear: boolean;
  32487. /**
  32488. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32489. */
  32490. autoClearDepthAndStencil: boolean;
  32491. /**
  32492. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32493. */
  32494. clearColor: Color4;
  32495. /**
  32496. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32497. */
  32498. ambientColor: Color3;
  32499. /**
  32500. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32501. * It should only be one of the following (if not the default embedded one):
  32502. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32503. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32504. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32505. * The material properties need to be setup according to the type of texture in use.
  32506. */
  32507. environmentBRDFTexture: BaseTexture;
  32508. /** @hidden */
  32509. protected _environmentTexture: Nullable<BaseTexture>;
  32510. /**
  32511. * Texture used in all pbr material as the reflection texture.
  32512. * As in the majority of the scene they are the same (exception for multi room and so on),
  32513. * this is easier to reference from here than from all the materials.
  32514. */
  32515. /**
  32516. * Texture used in all pbr material as the reflection texture.
  32517. * As in the majority of the scene they are the same (exception for multi room and so on),
  32518. * this is easier to set here than in all the materials.
  32519. */
  32520. environmentTexture: Nullable<BaseTexture>;
  32521. /** @hidden */
  32522. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32523. /**
  32524. * Default image processing configuration used either in the rendering
  32525. * Forward main pass or through the imageProcessingPostProcess if present.
  32526. * As in the majority of the scene they are the same (exception for multi camera),
  32527. * this is easier to reference from here than from all the materials and post process.
  32528. *
  32529. * No setter as we it is a shared configuration, you can set the values instead.
  32530. */
  32531. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32532. private _forceWireframe;
  32533. /**
  32534. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32535. */
  32536. forceWireframe: boolean;
  32537. private _forcePointsCloud;
  32538. /**
  32539. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32540. */
  32541. forcePointsCloud: boolean;
  32542. /**
  32543. * Gets or sets the active clipplane 1
  32544. */
  32545. clipPlane: Nullable<Plane>;
  32546. /**
  32547. * Gets or sets the active clipplane 2
  32548. */
  32549. clipPlane2: Nullable<Plane>;
  32550. /**
  32551. * Gets or sets the active clipplane 3
  32552. */
  32553. clipPlane3: Nullable<Plane>;
  32554. /**
  32555. * Gets or sets the active clipplane 4
  32556. */
  32557. clipPlane4: Nullable<Plane>;
  32558. /**
  32559. * Gets or sets a boolean indicating if animations are enabled
  32560. */
  32561. animationsEnabled: boolean;
  32562. private _animationPropertiesOverride;
  32563. /**
  32564. * Gets or sets the animation properties override
  32565. */
  32566. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32567. /**
  32568. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32569. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32570. */
  32571. useConstantAnimationDeltaTime: boolean;
  32572. /**
  32573. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32574. * Please note that it requires to run a ray cast through the scene on every frame
  32575. */
  32576. constantlyUpdateMeshUnderPointer: boolean;
  32577. /**
  32578. * Defines the HTML cursor to use when hovering over interactive elements
  32579. */
  32580. hoverCursor: string;
  32581. /**
  32582. * Defines the HTML default cursor to use (empty by default)
  32583. */
  32584. defaultCursor: string;
  32585. /**
  32586. * This is used to call preventDefault() on pointer down
  32587. * in order to block unwanted artifacts like system double clicks
  32588. */
  32589. preventDefaultOnPointerDown: boolean;
  32590. /**
  32591. * This is used to call preventDefault() on pointer up
  32592. * in order to block unwanted artifacts like system double clicks
  32593. */
  32594. preventDefaultOnPointerUp: boolean;
  32595. /**
  32596. * Gets or sets user defined metadata
  32597. */
  32598. metadata: any;
  32599. /**
  32600. * For internal use only. Please do not use.
  32601. */
  32602. reservedDataStore: any;
  32603. /**
  32604. * Gets the name of the plugin used to load this scene (null by default)
  32605. */
  32606. loadingPluginName: string;
  32607. /**
  32608. * Use this array to add regular expressions used to disable offline support for specific urls
  32609. */
  32610. disableOfflineSupportExceptionRules: RegExp[];
  32611. /**
  32612. * An event triggered when the scene is disposed.
  32613. */
  32614. onDisposeObservable: Observable<Scene>;
  32615. private _onDisposeObserver;
  32616. /** Sets a function to be executed when this scene is disposed. */
  32617. onDispose: () => void;
  32618. /**
  32619. * An event triggered before rendering the scene (right after animations and physics)
  32620. */
  32621. onBeforeRenderObservable: Observable<Scene>;
  32622. private _onBeforeRenderObserver;
  32623. /** Sets a function to be executed before rendering this scene */
  32624. beforeRender: Nullable<() => void>;
  32625. /**
  32626. * An event triggered after rendering the scene
  32627. */
  32628. onAfterRenderObservable: Observable<Scene>;
  32629. private _onAfterRenderObserver;
  32630. /** Sets a function to be executed after rendering this scene */
  32631. afterRender: Nullable<() => void>;
  32632. /**
  32633. * An event triggered before animating the scene
  32634. */
  32635. onBeforeAnimationsObservable: Observable<Scene>;
  32636. /**
  32637. * An event triggered after animations processing
  32638. */
  32639. onAfterAnimationsObservable: Observable<Scene>;
  32640. /**
  32641. * An event triggered before draw calls are ready to be sent
  32642. */
  32643. onBeforeDrawPhaseObservable: Observable<Scene>;
  32644. /**
  32645. * An event triggered after draw calls have been sent
  32646. */
  32647. onAfterDrawPhaseObservable: Observable<Scene>;
  32648. /**
  32649. * An event triggered when the scene is ready
  32650. */
  32651. onReadyObservable: Observable<Scene>;
  32652. /**
  32653. * An event triggered before rendering a camera
  32654. */
  32655. onBeforeCameraRenderObservable: Observable<Camera>;
  32656. private _onBeforeCameraRenderObserver;
  32657. /** Sets a function to be executed before rendering a camera*/
  32658. beforeCameraRender: () => void;
  32659. /**
  32660. * An event triggered after rendering a camera
  32661. */
  32662. onAfterCameraRenderObservable: Observable<Camera>;
  32663. private _onAfterCameraRenderObserver;
  32664. /** Sets a function to be executed after rendering a camera*/
  32665. afterCameraRender: () => void;
  32666. /**
  32667. * An event triggered when active meshes evaluation is about to start
  32668. */
  32669. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32670. /**
  32671. * An event triggered when active meshes evaluation is done
  32672. */
  32673. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32674. /**
  32675. * An event triggered when particles rendering is about to start
  32676. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32677. */
  32678. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32679. /**
  32680. * An event triggered when particles rendering is done
  32681. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32682. */
  32683. onAfterParticlesRenderingObservable: Observable<Scene>;
  32684. /**
  32685. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32686. */
  32687. onDataLoadedObservable: Observable<Scene>;
  32688. /**
  32689. * An event triggered when a camera is created
  32690. */
  32691. onNewCameraAddedObservable: Observable<Camera>;
  32692. /**
  32693. * An event triggered when a camera is removed
  32694. */
  32695. onCameraRemovedObservable: Observable<Camera>;
  32696. /**
  32697. * An event triggered when a light is created
  32698. */
  32699. onNewLightAddedObservable: Observable<Light>;
  32700. /**
  32701. * An event triggered when a light is removed
  32702. */
  32703. onLightRemovedObservable: Observable<Light>;
  32704. /**
  32705. * An event triggered when a geometry is created
  32706. */
  32707. onNewGeometryAddedObservable: Observable<Geometry>;
  32708. /**
  32709. * An event triggered when a geometry is removed
  32710. */
  32711. onGeometryRemovedObservable: Observable<Geometry>;
  32712. /**
  32713. * An event triggered when a transform node is created
  32714. */
  32715. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32716. /**
  32717. * An event triggered when a transform node is removed
  32718. */
  32719. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32720. /**
  32721. * An event triggered when a mesh is created
  32722. */
  32723. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32724. /**
  32725. * An event triggered when a mesh is removed
  32726. */
  32727. onMeshRemovedObservable: Observable<AbstractMesh>;
  32728. /**
  32729. * An event triggered when a skeleton is created
  32730. */
  32731. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32732. /**
  32733. * An event triggered when a skeleton is removed
  32734. */
  32735. onSkeletonRemovedObservable: Observable<Skeleton>;
  32736. /**
  32737. * An event triggered when a material is created
  32738. */
  32739. onNewMaterialAddedObservable: Observable<Material>;
  32740. /**
  32741. * An event triggered when a material is removed
  32742. */
  32743. onMaterialRemovedObservable: Observable<Material>;
  32744. /**
  32745. * An event triggered when a texture is created
  32746. */
  32747. onNewTextureAddedObservable: Observable<BaseTexture>;
  32748. /**
  32749. * An event triggered when a texture is removed
  32750. */
  32751. onTextureRemovedObservable: Observable<BaseTexture>;
  32752. /**
  32753. * An event triggered when render targets are about to be rendered
  32754. * Can happen multiple times per frame.
  32755. */
  32756. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32757. /**
  32758. * An event triggered when render targets were rendered.
  32759. * Can happen multiple times per frame.
  32760. */
  32761. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32762. /**
  32763. * An event triggered before calculating deterministic simulation step
  32764. */
  32765. onBeforeStepObservable: Observable<Scene>;
  32766. /**
  32767. * An event triggered after calculating deterministic simulation step
  32768. */
  32769. onAfterStepObservable: Observable<Scene>;
  32770. /**
  32771. * An event triggered when the activeCamera property is updated
  32772. */
  32773. onActiveCameraChanged: Observable<Scene>;
  32774. /**
  32775. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32776. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32777. * 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)
  32778. */
  32779. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32780. /**
  32781. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32782. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32783. * 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)
  32784. */
  32785. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32786. /**
  32787. * This Observable will when a mesh has been imported into the scene.
  32788. */
  32789. onMeshImportedObservable: Observable<AbstractMesh>;
  32790. /**
  32791. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32792. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32793. */
  32794. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32795. /** @hidden */
  32796. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32797. /**
  32798. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32799. */
  32800. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32801. /**
  32802. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32803. */
  32804. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32805. /**
  32806. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32807. */
  32808. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32809. private _onPointerMove;
  32810. private _onPointerDown;
  32811. private _onPointerUp;
  32812. /** Callback called when a pointer move is detected */
  32813. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32814. /** Callback called when a pointer down is detected */
  32815. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32816. /** Callback called when a pointer up is detected */
  32817. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32818. /** Callback called when a pointer pick is detected */
  32819. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32820. /**
  32821. * 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).
  32822. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32823. */
  32824. onPrePointerObservable: Observable<PointerInfoPre>;
  32825. /**
  32826. * Observable event triggered each time an input event is received from the rendering canvas
  32827. */
  32828. onPointerObservable: Observable<PointerInfo>;
  32829. /**
  32830. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32831. */
  32832. readonly unTranslatedPointer: Vector2;
  32833. /** The distance in pixel that you have to move to prevent some events */
  32834. static DragMovementThreshold: number;
  32835. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32836. static LongPressDelay: number;
  32837. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32838. static DoubleClickDelay: number;
  32839. /** If you need to check double click without raising a single click at first click, enable this flag */
  32840. static ExclusiveDoubleClickMode: boolean;
  32841. private _initClickEvent;
  32842. private _initActionManager;
  32843. private _delayedSimpleClick;
  32844. private _delayedSimpleClickTimeout;
  32845. private _previousDelayedSimpleClickTimeout;
  32846. private _meshPickProceed;
  32847. private _previousButtonPressed;
  32848. private _currentPickResult;
  32849. private _previousPickResult;
  32850. private _totalPointersPressed;
  32851. private _doubleClickOccured;
  32852. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32853. cameraToUseForPointers: Nullable<Camera>;
  32854. private _pointerX;
  32855. private _pointerY;
  32856. private _unTranslatedPointerX;
  32857. private _unTranslatedPointerY;
  32858. private _startingPointerPosition;
  32859. private _previousStartingPointerPosition;
  32860. private _startingPointerTime;
  32861. private _previousStartingPointerTime;
  32862. private _pointerCaptures;
  32863. private _timeAccumulator;
  32864. private _currentStepId;
  32865. private _currentInternalStep;
  32866. /** @hidden */
  32867. _mirroredCameraPosition: Nullable<Vector3>;
  32868. /**
  32869. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32870. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32871. */
  32872. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32873. /**
  32874. * Observable event triggered each time an keyboard event is received from the hosting window
  32875. */
  32876. onKeyboardObservable: Observable<KeyboardInfo>;
  32877. private _onKeyDown;
  32878. private _onKeyUp;
  32879. private _onCanvasFocusObserver;
  32880. private _onCanvasBlurObserver;
  32881. private _useRightHandedSystem;
  32882. /**
  32883. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32884. */
  32885. useRightHandedSystem: boolean;
  32886. /**
  32887. * Sets the step Id used by deterministic lock step
  32888. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32889. * @param newStepId defines the step Id
  32890. */
  32891. setStepId(newStepId: number): void;
  32892. /**
  32893. * Gets the step Id used by deterministic lock step
  32894. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32895. * @returns the step Id
  32896. */
  32897. getStepId(): number;
  32898. /**
  32899. * Gets the internal step used by deterministic lock step
  32900. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32901. * @returns the internal step
  32902. */
  32903. getInternalStep(): number;
  32904. private _fogEnabled;
  32905. /**
  32906. * Gets or sets a boolean indicating if fog is enabled on this scene
  32907. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32908. * (Default is true)
  32909. */
  32910. fogEnabled: boolean;
  32911. private _fogMode;
  32912. /**
  32913. * Gets or sets the fog mode to use
  32914. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32915. * | mode | value |
  32916. * | --- | --- |
  32917. * | FOGMODE_NONE | 0 |
  32918. * | FOGMODE_EXP | 1 |
  32919. * | FOGMODE_EXP2 | 2 |
  32920. * | FOGMODE_LINEAR | 3 |
  32921. */
  32922. fogMode: number;
  32923. /**
  32924. * Gets or sets the fog color to use
  32925. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32926. * (Default is Color3(0.2, 0.2, 0.3))
  32927. */
  32928. fogColor: Color3;
  32929. /**
  32930. * Gets or sets the fog density to use
  32931. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32932. * (Default is 0.1)
  32933. */
  32934. fogDensity: number;
  32935. /**
  32936. * Gets or sets the fog start distance to use
  32937. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32938. * (Default is 0)
  32939. */
  32940. fogStart: number;
  32941. /**
  32942. * Gets or sets the fog end distance to use
  32943. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32944. * (Default is 1000)
  32945. */
  32946. fogEnd: number;
  32947. private _shadowsEnabled;
  32948. /**
  32949. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32950. */
  32951. shadowsEnabled: boolean;
  32952. private _lightsEnabled;
  32953. /**
  32954. * Gets or sets a boolean indicating if lights are enabled on this scene
  32955. */
  32956. lightsEnabled: boolean;
  32957. /** All of the active cameras added to this scene. */
  32958. activeCameras: Camera[];
  32959. /** @hidden */
  32960. _activeCamera: Nullable<Camera>;
  32961. /** Gets or sets the current active camera */
  32962. activeCamera: Nullable<Camera>;
  32963. private _defaultMaterial;
  32964. /** The default material used on meshes when no material is affected */
  32965. /** The default material used on meshes when no material is affected */
  32966. defaultMaterial: Material;
  32967. private _texturesEnabled;
  32968. /**
  32969. * Gets or sets a boolean indicating if textures are enabled on this scene
  32970. */
  32971. texturesEnabled: boolean;
  32972. /**
  32973. * Gets or sets a boolean indicating if particles are enabled on this scene
  32974. */
  32975. particlesEnabled: boolean;
  32976. /**
  32977. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32978. */
  32979. spritesEnabled: boolean;
  32980. private _skeletonsEnabled;
  32981. /**
  32982. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32983. */
  32984. skeletonsEnabled: boolean;
  32985. /**
  32986. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32987. */
  32988. lensFlaresEnabled: boolean;
  32989. /**
  32990. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32991. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32992. */
  32993. collisionsEnabled: boolean;
  32994. private _collisionCoordinator;
  32995. /** @hidden */
  32996. readonly collisionCoordinator: ICollisionCoordinator;
  32997. /**
  32998. * Defines the gravity applied to this scene (used only for collisions)
  32999. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33000. */
  33001. gravity: Vector3;
  33002. /**
  33003. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33004. */
  33005. postProcessesEnabled: boolean;
  33006. /**
  33007. * The list of postprocesses added to the scene
  33008. */
  33009. postProcesses: PostProcess[];
  33010. /**
  33011. * Gets the current postprocess manager
  33012. */
  33013. postProcessManager: PostProcessManager;
  33014. /**
  33015. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33016. */
  33017. renderTargetsEnabled: boolean;
  33018. /**
  33019. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33020. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33021. */
  33022. dumpNextRenderTargets: boolean;
  33023. /**
  33024. * The list of user defined render targets added to the scene
  33025. */
  33026. customRenderTargets: RenderTargetTexture[];
  33027. /**
  33028. * Defines if texture loading must be delayed
  33029. * If true, textures will only be loaded when they need to be rendered
  33030. */
  33031. useDelayedTextureLoading: boolean;
  33032. /**
  33033. * Gets the list of meshes imported to the scene through SceneLoader
  33034. */
  33035. importedMeshesFiles: String[];
  33036. /**
  33037. * Gets or sets a boolean indicating if probes are enabled on this scene
  33038. */
  33039. probesEnabled: boolean;
  33040. /**
  33041. * Gets or sets the current offline provider to use to store scene data
  33042. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33043. */
  33044. offlineProvider: IOfflineProvider;
  33045. /**
  33046. * Gets or sets the action manager associated with the scene
  33047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33048. */
  33049. actionManager: AbstractActionManager;
  33050. private _meshesForIntersections;
  33051. /**
  33052. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33053. */
  33054. proceduralTexturesEnabled: boolean;
  33055. private _engine;
  33056. private _totalVertices;
  33057. /** @hidden */
  33058. _activeIndices: PerfCounter;
  33059. /** @hidden */
  33060. _activeParticles: PerfCounter;
  33061. /** @hidden */
  33062. _activeBones: PerfCounter;
  33063. private _animationRatio;
  33064. /** @hidden */
  33065. _animationTimeLast: number;
  33066. /** @hidden */
  33067. _animationTime: number;
  33068. /**
  33069. * Gets or sets a general scale for animation speed
  33070. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33071. */
  33072. animationTimeScale: number;
  33073. /** @hidden */
  33074. _cachedMaterial: Nullable<Material>;
  33075. /** @hidden */
  33076. _cachedEffect: Nullable<Effect>;
  33077. /** @hidden */
  33078. _cachedVisibility: Nullable<number>;
  33079. private _renderId;
  33080. private _frameId;
  33081. private _executeWhenReadyTimeoutId;
  33082. private _intermediateRendering;
  33083. private _viewUpdateFlag;
  33084. private _projectionUpdateFlag;
  33085. /** @hidden */
  33086. _toBeDisposed: Nullable<IDisposable>[];
  33087. private _activeRequests;
  33088. /** @hidden */
  33089. _pendingData: any[];
  33090. private _isDisposed;
  33091. /**
  33092. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33093. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33094. */
  33095. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33096. private _activeMeshes;
  33097. private _processedMaterials;
  33098. private _renderTargets;
  33099. /** @hidden */
  33100. _activeParticleSystems: SmartArray<IParticleSystem>;
  33101. private _activeSkeletons;
  33102. private _softwareSkinnedMeshes;
  33103. private _renderingManager;
  33104. /** @hidden */
  33105. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33106. private _transformMatrix;
  33107. private _sceneUbo;
  33108. /** @hidden */
  33109. _viewMatrix: Matrix;
  33110. private _projectionMatrix;
  33111. private _wheelEventName;
  33112. /** @hidden */
  33113. _forcedViewPosition: Nullable<Vector3>;
  33114. /** @hidden */
  33115. _frustumPlanes: Plane[];
  33116. /**
  33117. * Gets the list of frustum planes (built from the active camera)
  33118. */
  33119. readonly frustumPlanes: Plane[];
  33120. /**
  33121. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33122. * This is useful if there are more lights that the maximum simulteanous authorized
  33123. */
  33124. requireLightSorting: boolean;
  33125. /** @hidden */
  33126. readonly useMaterialMeshMap: boolean;
  33127. /** @hidden */
  33128. readonly useClonedMeshhMap: boolean;
  33129. private _pointerOverMesh;
  33130. private _pickedDownMesh;
  33131. private _pickedUpMesh;
  33132. private _externalData;
  33133. private _uid;
  33134. /**
  33135. * @hidden
  33136. * Backing store of defined scene components.
  33137. */
  33138. _components: ISceneComponent[];
  33139. /**
  33140. * @hidden
  33141. * Backing store of defined scene components.
  33142. */
  33143. _serializableComponents: ISceneSerializableComponent[];
  33144. /**
  33145. * List of components to register on the next registration step.
  33146. */
  33147. private _transientComponents;
  33148. /**
  33149. * Registers the transient components if needed.
  33150. */
  33151. private _registerTransientComponents;
  33152. /**
  33153. * @hidden
  33154. * Add a component to the scene.
  33155. * Note that the ccomponent could be registered on th next frame if this is called after
  33156. * the register component stage.
  33157. * @param component Defines the component to add to the scene
  33158. */
  33159. _addComponent(component: ISceneComponent): void;
  33160. /**
  33161. * @hidden
  33162. * Gets a component from the scene.
  33163. * @param name defines the name of the component to retrieve
  33164. * @returns the component or null if not present
  33165. */
  33166. _getComponent(name: string): Nullable<ISceneComponent>;
  33167. /**
  33168. * @hidden
  33169. * Defines the actions happening before camera updates.
  33170. */
  33171. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33172. /**
  33173. * @hidden
  33174. * Defines the actions happening before clear the canvas.
  33175. */
  33176. _beforeClearStage: Stage<SimpleStageAction>;
  33177. /**
  33178. * @hidden
  33179. * Defines the actions when collecting render targets for the frame.
  33180. */
  33181. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33182. /**
  33183. * @hidden
  33184. * Defines the actions happening for one camera in the frame.
  33185. */
  33186. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33187. /**
  33188. * @hidden
  33189. * Defines the actions happening during the per mesh ready checks.
  33190. */
  33191. _isReadyForMeshStage: Stage<MeshStageAction>;
  33192. /**
  33193. * @hidden
  33194. * Defines the actions happening before evaluate active mesh checks.
  33195. */
  33196. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33197. /**
  33198. * @hidden
  33199. * Defines the actions happening during the evaluate sub mesh checks.
  33200. */
  33201. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33202. /**
  33203. * @hidden
  33204. * Defines the actions happening during the active mesh stage.
  33205. */
  33206. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33207. /**
  33208. * @hidden
  33209. * Defines the actions happening during the per camera render target step.
  33210. */
  33211. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33212. /**
  33213. * @hidden
  33214. * Defines the actions happening just before the active camera is drawing.
  33215. */
  33216. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33217. /**
  33218. * @hidden
  33219. * Defines the actions happening just before a render target is drawing.
  33220. */
  33221. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33222. /**
  33223. * @hidden
  33224. * Defines the actions happening just before a rendering group is drawing.
  33225. */
  33226. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33227. /**
  33228. * @hidden
  33229. * Defines the actions happening just before a mesh is drawing.
  33230. */
  33231. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33232. /**
  33233. * @hidden
  33234. * Defines the actions happening just after a mesh has been drawn.
  33235. */
  33236. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33237. /**
  33238. * @hidden
  33239. * Defines the actions happening just after a rendering group has been drawn.
  33240. */
  33241. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33242. /**
  33243. * @hidden
  33244. * Defines the actions happening just after the active camera has been drawn.
  33245. */
  33246. _afterCameraDrawStage: Stage<CameraStageAction>;
  33247. /**
  33248. * @hidden
  33249. * Defines the actions happening just after a render target has been drawn.
  33250. */
  33251. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33252. /**
  33253. * @hidden
  33254. * Defines the actions happening just after rendering all cameras and computing intersections.
  33255. */
  33256. _afterRenderStage: Stage<SimpleStageAction>;
  33257. /**
  33258. * @hidden
  33259. * Defines the actions happening when a pointer move event happens.
  33260. */
  33261. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33262. /**
  33263. * @hidden
  33264. * Defines the actions happening when a pointer down event happens.
  33265. */
  33266. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33267. /**
  33268. * @hidden
  33269. * Defines the actions happening when a pointer up event happens.
  33270. */
  33271. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33272. /**
  33273. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33274. */
  33275. private geometriesByUniqueId;
  33276. /**
  33277. * Creates a new Scene
  33278. * @param engine defines the engine to use to render this scene
  33279. * @param options defines the scene options
  33280. */
  33281. constructor(engine: Engine, options?: SceneOptions);
  33282. /**
  33283. * Gets a string idenfifying the name of the class
  33284. * @returns "Scene" string
  33285. */
  33286. getClassName(): string;
  33287. private _defaultMeshCandidates;
  33288. /**
  33289. * @hidden
  33290. */
  33291. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33292. private _defaultSubMeshCandidates;
  33293. /**
  33294. * @hidden
  33295. */
  33296. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33297. /**
  33298. * Sets the default candidate providers for the scene.
  33299. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33300. * and getCollidingSubMeshCandidates to their default function
  33301. */
  33302. setDefaultCandidateProviders(): void;
  33303. /**
  33304. * Gets the mesh that is currently under the pointer
  33305. */
  33306. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33307. /**
  33308. * Gets or sets the current on-screen X position of the pointer
  33309. */
  33310. pointerX: number;
  33311. /**
  33312. * Gets or sets the current on-screen Y position of the pointer
  33313. */
  33314. pointerY: number;
  33315. /**
  33316. * Gets the cached material (ie. the latest rendered one)
  33317. * @returns the cached material
  33318. */
  33319. getCachedMaterial(): Nullable<Material>;
  33320. /**
  33321. * Gets the cached effect (ie. the latest rendered one)
  33322. * @returns the cached effect
  33323. */
  33324. getCachedEffect(): Nullable<Effect>;
  33325. /**
  33326. * Gets the cached visibility state (ie. the latest rendered one)
  33327. * @returns the cached visibility state
  33328. */
  33329. getCachedVisibility(): Nullable<number>;
  33330. /**
  33331. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33332. * @param material defines the current material
  33333. * @param effect defines the current effect
  33334. * @param visibility defines the current visibility state
  33335. * @returns true if one parameter is not cached
  33336. */
  33337. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33338. /**
  33339. * Gets the engine associated with the scene
  33340. * @returns an Engine
  33341. */
  33342. getEngine(): Engine;
  33343. /**
  33344. * Gets the total number of vertices rendered per frame
  33345. * @returns the total number of vertices rendered per frame
  33346. */
  33347. getTotalVertices(): number;
  33348. /**
  33349. * Gets the performance counter for total vertices
  33350. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33351. */
  33352. readonly totalVerticesPerfCounter: PerfCounter;
  33353. /**
  33354. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33355. * @returns the total number of active indices rendered per frame
  33356. */
  33357. getActiveIndices(): number;
  33358. /**
  33359. * Gets the performance counter for active indices
  33360. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33361. */
  33362. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33363. /**
  33364. * Gets the total number of active particles rendered per frame
  33365. * @returns the total number of active particles rendered per frame
  33366. */
  33367. getActiveParticles(): number;
  33368. /**
  33369. * Gets the performance counter for active particles
  33370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33371. */
  33372. readonly activeParticlesPerfCounter: PerfCounter;
  33373. /**
  33374. * Gets the total number of active bones rendered per frame
  33375. * @returns the total number of active bones rendered per frame
  33376. */
  33377. getActiveBones(): number;
  33378. /**
  33379. * Gets the performance counter for active bones
  33380. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33381. */
  33382. readonly activeBonesPerfCounter: PerfCounter;
  33383. /**
  33384. * Gets the array of active meshes
  33385. * @returns an array of AbstractMesh
  33386. */
  33387. getActiveMeshes(): SmartArray<AbstractMesh>;
  33388. /**
  33389. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33390. * @returns a number
  33391. */
  33392. getAnimationRatio(): number;
  33393. /**
  33394. * Gets an unique Id for the current render phase
  33395. * @returns a number
  33396. */
  33397. getRenderId(): number;
  33398. /**
  33399. * Gets an unique Id for the current frame
  33400. * @returns a number
  33401. */
  33402. getFrameId(): number;
  33403. /** Call this function if you want to manually increment the render Id*/
  33404. incrementRenderId(): void;
  33405. private _updatePointerPosition;
  33406. private _createUbo;
  33407. private _setRayOnPointerInfo;
  33408. /**
  33409. * Use this method to simulate a pointer move on a mesh
  33410. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33411. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33412. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33413. * @returns the current scene
  33414. */
  33415. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33416. private _processPointerMove;
  33417. private _checkPrePointerObservable;
  33418. /**
  33419. * Use this method to simulate a pointer down on a mesh
  33420. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33421. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33422. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33423. * @returns the current scene
  33424. */
  33425. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33426. private _processPointerDown;
  33427. /**
  33428. * Use this method to simulate a pointer up on a mesh
  33429. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33430. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33431. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33432. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33433. * @returns the current scene
  33434. */
  33435. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33436. private _processPointerUp;
  33437. /**
  33438. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33439. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33440. * @returns true if the pointer was captured
  33441. */
  33442. isPointerCaptured(pointerId?: number): boolean;
  33443. /** @hidden */
  33444. _isPointerSwiping(): boolean;
  33445. /**
  33446. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33447. * @param attachUp defines if you want to attach events to pointerup
  33448. * @param attachDown defines if you want to attach events to pointerdown
  33449. * @param attachMove defines if you want to attach events to pointermove
  33450. */
  33451. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33452. /** Detaches all event handlers*/
  33453. detachControl(): void;
  33454. /**
  33455. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33456. * Delay loaded resources are not taking in account
  33457. * @return true if all required resources are ready
  33458. */
  33459. isReady(): boolean;
  33460. /** Resets all cached information relative to material (including effect and visibility) */
  33461. resetCachedMaterial(): void;
  33462. /**
  33463. * Registers a function to be called before every frame render
  33464. * @param func defines the function to register
  33465. */
  33466. registerBeforeRender(func: () => void): void;
  33467. /**
  33468. * Unregisters a function called before every frame render
  33469. * @param func defines the function to unregister
  33470. */
  33471. unregisterBeforeRender(func: () => void): void;
  33472. /**
  33473. * Registers a function to be called after every frame render
  33474. * @param func defines the function to register
  33475. */
  33476. registerAfterRender(func: () => void): void;
  33477. /**
  33478. * Unregisters a function called after every frame render
  33479. * @param func defines the function to unregister
  33480. */
  33481. unregisterAfterRender(func: () => void): void;
  33482. private _executeOnceBeforeRender;
  33483. /**
  33484. * The provided function will run before render once and will be disposed afterwards.
  33485. * A timeout delay can be provided so that the function will be executed in N ms.
  33486. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33487. * @param func The function to be executed.
  33488. * @param timeout optional delay in ms
  33489. */
  33490. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33491. /** @hidden */
  33492. _addPendingData(data: any): void;
  33493. /** @hidden */
  33494. _removePendingData(data: any): void;
  33495. /**
  33496. * Returns the number of items waiting to be loaded
  33497. * @returns the number of items waiting to be loaded
  33498. */
  33499. getWaitingItemsCount(): number;
  33500. /**
  33501. * Returns a boolean indicating if the scene is still loading data
  33502. */
  33503. readonly isLoading: boolean;
  33504. /**
  33505. * Registers a function to be executed when the scene is ready
  33506. * @param {Function} func - the function to be executed
  33507. */
  33508. executeWhenReady(func: () => void): void;
  33509. /**
  33510. * Returns a promise that resolves when the scene is ready
  33511. * @returns A promise that resolves when the scene is ready
  33512. */
  33513. whenReadyAsync(): Promise<void>;
  33514. /** @hidden */
  33515. _checkIsReady(): void;
  33516. /**
  33517. * Gets all animatable attached to the scene
  33518. */
  33519. readonly animatables: Animatable[];
  33520. /**
  33521. * Resets the last animation time frame.
  33522. * Useful to override when animations start running when loading a scene for the first time.
  33523. */
  33524. resetLastAnimationTimeFrame(): void;
  33525. /**
  33526. * Gets the current view matrix
  33527. * @returns a Matrix
  33528. */
  33529. getViewMatrix(): Matrix;
  33530. /**
  33531. * Gets the current projection matrix
  33532. * @returns a Matrix
  33533. */
  33534. getProjectionMatrix(): Matrix;
  33535. /**
  33536. * Gets the current transform matrix
  33537. * @returns a Matrix made of View * Projection
  33538. */
  33539. getTransformMatrix(): Matrix;
  33540. /**
  33541. * Sets the current transform matrix
  33542. * @param viewL defines the View matrix to use
  33543. * @param projectionL defines the Projection matrix to use
  33544. * @param viewR defines the right View matrix to use (if provided)
  33545. * @param projectionR defines the right Projection matrix to use (if provided)
  33546. */
  33547. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33548. /**
  33549. * Gets the uniform buffer used to store scene data
  33550. * @returns a UniformBuffer
  33551. */
  33552. getSceneUniformBuffer(): UniformBuffer;
  33553. /**
  33554. * Gets an unique (relatively to the current scene) Id
  33555. * @returns an unique number for the scene
  33556. */
  33557. getUniqueId(): number;
  33558. /**
  33559. * Add a mesh to the list of scene's meshes
  33560. * @param newMesh defines the mesh to add
  33561. * @param recursive if all child meshes should also be added to the scene
  33562. */
  33563. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33564. /**
  33565. * Remove a mesh for the list of scene's meshes
  33566. * @param toRemove defines the mesh to remove
  33567. * @param recursive if all child meshes should also be removed from the scene
  33568. * @returns the index where the mesh was in the mesh list
  33569. */
  33570. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33571. /**
  33572. * Add a transform node to the list of scene's transform nodes
  33573. * @param newTransformNode defines the transform node to add
  33574. */
  33575. addTransformNode(newTransformNode: TransformNode): void;
  33576. /**
  33577. * Remove a transform node for the list of scene's transform nodes
  33578. * @param toRemove defines the transform node to remove
  33579. * @returns the index where the transform node was in the transform node list
  33580. */
  33581. removeTransformNode(toRemove: TransformNode): number;
  33582. /**
  33583. * Remove a skeleton for the list of scene's skeletons
  33584. * @param toRemove defines the skeleton to remove
  33585. * @returns the index where the skeleton was in the skeleton list
  33586. */
  33587. removeSkeleton(toRemove: Skeleton): number;
  33588. /**
  33589. * Remove a morph target for the list of scene's morph targets
  33590. * @param toRemove defines the morph target to remove
  33591. * @returns the index where the morph target was in the morph target list
  33592. */
  33593. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33594. /**
  33595. * Remove a light for the list of scene's lights
  33596. * @param toRemove defines the light to remove
  33597. * @returns the index where the light was in the light list
  33598. */
  33599. removeLight(toRemove: Light): number;
  33600. /**
  33601. * Remove a camera for the list of scene's cameras
  33602. * @param toRemove defines the camera to remove
  33603. * @returns the index where the camera was in the camera list
  33604. */
  33605. removeCamera(toRemove: Camera): number;
  33606. /**
  33607. * Remove a particle system for the list of scene's particle systems
  33608. * @param toRemove defines the particle system to remove
  33609. * @returns the index where the particle system was in the particle system list
  33610. */
  33611. removeParticleSystem(toRemove: IParticleSystem): number;
  33612. /**
  33613. * Remove a animation for the list of scene's animations
  33614. * @param toRemove defines the animation to remove
  33615. * @returns the index where the animation was in the animation list
  33616. */
  33617. removeAnimation(toRemove: Animation): number;
  33618. /**
  33619. * Removes the given animation group from this scene.
  33620. * @param toRemove The animation group to remove
  33621. * @returns The index of the removed animation group
  33622. */
  33623. removeAnimationGroup(toRemove: AnimationGroup): number;
  33624. /**
  33625. * Removes the given multi-material from this scene.
  33626. * @param toRemove The multi-material to remove
  33627. * @returns The index of the removed multi-material
  33628. */
  33629. removeMultiMaterial(toRemove: MultiMaterial): number;
  33630. /**
  33631. * Removes the given material from this scene.
  33632. * @param toRemove The material to remove
  33633. * @returns The index of the removed material
  33634. */
  33635. removeMaterial(toRemove: Material): number;
  33636. /**
  33637. * Removes the given action manager from this scene.
  33638. * @param toRemove The action manager to remove
  33639. * @returns The index of the removed action manager
  33640. */
  33641. removeActionManager(toRemove: AbstractActionManager): number;
  33642. /**
  33643. * Removes the given texture from this scene.
  33644. * @param toRemove The texture to remove
  33645. * @returns The index of the removed texture
  33646. */
  33647. removeTexture(toRemove: BaseTexture): number;
  33648. /**
  33649. * Adds the given light to this scene
  33650. * @param newLight The light to add
  33651. */
  33652. addLight(newLight: Light): void;
  33653. /**
  33654. * Sorts the list list based on light priorities
  33655. */
  33656. sortLightsByPriority(): void;
  33657. /**
  33658. * Adds the given camera to this scene
  33659. * @param newCamera The camera to add
  33660. */
  33661. addCamera(newCamera: Camera): void;
  33662. /**
  33663. * Adds the given skeleton to this scene
  33664. * @param newSkeleton The skeleton to add
  33665. */
  33666. addSkeleton(newSkeleton: Skeleton): void;
  33667. /**
  33668. * Adds the given particle system to this scene
  33669. * @param newParticleSystem The particle system to add
  33670. */
  33671. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33672. /**
  33673. * Adds the given animation to this scene
  33674. * @param newAnimation The animation to add
  33675. */
  33676. addAnimation(newAnimation: Animation): void;
  33677. /**
  33678. * Adds the given animation group to this scene.
  33679. * @param newAnimationGroup The animation group to add
  33680. */
  33681. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33682. /**
  33683. * Adds the given multi-material to this scene
  33684. * @param newMultiMaterial The multi-material to add
  33685. */
  33686. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33687. /**
  33688. * Adds the given material to this scene
  33689. * @param newMaterial The material to add
  33690. */
  33691. addMaterial(newMaterial: Material): void;
  33692. /**
  33693. * Adds the given morph target to this scene
  33694. * @param newMorphTargetManager The morph target to add
  33695. */
  33696. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33697. /**
  33698. * Adds the given geometry to this scene
  33699. * @param newGeometry The geometry to add
  33700. */
  33701. addGeometry(newGeometry: Geometry): void;
  33702. /**
  33703. * Adds the given action manager to this scene
  33704. * @param newActionManager The action manager to add
  33705. */
  33706. addActionManager(newActionManager: AbstractActionManager): void;
  33707. /**
  33708. * Adds the given texture to this scene.
  33709. * @param newTexture The texture to add
  33710. */
  33711. addTexture(newTexture: BaseTexture): void;
  33712. /**
  33713. * Switch active camera
  33714. * @param newCamera defines the new active camera
  33715. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33716. */
  33717. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33718. /**
  33719. * sets the active camera of the scene using its ID
  33720. * @param id defines the camera's ID
  33721. * @return the new active camera or null if none found.
  33722. */
  33723. setActiveCameraByID(id: string): Nullable<Camera>;
  33724. /**
  33725. * sets the active camera of the scene using its name
  33726. * @param name defines the camera's name
  33727. * @returns the new active camera or null if none found.
  33728. */
  33729. setActiveCameraByName(name: string): Nullable<Camera>;
  33730. /**
  33731. * get an animation group using its name
  33732. * @param name defines the material's name
  33733. * @return the animation group or null if none found.
  33734. */
  33735. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33736. /**
  33737. * Get a material using its unique id
  33738. * @param uniqueId defines the material's unique id
  33739. * @return the material or null if none found.
  33740. */
  33741. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33742. /**
  33743. * get a material using its id
  33744. * @param id defines the material's ID
  33745. * @return the material or null if none found.
  33746. */
  33747. getMaterialByID(id: string): Nullable<Material>;
  33748. /**
  33749. * Gets a material using its name
  33750. * @param name defines the material's name
  33751. * @return the material or null if none found.
  33752. */
  33753. getMaterialByName(name: string): Nullable<Material>;
  33754. /**
  33755. * Gets a camera using its id
  33756. * @param id defines the id to look for
  33757. * @returns the camera or null if not found
  33758. */
  33759. getCameraByID(id: string): Nullable<Camera>;
  33760. /**
  33761. * Gets a camera using its unique id
  33762. * @param uniqueId defines the unique id to look for
  33763. * @returns the camera or null if not found
  33764. */
  33765. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33766. /**
  33767. * Gets a camera using its name
  33768. * @param name defines the camera's name
  33769. * @return the camera or null if none found.
  33770. */
  33771. getCameraByName(name: string): Nullable<Camera>;
  33772. /**
  33773. * Gets a bone using its id
  33774. * @param id defines the bone's id
  33775. * @return the bone or null if not found
  33776. */
  33777. getBoneByID(id: string): Nullable<Bone>;
  33778. /**
  33779. * Gets a bone using its id
  33780. * @param name defines the bone's name
  33781. * @return the bone or null if not found
  33782. */
  33783. getBoneByName(name: string): Nullable<Bone>;
  33784. /**
  33785. * Gets a light node using its name
  33786. * @param name defines the the light's name
  33787. * @return the light or null if none found.
  33788. */
  33789. getLightByName(name: string): Nullable<Light>;
  33790. /**
  33791. * Gets a light node using its id
  33792. * @param id defines the light's id
  33793. * @return the light or null if none found.
  33794. */
  33795. getLightByID(id: string): Nullable<Light>;
  33796. /**
  33797. * Gets a light node using its scene-generated unique ID
  33798. * @param uniqueId defines the light's unique id
  33799. * @return the light or null if none found.
  33800. */
  33801. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33802. /**
  33803. * Gets a particle system by id
  33804. * @param id defines the particle system id
  33805. * @return the corresponding system or null if none found
  33806. */
  33807. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33808. /**
  33809. * Gets a geometry using its ID
  33810. * @param id defines the geometry's id
  33811. * @return the geometry or null if none found.
  33812. */
  33813. getGeometryByID(id: string): Nullable<Geometry>;
  33814. private _getGeometryByUniqueID;
  33815. /**
  33816. * Add a new geometry to this scene
  33817. * @param geometry defines the geometry to be added to the scene.
  33818. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33819. * @return a boolean defining if the geometry was added or not
  33820. */
  33821. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33822. /**
  33823. * Removes an existing geometry
  33824. * @param geometry defines the geometry to be removed from the scene
  33825. * @return a boolean defining if the geometry was removed or not
  33826. */
  33827. removeGeometry(geometry: Geometry): boolean;
  33828. /**
  33829. * Gets the list of geometries attached to the scene
  33830. * @returns an array of Geometry
  33831. */
  33832. getGeometries(): Geometry[];
  33833. /**
  33834. * Gets the first added mesh found of a given ID
  33835. * @param id defines the id to search for
  33836. * @return the mesh found or null if not found at all
  33837. */
  33838. getMeshByID(id: string): Nullable<AbstractMesh>;
  33839. /**
  33840. * Gets a list of meshes using their id
  33841. * @param id defines the id to search for
  33842. * @returns a list of meshes
  33843. */
  33844. getMeshesByID(id: string): Array<AbstractMesh>;
  33845. /**
  33846. * Gets the first added transform node found of a given ID
  33847. * @param id defines the id to search for
  33848. * @return the found transform node or null if not found at all.
  33849. */
  33850. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33851. /**
  33852. * Gets a transform node with its auto-generated unique id
  33853. * @param uniqueId efines the unique id to search for
  33854. * @return the found transform node or null if not found at all.
  33855. */
  33856. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33857. /**
  33858. * Gets a list of transform nodes using their id
  33859. * @param id defines the id to search for
  33860. * @returns a list of transform nodes
  33861. */
  33862. getTransformNodesByID(id: string): Array<TransformNode>;
  33863. /**
  33864. * Gets a mesh with its auto-generated unique id
  33865. * @param uniqueId defines the unique id to search for
  33866. * @return the found mesh or null if not found at all.
  33867. */
  33868. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33869. /**
  33870. * Gets a the last added mesh using a given id
  33871. * @param id defines the id to search for
  33872. * @return the found mesh or null if not found at all.
  33873. */
  33874. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33875. /**
  33876. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33877. * @param id defines the id to search for
  33878. * @return the found node or null if not found at all
  33879. */
  33880. getLastEntryByID(id: string): Nullable<Node>;
  33881. /**
  33882. * Gets a node (Mesh, Camera, Light) using a given id
  33883. * @param id defines the id to search for
  33884. * @return the found node or null if not found at all
  33885. */
  33886. getNodeByID(id: string): Nullable<Node>;
  33887. /**
  33888. * Gets a node (Mesh, Camera, Light) using a given name
  33889. * @param name defines the name to search for
  33890. * @return the found node or null if not found at all.
  33891. */
  33892. getNodeByName(name: string): Nullable<Node>;
  33893. /**
  33894. * Gets a mesh using a given name
  33895. * @param name defines the name to search for
  33896. * @return the found mesh or null if not found at all.
  33897. */
  33898. getMeshByName(name: string): Nullable<AbstractMesh>;
  33899. /**
  33900. * Gets a transform node using a given name
  33901. * @param name defines the name to search for
  33902. * @return the found transform node or null if not found at all.
  33903. */
  33904. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33905. /**
  33906. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33907. * @param id defines the id to search for
  33908. * @return the found skeleton or null if not found at all.
  33909. */
  33910. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33911. /**
  33912. * Gets a skeleton using a given auto generated unique id
  33913. * @param uniqueId defines the unique id to search for
  33914. * @return the found skeleton or null if not found at all.
  33915. */
  33916. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33917. /**
  33918. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33919. * @param id defines the id to search for
  33920. * @return the found skeleton or null if not found at all.
  33921. */
  33922. getSkeletonById(id: string): Nullable<Skeleton>;
  33923. /**
  33924. * Gets a skeleton using a given name
  33925. * @param name defines the name to search for
  33926. * @return the found skeleton or null if not found at all.
  33927. */
  33928. getSkeletonByName(name: string): Nullable<Skeleton>;
  33929. /**
  33930. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33931. * @param id defines the id to search for
  33932. * @return the found morph target manager or null if not found at all.
  33933. */
  33934. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33935. /**
  33936. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33937. * @param id defines the id to search for
  33938. * @return the found morph target or null if not found at all.
  33939. */
  33940. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33941. /**
  33942. * Gets a boolean indicating if the given mesh is active
  33943. * @param mesh defines the mesh to look for
  33944. * @returns true if the mesh is in the active list
  33945. */
  33946. isActiveMesh(mesh: AbstractMesh): boolean;
  33947. /**
  33948. * Return a unique id as a string which can serve as an identifier for the scene
  33949. */
  33950. readonly uid: string;
  33951. /**
  33952. * Add an externaly attached data from its key.
  33953. * This method call will fail and return false, if such key already exists.
  33954. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33955. * @param key the unique key that identifies the data
  33956. * @param data the data object to associate to the key for this Engine instance
  33957. * @return true if no such key were already present and the data was added successfully, false otherwise
  33958. */
  33959. addExternalData<T>(key: string, data: T): boolean;
  33960. /**
  33961. * Get an externaly attached data from its key
  33962. * @param key the unique key that identifies the data
  33963. * @return the associated data, if present (can be null), or undefined if not present
  33964. */
  33965. getExternalData<T>(key: string): Nullable<T>;
  33966. /**
  33967. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33968. * @param key the unique key that identifies the data
  33969. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33970. * @return the associated data, can be null if the factory returned null.
  33971. */
  33972. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33973. /**
  33974. * Remove an externaly attached data from the Engine instance
  33975. * @param key the unique key that identifies the data
  33976. * @return true if the data was successfully removed, false if it doesn't exist
  33977. */
  33978. removeExternalData(key: string): boolean;
  33979. private _evaluateSubMesh;
  33980. /**
  33981. * Clear the processed materials smart array preventing retention point in material dispose.
  33982. */
  33983. freeProcessedMaterials(): void;
  33984. private _preventFreeActiveMeshesAndRenderingGroups;
  33985. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33986. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33987. * when disposing several meshes in a row or a hierarchy of meshes.
  33988. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33989. */
  33990. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33991. /**
  33992. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33993. */
  33994. freeActiveMeshes(): void;
  33995. /**
  33996. * Clear the info related to rendering groups preventing retention points during dispose.
  33997. */
  33998. freeRenderingGroups(): void;
  33999. /** @hidden */
  34000. _isInIntermediateRendering(): boolean;
  34001. /**
  34002. * Lambda returning the list of potentially active meshes.
  34003. */
  34004. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34005. /**
  34006. * Lambda returning the list of potentially active sub meshes.
  34007. */
  34008. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34009. /**
  34010. * Lambda returning the list of potentially intersecting sub meshes.
  34011. */
  34012. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34013. /**
  34014. * Lambda returning the list of potentially colliding sub meshes.
  34015. */
  34016. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34017. private _activeMeshesFrozen;
  34018. /**
  34019. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34020. * @returns the current scene
  34021. */
  34022. freezeActiveMeshes(): Scene;
  34023. /**
  34024. * Use this function to restart evaluating active meshes on every frame
  34025. * @returns the current scene
  34026. */
  34027. unfreezeActiveMeshes(): Scene;
  34028. private _evaluateActiveMeshes;
  34029. private _activeMesh;
  34030. /**
  34031. * Update the transform matrix to update from the current active camera
  34032. * @param force defines a boolean used to force the update even if cache is up to date
  34033. */
  34034. updateTransformMatrix(force?: boolean): void;
  34035. private _bindFrameBuffer;
  34036. /** @hidden */
  34037. _allowPostProcessClearColor: boolean;
  34038. /** @hidden */
  34039. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34040. private _processSubCameras;
  34041. private _checkIntersections;
  34042. /** @hidden */
  34043. _advancePhysicsEngineStep(step: number): void;
  34044. /**
  34045. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34046. */
  34047. getDeterministicFrameTime: () => number;
  34048. /** @hidden */
  34049. _animate(): void;
  34050. /**
  34051. * Render the scene
  34052. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34053. */
  34054. render(updateCameras?: boolean): void;
  34055. /**
  34056. * Freeze all materials
  34057. * A frozen material will not be updatable but should be faster to render
  34058. */
  34059. freezeMaterials(): void;
  34060. /**
  34061. * Unfreeze all materials
  34062. * A frozen material will not be updatable but should be faster to render
  34063. */
  34064. unfreezeMaterials(): void;
  34065. /**
  34066. * Releases all held ressources
  34067. */
  34068. dispose(): void;
  34069. /**
  34070. * Gets if the scene is already disposed
  34071. */
  34072. readonly isDisposed: boolean;
  34073. /**
  34074. * Call this function to reduce memory footprint of the scene.
  34075. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34076. */
  34077. clearCachedVertexData(): void;
  34078. /**
  34079. * This function will remove the local cached buffer data from texture.
  34080. * It will save memory but will prevent the texture from being rebuilt
  34081. */
  34082. cleanCachedTextureBuffer(): void;
  34083. /**
  34084. * Get the world extend vectors with an optional filter
  34085. *
  34086. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34087. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34088. */
  34089. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34090. min: Vector3;
  34091. max: Vector3;
  34092. };
  34093. /**
  34094. * Creates a ray that can be used to pick in the scene
  34095. * @param x defines the x coordinate of the origin (on-screen)
  34096. * @param y defines the y coordinate of the origin (on-screen)
  34097. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34098. * @param camera defines the camera to use for the picking
  34099. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34100. * @returns a Ray
  34101. */
  34102. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34103. /**
  34104. * Creates a ray that can be used to pick in the scene
  34105. * @param x defines the x coordinate of the origin (on-screen)
  34106. * @param y defines the y coordinate of the origin (on-screen)
  34107. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34108. * @param result defines the ray where to store the picking ray
  34109. * @param camera defines the camera to use for the picking
  34110. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34111. * @returns the current scene
  34112. */
  34113. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34114. /**
  34115. * Creates a ray that can be used to pick in the scene
  34116. * @param x defines the x coordinate of the origin (on-screen)
  34117. * @param y defines the y coordinate of the origin (on-screen)
  34118. * @param camera defines the camera to use for the picking
  34119. * @returns a Ray
  34120. */
  34121. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34122. /**
  34123. * Creates a ray that can be used to pick in the scene
  34124. * @param x defines the x coordinate of the origin (on-screen)
  34125. * @param y defines the y coordinate of the origin (on-screen)
  34126. * @param result defines the ray where to store the picking ray
  34127. * @param camera defines the camera to use for the picking
  34128. * @returns the current scene
  34129. */
  34130. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34131. /** Launch a ray to try to pick a mesh in the scene
  34132. * @param x position on screen
  34133. * @param y position on screen
  34134. * @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
  34135. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34136. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34137. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34138. * @returns a PickingInfo
  34139. */
  34140. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34141. /** Use the given ray to pick a mesh in the scene
  34142. * @param ray The ray to use to pick meshes
  34143. * @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
  34144. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34145. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34146. * @returns a PickingInfo
  34147. */
  34148. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34149. /**
  34150. * Launch a ray to try to pick a mesh in the scene
  34151. * @param x X position on screen
  34152. * @param y Y position on screen
  34153. * @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
  34154. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34155. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34156. * @returns an array of PickingInfo
  34157. */
  34158. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34159. /**
  34160. * Launch a ray to try to pick a mesh in the scene
  34161. * @param ray Ray to use
  34162. * @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
  34163. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34164. * @returns an array of PickingInfo
  34165. */
  34166. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34167. /**
  34168. * Force the value of meshUnderPointer
  34169. * @param mesh defines the mesh to use
  34170. */
  34171. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34172. /**
  34173. * Gets the mesh under the pointer
  34174. * @returns a Mesh or null if no mesh is under the pointer
  34175. */
  34176. getPointerOverMesh(): Nullable<AbstractMesh>;
  34177. /** @hidden */
  34178. _rebuildGeometries(): void;
  34179. /** @hidden */
  34180. _rebuildTextures(): void;
  34181. private _getByTags;
  34182. /**
  34183. * Get a list of meshes by tags
  34184. * @param tagsQuery defines the tags query to use
  34185. * @param forEach defines a predicate used to filter results
  34186. * @returns an array of Mesh
  34187. */
  34188. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34189. /**
  34190. * Get a list of cameras by tags
  34191. * @param tagsQuery defines the tags query to use
  34192. * @param forEach defines a predicate used to filter results
  34193. * @returns an array of Camera
  34194. */
  34195. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34196. /**
  34197. * Get a list of lights by tags
  34198. * @param tagsQuery defines the tags query to use
  34199. * @param forEach defines a predicate used to filter results
  34200. * @returns an array of Light
  34201. */
  34202. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34203. /**
  34204. * Get a list of materials by tags
  34205. * @param tagsQuery defines the tags query to use
  34206. * @param forEach defines a predicate used to filter results
  34207. * @returns an array of Material
  34208. */
  34209. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34210. /**
  34211. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34212. * This allowed control for front to back rendering or reversly depending of the special needs.
  34213. *
  34214. * @param renderingGroupId The rendering group id corresponding to its index
  34215. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34216. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34217. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34218. */
  34219. 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;
  34220. /**
  34221. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34222. *
  34223. * @param renderingGroupId The rendering group id corresponding to its index
  34224. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34225. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34226. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34227. */
  34228. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34229. /**
  34230. * Gets the current auto clear configuration for one rendering group of the rendering
  34231. * manager.
  34232. * @param index the rendering group index to get the information for
  34233. * @returns The auto clear setup for the requested rendering group
  34234. */
  34235. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34236. private _blockMaterialDirtyMechanism;
  34237. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34238. blockMaterialDirtyMechanism: boolean;
  34239. /**
  34240. * Will flag all materials as dirty to trigger new shader compilation
  34241. * @param flag defines the flag used to specify which material part must be marked as dirty
  34242. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34243. */
  34244. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34245. /** @hidden */
  34246. _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;
  34247. /** @hidden */
  34248. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34249. }
  34250. }
  34251. declare module "babylonjs/assetContainer" {
  34252. import { AbstractScene } from "babylonjs/abstractScene";
  34253. import { Scene } from "babylonjs/scene";
  34254. import { Mesh } from "babylonjs/Meshes/mesh";
  34255. /**
  34256. * Set of assets to keep when moving a scene into an asset container.
  34257. */
  34258. export class KeepAssets extends AbstractScene {
  34259. }
  34260. /**
  34261. * Container with a set of assets that can be added or removed from a scene.
  34262. */
  34263. export class AssetContainer extends AbstractScene {
  34264. /**
  34265. * The scene the AssetContainer belongs to.
  34266. */
  34267. scene: Scene;
  34268. /**
  34269. * Instantiates an AssetContainer.
  34270. * @param scene The scene the AssetContainer belongs to.
  34271. */
  34272. constructor(scene: Scene);
  34273. /**
  34274. * Adds all the assets from the container to the scene.
  34275. */
  34276. addAllToScene(): void;
  34277. /**
  34278. * Removes all the assets in the container from the scene
  34279. */
  34280. removeAllFromScene(): void;
  34281. /**
  34282. * Disposes all the assets in the container
  34283. */
  34284. dispose(): void;
  34285. private _moveAssets;
  34286. /**
  34287. * Removes all the assets contained in the scene and adds them to the container.
  34288. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34289. */
  34290. moveAllFromScene(keepAssets?: KeepAssets): void;
  34291. /**
  34292. * 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.
  34293. * @returns the root mesh
  34294. */
  34295. createRootMesh(): Mesh;
  34296. }
  34297. }
  34298. declare module "babylonjs/abstractScene" {
  34299. import { Scene } from "babylonjs/scene";
  34300. import { Nullable } from "babylonjs/types";
  34301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34302. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34303. import { Geometry } from "babylonjs/Meshes/geometry";
  34304. import { Skeleton } from "babylonjs/Bones/skeleton";
  34305. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34306. import { AssetContainer } from "babylonjs/assetContainer";
  34307. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34308. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34309. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34310. import { Material } from "babylonjs/Materials/material";
  34311. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34312. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34313. import { Camera } from "babylonjs/Cameras/camera";
  34314. import { Light } from "babylonjs/Lights/light";
  34315. import { Node } from "babylonjs/node";
  34316. import { Animation } from "babylonjs/Animations/animation";
  34317. /**
  34318. * Defines how the parser contract is defined.
  34319. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34320. */
  34321. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34322. /**
  34323. * Defines how the individual parser contract is defined.
  34324. * These parser can parse an individual asset
  34325. */
  34326. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34327. /**
  34328. * Base class of the scene acting as a container for the different elements composing a scene.
  34329. * This class is dynamically extended by the different components of the scene increasing
  34330. * flexibility and reducing coupling
  34331. */
  34332. export abstract class AbstractScene {
  34333. /**
  34334. * Stores the list of available parsers in the application.
  34335. */
  34336. private static _BabylonFileParsers;
  34337. /**
  34338. * Stores the list of available individual parsers in the application.
  34339. */
  34340. private static _IndividualBabylonFileParsers;
  34341. /**
  34342. * Adds a parser in the list of available ones
  34343. * @param name Defines the name of the parser
  34344. * @param parser Defines the parser to add
  34345. */
  34346. static AddParser(name: string, parser: BabylonFileParser): void;
  34347. /**
  34348. * Gets a general parser from the list of avaialble ones
  34349. * @param name Defines the name of the parser
  34350. * @returns the requested parser or null
  34351. */
  34352. static GetParser(name: string): Nullable<BabylonFileParser>;
  34353. /**
  34354. * Adds n individual parser in the list of available ones
  34355. * @param name Defines the name of the parser
  34356. * @param parser Defines the parser to add
  34357. */
  34358. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34359. /**
  34360. * Gets an individual parser from the list of avaialble ones
  34361. * @param name Defines the name of the parser
  34362. * @returns the requested parser or null
  34363. */
  34364. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34365. /**
  34366. * Parser json data and populate both a scene and its associated container object
  34367. * @param jsonData Defines the data to parse
  34368. * @param scene Defines the scene to parse the data for
  34369. * @param container Defines the container attached to the parsing sequence
  34370. * @param rootUrl Defines the root url of the data
  34371. */
  34372. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34373. /**
  34374. * Gets the list of root nodes (ie. nodes with no parent)
  34375. */
  34376. rootNodes: Node[];
  34377. /** All of the cameras added to this scene
  34378. * @see http://doc.babylonjs.com/babylon101/cameras
  34379. */
  34380. cameras: Camera[];
  34381. /**
  34382. * All of the lights added to this scene
  34383. * @see http://doc.babylonjs.com/babylon101/lights
  34384. */
  34385. lights: Light[];
  34386. /**
  34387. * All of the (abstract) meshes added to this scene
  34388. */
  34389. meshes: AbstractMesh[];
  34390. /**
  34391. * The list of skeletons added to the scene
  34392. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34393. */
  34394. skeletons: Skeleton[];
  34395. /**
  34396. * All of the particle systems added to this scene
  34397. * @see http://doc.babylonjs.com/babylon101/particles
  34398. */
  34399. particleSystems: IParticleSystem[];
  34400. /**
  34401. * Gets a list of Animations associated with the scene
  34402. */
  34403. animations: Animation[];
  34404. /**
  34405. * All of the animation groups added to this scene
  34406. * @see http://doc.babylonjs.com/how_to/group
  34407. */
  34408. animationGroups: AnimationGroup[];
  34409. /**
  34410. * All of the multi-materials added to this scene
  34411. * @see http://doc.babylonjs.com/how_to/multi_materials
  34412. */
  34413. multiMaterials: MultiMaterial[];
  34414. /**
  34415. * All of the materials added to this scene
  34416. * In the context of a Scene, it is not supposed to be modified manually.
  34417. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34418. * Note also that the order of the Material wihin the array is not significant and might change.
  34419. * @see http://doc.babylonjs.com/babylon101/materials
  34420. */
  34421. materials: Material[];
  34422. /**
  34423. * The list of morph target managers added to the scene
  34424. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34425. */
  34426. morphTargetManagers: MorphTargetManager[];
  34427. /**
  34428. * The list of geometries used in the scene.
  34429. */
  34430. geometries: Geometry[];
  34431. /**
  34432. * All of the tranform nodes added to this scene
  34433. * In the context of a Scene, it is not supposed to be modified manually.
  34434. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34435. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34436. * @see http://doc.babylonjs.com/how_to/transformnode
  34437. */
  34438. transformNodes: TransformNode[];
  34439. /**
  34440. * ActionManagers available on the scene.
  34441. */
  34442. actionManagers: AbstractActionManager[];
  34443. /**
  34444. * Textures to keep.
  34445. */
  34446. textures: BaseTexture[];
  34447. /**
  34448. * Environment texture for the scene
  34449. */
  34450. environmentTexture: Nullable<BaseTexture>;
  34451. }
  34452. }
  34453. declare module "babylonjs/Audio/sound" {
  34454. import { Observable } from "babylonjs/Misc/observable";
  34455. import { Vector3 } from "babylonjs/Maths/math";
  34456. import { Nullable } from "babylonjs/types";
  34457. import { Scene } from "babylonjs/scene";
  34458. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34459. /**
  34460. * Defines a sound that can be played in the application.
  34461. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34463. */
  34464. export class Sound {
  34465. /**
  34466. * The name of the sound in the scene.
  34467. */
  34468. name: string;
  34469. /**
  34470. * Does the sound autoplay once loaded.
  34471. */
  34472. autoplay: boolean;
  34473. /**
  34474. * Does the sound loop after it finishes playing once.
  34475. */
  34476. loop: boolean;
  34477. /**
  34478. * Does the sound use a custom attenuation curve to simulate the falloff
  34479. * happening when the source gets further away from the camera.
  34480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34481. */
  34482. useCustomAttenuation: boolean;
  34483. /**
  34484. * The sound track id this sound belongs to.
  34485. */
  34486. soundTrackId: number;
  34487. /**
  34488. * Is this sound currently played.
  34489. */
  34490. isPlaying: boolean;
  34491. /**
  34492. * Is this sound currently paused.
  34493. */
  34494. isPaused: boolean;
  34495. /**
  34496. * Does this sound enables spatial sound.
  34497. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34498. */
  34499. spatialSound: boolean;
  34500. /**
  34501. * Define the reference distance the sound should be heard perfectly.
  34502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34503. */
  34504. refDistance: number;
  34505. /**
  34506. * Define the roll off factor of spatial sounds.
  34507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34508. */
  34509. rolloffFactor: number;
  34510. /**
  34511. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34513. */
  34514. maxDistance: number;
  34515. /**
  34516. * Define the distance attenuation model the sound will follow.
  34517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34518. */
  34519. distanceModel: string;
  34520. /**
  34521. * @hidden
  34522. * Back Compat
  34523. **/
  34524. onended: () => any;
  34525. /**
  34526. * Observable event when the current playing sound finishes.
  34527. */
  34528. onEndedObservable: Observable<Sound>;
  34529. private _panningModel;
  34530. private _playbackRate;
  34531. private _streaming;
  34532. private _startTime;
  34533. private _startOffset;
  34534. private _position;
  34535. /** @hidden */
  34536. _positionInEmitterSpace: boolean;
  34537. private _localDirection;
  34538. private _volume;
  34539. private _isReadyToPlay;
  34540. private _isDirectional;
  34541. private _readyToPlayCallback;
  34542. private _audioBuffer;
  34543. private _soundSource;
  34544. private _streamingSource;
  34545. private _soundPanner;
  34546. private _soundGain;
  34547. private _inputAudioNode;
  34548. private _outputAudioNode;
  34549. private _coneInnerAngle;
  34550. private _coneOuterAngle;
  34551. private _coneOuterGain;
  34552. private _scene;
  34553. private _connectedTransformNode;
  34554. private _customAttenuationFunction;
  34555. private _registerFunc;
  34556. private _isOutputConnected;
  34557. private _htmlAudioElement;
  34558. private _urlType;
  34559. /** @hidden */
  34560. static _SceneComponentInitialization: (scene: Scene) => void;
  34561. /**
  34562. * Create a sound and attach it to a scene
  34563. * @param name Name of your sound
  34564. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34565. * @param scene defines the scene the sound belongs to
  34566. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34567. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34568. */
  34569. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34570. /**
  34571. * Release the sound and its associated resources
  34572. */
  34573. dispose(): void;
  34574. /**
  34575. * Gets if the sounds is ready to be played or not.
  34576. * @returns true if ready, otherwise false
  34577. */
  34578. isReady(): boolean;
  34579. private _soundLoaded;
  34580. /**
  34581. * Sets the data of the sound from an audiobuffer
  34582. * @param audioBuffer The audioBuffer containing the data
  34583. */
  34584. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34585. /**
  34586. * Updates the current sounds options such as maxdistance, loop...
  34587. * @param options A JSON object containing values named as the object properties
  34588. */
  34589. updateOptions(options: any): void;
  34590. private _createSpatialParameters;
  34591. private _updateSpatialParameters;
  34592. /**
  34593. * Switch the panning model to HRTF:
  34594. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34596. */
  34597. switchPanningModelToHRTF(): void;
  34598. /**
  34599. * Switch the panning model to Equal Power:
  34600. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34602. */
  34603. switchPanningModelToEqualPower(): void;
  34604. private _switchPanningModel;
  34605. /**
  34606. * Connect this sound to a sound track audio node like gain...
  34607. * @param soundTrackAudioNode the sound track audio node to connect to
  34608. */
  34609. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34610. /**
  34611. * Transform this sound into a directional source
  34612. * @param coneInnerAngle Size of the inner cone in degree
  34613. * @param coneOuterAngle Size of the outer cone in degree
  34614. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34615. */
  34616. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34617. /**
  34618. * Gets or sets the inner angle for the directional cone.
  34619. */
  34620. /**
  34621. * Gets or sets the inner angle for the directional cone.
  34622. */
  34623. directionalConeInnerAngle: number;
  34624. /**
  34625. * Gets or sets the outer angle for the directional cone.
  34626. */
  34627. /**
  34628. * Gets or sets the outer angle for the directional cone.
  34629. */
  34630. directionalConeOuterAngle: number;
  34631. /**
  34632. * Sets the position of the emitter if spatial sound is enabled
  34633. * @param newPosition Defines the new posisiton
  34634. */
  34635. setPosition(newPosition: Vector3): void;
  34636. /**
  34637. * Sets the local direction of the emitter if spatial sound is enabled
  34638. * @param newLocalDirection Defines the new local direction
  34639. */
  34640. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34641. private _updateDirection;
  34642. /** @hidden */
  34643. updateDistanceFromListener(): void;
  34644. /**
  34645. * Sets a new custom attenuation function for the sound.
  34646. * @param callback Defines the function used for the attenuation
  34647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34648. */
  34649. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34650. /**
  34651. * Play the sound
  34652. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34653. * @param offset (optional) Start the sound setting it at a specific time
  34654. */
  34655. play(time?: number, offset?: number): void;
  34656. private _onended;
  34657. /**
  34658. * Stop the sound
  34659. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34660. */
  34661. stop(time?: number): void;
  34662. /**
  34663. * Put the sound in pause
  34664. */
  34665. pause(): void;
  34666. /**
  34667. * Sets a dedicated volume for this sounds
  34668. * @param newVolume Define the new volume of the sound
  34669. * @param time Define in how long the sound should be at this value
  34670. */
  34671. setVolume(newVolume: number, time?: number): void;
  34672. /**
  34673. * Set the sound play back rate
  34674. * @param newPlaybackRate Define the playback rate the sound should be played at
  34675. */
  34676. setPlaybackRate(newPlaybackRate: number): void;
  34677. /**
  34678. * Gets the volume of the sound.
  34679. * @returns the volume of the sound
  34680. */
  34681. getVolume(): number;
  34682. /**
  34683. * Attach the sound to a dedicated mesh
  34684. * @param transformNode The transform node to connect the sound with
  34685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34686. */
  34687. attachToMesh(transformNode: TransformNode): void;
  34688. /**
  34689. * Detach the sound from the previously attached mesh
  34690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34691. */
  34692. detachFromMesh(): void;
  34693. private _onRegisterAfterWorldMatrixUpdate;
  34694. /**
  34695. * Clone the current sound in the scene.
  34696. * @returns the new sound clone
  34697. */
  34698. clone(): Nullable<Sound>;
  34699. /**
  34700. * Gets the current underlying audio buffer containing the data
  34701. * @returns the audio buffer
  34702. */
  34703. getAudioBuffer(): Nullable<AudioBuffer>;
  34704. /**
  34705. * Serializes the Sound in a JSON representation
  34706. * @returns the JSON representation of the sound
  34707. */
  34708. serialize(): any;
  34709. /**
  34710. * Parse a JSON representation of a sound to innstantiate in a given scene
  34711. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34712. * @param scene Define the scene the new parsed sound should be created in
  34713. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34714. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34715. * @returns the newly parsed sound
  34716. */
  34717. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34718. }
  34719. }
  34720. declare module "babylonjs/Actions/directAudioActions" {
  34721. import { Action } from "babylonjs/Actions/action";
  34722. import { Condition } from "babylonjs/Actions/condition";
  34723. import { Sound } from "babylonjs/Audio/sound";
  34724. /**
  34725. * This defines an action helpful to play a defined sound on a triggered action.
  34726. */
  34727. export class PlaySoundAction extends Action {
  34728. private _sound;
  34729. /**
  34730. * Instantiate the action
  34731. * @param triggerOptions defines the trigger options
  34732. * @param sound defines the sound to play
  34733. * @param condition defines the trigger related conditions
  34734. */
  34735. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34736. /** @hidden */
  34737. _prepare(): void;
  34738. /**
  34739. * Execute the action and play the sound.
  34740. */
  34741. execute(): void;
  34742. /**
  34743. * Serializes the actions and its related information.
  34744. * @param parent defines the object to serialize in
  34745. * @returns the serialized object
  34746. */
  34747. serialize(parent: any): any;
  34748. }
  34749. /**
  34750. * This defines an action helpful to stop a defined sound on a triggered action.
  34751. */
  34752. export class StopSoundAction extends Action {
  34753. private _sound;
  34754. /**
  34755. * Instantiate the action
  34756. * @param triggerOptions defines the trigger options
  34757. * @param sound defines the sound to stop
  34758. * @param condition defines the trigger related conditions
  34759. */
  34760. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34761. /** @hidden */
  34762. _prepare(): void;
  34763. /**
  34764. * Execute the action and stop the sound.
  34765. */
  34766. execute(): void;
  34767. /**
  34768. * Serializes the actions and its related information.
  34769. * @param parent defines the object to serialize in
  34770. * @returns the serialized object
  34771. */
  34772. serialize(parent: any): any;
  34773. }
  34774. }
  34775. declare module "babylonjs/Actions/interpolateValueAction" {
  34776. import { Action } from "babylonjs/Actions/action";
  34777. import { Condition } from "babylonjs/Actions/condition";
  34778. import { Observable } from "babylonjs/Misc/observable";
  34779. /**
  34780. * This defines an action responsible to change the value of a property
  34781. * by interpolating between its current value and the newly set one once triggered.
  34782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34783. */
  34784. export class InterpolateValueAction extends Action {
  34785. /**
  34786. * Defines the path of the property where the value should be interpolated
  34787. */
  34788. propertyPath: string;
  34789. /**
  34790. * Defines the target value at the end of the interpolation.
  34791. */
  34792. value: any;
  34793. /**
  34794. * Defines the time it will take for the property to interpolate to the value.
  34795. */
  34796. duration: number;
  34797. /**
  34798. * Defines if the other scene animations should be stopped when the action has been triggered
  34799. */
  34800. stopOtherAnimations?: boolean;
  34801. /**
  34802. * Defines a callback raised once the interpolation animation has been done.
  34803. */
  34804. onInterpolationDone?: () => void;
  34805. /**
  34806. * Observable triggered once the interpolation animation has been done.
  34807. */
  34808. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34809. private _target;
  34810. private _effectiveTarget;
  34811. private _property;
  34812. /**
  34813. * Instantiate the action
  34814. * @param triggerOptions defines the trigger options
  34815. * @param target defines the object containing the value to interpolate
  34816. * @param propertyPath defines the path to the property in the target object
  34817. * @param value defines the target value at the end of the interpolation
  34818. * @param duration deines the time it will take for the property to interpolate to the value.
  34819. * @param condition defines the trigger related conditions
  34820. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34821. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34822. */
  34823. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34824. /** @hidden */
  34825. _prepare(): void;
  34826. /**
  34827. * Execute the action starts the value interpolation.
  34828. */
  34829. execute(): void;
  34830. /**
  34831. * Serializes the actions and its related information.
  34832. * @param parent defines the object to serialize in
  34833. * @returns the serialized object
  34834. */
  34835. serialize(parent: any): any;
  34836. }
  34837. }
  34838. declare module "babylonjs/Actions/index" {
  34839. export * from "babylonjs/Actions/action";
  34840. export * from "babylonjs/Actions/actionEvent";
  34841. export * from "babylonjs/Actions/actionManager";
  34842. export * from "babylonjs/Actions/condition";
  34843. export * from "babylonjs/Actions/directActions";
  34844. export * from "babylonjs/Actions/directAudioActions";
  34845. export * from "babylonjs/Actions/interpolateValueAction";
  34846. }
  34847. declare module "babylonjs/Animations/index" {
  34848. export * from "babylonjs/Animations/animatable";
  34849. export * from "babylonjs/Animations/animation";
  34850. export * from "babylonjs/Animations/animationGroup";
  34851. export * from "babylonjs/Animations/animationPropertiesOverride";
  34852. export * from "babylonjs/Animations/easing";
  34853. export * from "babylonjs/Animations/runtimeAnimation";
  34854. export * from "babylonjs/Animations/animationEvent";
  34855. export * from "babylonjs/Animations/animationGroup";
  34856. export * from "babylonjs/Animations/animationKey";
  34857. export * from "babylonjs/Animations/animationRange";
  34858. }
  34859. declare module "babylonjs/Audio/soundTrack" {
  34860. import { Sound } from "babylonjs/Audio/sound";
  34861. import { Analyser } from "babylonjs/Audio/analyser";
  34862. import { Scene } from "babylonjs/scene";
  34863. /**
  34864. * Options allowed during the creation of a sound track.
  34865. */
  34866. export interface ISoundTrackOptions {
  34867. /**
  34868. * The volume the sound track should take during creation
  34869. */
  34870. volume?: number;
  34871. /**
  34872. * Define if the sound track is the main sound track of the scene
  34873. */
  34874. mainTrack?: boolean;
  34875. }
  34876. /**
  34877. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34878. * It will be also used in a future release to apply effects on a specific track.
  34879. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34880. */
  34881. export class SoundTrack {
  34882. /**
  34883. * The unique identifier of the sound track in the scene.
  34884. */
  34885. id: number;
  34886. /**
  34887. * The list of sounds included in the sound track.
  34888. */
  34889. soundCollection: Array<Sound>;
  34890. private _outputAudioNode;
  34891. private _scene;
  34892. private _isMainTrack;
  34893. private _connectedAnalyser;
  34894. private _options;
  34895. private _isInitialized;
  34896. /**
  34897. * Creates a new sound track.
  34898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34899. * @param scene Define the scene the sound track belongs to
  34900. * @param options
  34901. */
  34902. constructor(scene: Scene, options?: ISoundTrackOptions);
  34903. private _initializeSoundTrackAudioGraph;
  34904. /**
  34905. * Release the sound track and its associated resources
  34906. */
  34907. dispose(): void;
  34908. /**
  34909. * Adds a sound to this sound track
  34910. * @param sound define the cound to add
  34911. * @ignoreNaming
  34912. */
  34913. AddSound(sound: Sound): void;
  34914. /**
  34915. * Removes a sound to this sound track
  34916. * @param sound define the cound to remove
  34917. * @ignoreNaming
  34918. */
  34919. RemoveSound(sound: Sound): void;
  34920. /**
  34921. * Set a global volume for the full sound track.
  34922. * @param newVolume Define the new volume of the sound track
  34923. */
  34924. setVolume(newVolume: number): void;
  34925. /**
  34926. * Switch the panning model to HRTF:
  34927. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34929. */
  34930. switchPanningModelToHRTF(): void;
  34931. /**
  34932. * Switch the panning model to Equal Power:
  34933. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34935. */
  34936. switchPanningModelToEqualPower(): void;
  34937. /**
  34938. * Connect the sound track to an audio analyser allowing some amazing
  34939. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34941. * @param analyser The analyser to connect to the engine
  34942. */
  34943. connectToAnalyser(analyser: Analyser): void;
  34944. }
  34945. }
  34946. declare module "babylonjs/Audio/audioSceneComponent" {
  34947. import { Sound } from "babylonjs/Audio/sound";
  34948. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34949. import { Nullable } from "babylonjs/types";
  34950. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34951. import { Scene } from "babylonjs/scene";
  34952. import { AbstractScene } from "babylonjs/abstractScene";
  34953. module "babylonjs/abstractScene" {
  34954. interface AbstractScene {
  34955. /**
  34956. * The list of sounds used in the scene.
  34957. */
  34958. sounds: Nullable<Array<Sound>>;
  34959. }
  34960. }
  34961. module "babylonjs/scene" {
  34962. interface Scene {
  34963. /**
  34964. * @hidden
  34965. * Backing field
  34966. */
  34967. _mainSoundTrack: SoundTrack;
  34968. /**
  34969. * The main sound track played by the scene.
  34970. * It cotains your primary collection of sounds.
  34971. */
  34972. mainSoundTrack: SoundTrack;
  34973. /**
  34974. * The list of sound tracks added to the scene
  34975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34976. */
  34977. soundTracks: Nullable<Array<SoundTrack>>;
  34978. /**
  34979. * Gets a sound using a given name
  34980. * @param name defines the name to search for
  34981. * @return the found sound or null if not found at all.
  34982. */
  34983. getSoundByName(name: string): Nullable<Sound>;
  34984. /**
  34985. * Gets or sets if audio support is enabled
  34986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34987. */
  34988. audioEnabled: boolean;
  34989. /**
  34990. * Gets or sets if audio will be output to headphones
  34991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34992. */
  34993. headphone: boolean;
  34994. }
  34995. }
  34996. /**
  34997. * Defines the sound scene component responsible to manage any sounds
  34998. * in a given scene.
  34999. */
  35000. export class AudioSceneComponent implements ISceneSerializableComponent {
  35001. /**
  35002. * The component name helpfull to identify the component in the list of scene components.
  35003. */
  35004. readonly name: string;
  35005. /**
  35006. * The scene the component belongs to.
  35007. */
  35008. scene: Scene;
  35009. private _audioEnabled;
  35010. /**
  35011. * Gets whether audio is enabled or not.
  35012. * Please use related enable/disable method to switch state.
  35013. */
  35014. readonly audioEnabled: boolean;
  35015. private _headphone;
  35016. /**
  35017. * Gets whether audio is outputing to headphone or not.
  35018. * Please use the according Switch methods to change output.
  35019. */
  35020. readonly headphone: boolean;
  35021. /**
  35022. * Creates a new instance of the component for the given scene
  35023. * @param scene Defines the scene to register the component in
  35024. */
  35025. constructor(scene: Scene);
  35026. /**
  35027. * Registers the component in a given scene
  35028. */
  35029. register(): void;
  35030. /**
  35031. * Rebuilds the elements related to this component in case of
  35032. * context lost for instance.
  35033. */
  35034. rebuild(): void;
  35035. /**
  35036. * Serializes the component data to the specified json object
  35037. * @param serializationObject The object to serialize to
  35038. */
  35039. serialize(serializationObject: any): void;
  35040. /**
  35041. * Adds all the element from the container to the scene
  35042. * @param container the container holding the elements
  35043. */
  35044. addFromContainer(container: AbstractScene): void;
  35045. /**
  35046. * Removes all the elements in the container from the scene
  35047. * @param container contains the elements to remove
  35048. * @param dispose if the removed element should be disposed (default: false)
  35049. */
  35050. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35051. /**
  35052. * Disposes the component and the associated ressources.
  35053. */
  35054. dispose(): void;
  35055. /**
  35056. * Disables audio in the associated scene.
  35057. */
  35058. disableAudio(): void;
  35059. /**
  35060. * Enables audio in the associated scene.
  35061. */
  35062. enableAudio(): void;
  35063. /**
  35064. * Switch audio to headphone output.
  35065. */
  35066. switchAudioModeForHeadphones(): void;
  35067. /**
  35068. * Switch audio to normal speakers.
  35069. */
  35070. switchAudioModeForNormalSpeakers(): void;
  35071. private _afterRender;
  35072. }
  35073. }
  35074. declare module "babylonjs/Audio/weightedsound" {
  35075. import { Sound } from "babylonjs/Audio/sound";
  35076. /**
  35077. * Wraps one or more Sound objects and selects one with random weight for playback.
  35078. */
  35079. export class WeightedSound {
  35080. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35081. loop: boolean;
  35082. private _coneInnerAngle;
  35083. private _coneOuterAngle;
  35084. private _volume;
  35085. /** A Sound is currently playing. */
  35086. isPlaying: boolean;
  35087. /** A Sound is currently paused. */
  35088. isPaused: boolean;
  35089. private _sounds;
  35090. private _weights;
  35091. private _currentIndex?;
  35092. /**
  35093. * Creates a new WeightedSound from the list of sounds given.
  35094. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35095. * @param sounds Array of Sounds that will be selected from.
  35096. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35097. */
  35098. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35099. /**
  35100. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35101. */
  35102. /**
  35103. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35104. */
  35105. directionalConeInnerAngle: number;
  35106. /**
  35107. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35108. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35109. */
  35110. /**
  35111. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35112. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35113. */
  35114. directionalConeOuterAngle: number;
  35115. /**
  35116. * Playback volume.
  35117. */
  35118. /**
  35119. * Playback volume.
  35120. */
  35121. volume: number;
  35122. private _onended;
  35123. /**
  35124. * Suspend playback
  35125. */
  35126. pause(): void;
  35127. /**
  35128. * Stop playback
  35129. */
  35130. stop(): void;
  35131. /**
  35132. * Start playback.
  35133. * @param startOffset Position the clip head at a specific time in seconds.
  35134. */
  35135. play(startOffset?: number): void;
  35136. }
  35137. }
  35138. declare module "babylonjs/Audio/index" {
  35139. export * from "babylonjs/Audio/analyser";
  35140. export * from "babylonjs/Audio/audioEngine";
  35141. export * from "babylonjs/Audio/audioSceneComponent";
  35142. export * from "babylonjs/Audio/sound";
  35143. export * from "babylonjs/Audio/soundTrack";
  35144. export * from "babylonjs/Audio/weightedsound";
  35145. }
  35146. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35147. import { Behavior } from "babylonjs/Behaviors/behavior";
  35148. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35149. import { BackEase } from "babylonjs/Animations/easing";
  35150. /**
  35151. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35152. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35153. */
  35154. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35155. /**
  35156. * Gets the name of the behavior.
  35157. */
  35158. readonly name: string;
  35159. /**
  35160. * The easing function used by animations
  35161. */
  35162. static EasingFunction: BackEase;
  35163. /**
  35164. * The easing mode used by animations
  35165. */
  35166. static EasingMode: number;
  35167. /**
  35168. * The duration of the animation, in milliseconds
  35169. */
  35170. transitionDuration: number;
  35171. /**
  35172. * Length of the distance animated by the transition when lower radius is reached
  35173. */
  35174. lowerRadiusTransitionRange: number;
  35175. /**
  35176. * Length of the distance animated by the transition when upper radius is reached
  35177. */
  35178. upperRadiusTransitionRange: number;
  35179. private _autoTransitionRange;
  35180. /**
  35181. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35182. */
  35183. /**
  35184. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35185. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35186. */
  35187. autoTransitionRange: boolean;
  35188. private _attachedCamera;
  35189. private _onAfterCheckInputsObserver;
  35190. private _onMeshTargetChangedObserver;
  35191. /**
  35192. * Initializes the behavior.
  35193. */
  35194. init(): void;
  35195. /**
  35196. * Attaches the behavior to its arc rotate camera.
  35197. * @param camera Defines the camera to attach the behavior to
  35198. */
  35199. attach(camera: ArcRotateCamera): void;
  35200. /**
  35201. * Detaches the behavior from its current arc rotate camera.
  35202. */
  35203. detach(): void;
  35204. private _radiusIsAnimating;
  35205. private _radiusBounceTransition;
  35206. private _animatables;
  35207. private _cachedWheelPrecision;
  35208. /**
  35209. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35210. * @param radiusLimit The limit to check against.
  35211. * @return Bool to indicate if at limit.
  35212. */
  35213. private _isRadiusAtLimit;
  35214. /**
  35215. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35216. * @param radiusDelta The delta by which to animate to. Can be negative.
  35217. */
  35218. private _applyBoundRadiusAnimation;
  35219. /**
  35220. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35221. */
  35222. protected _clearAnimationLocks(): void;
  35223. /**
  35224. * Stops and removes all animations that have been applied to the camera
  35225. */
  35226. stopAllAnimations(): void;
  35227. }
  35228. }
  35229. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35230. import { Behavior } from "babylonjs/Behaviors/behavior";
  35231. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35232. import { ExponentialEase } from "babylonjs/Animations/easing";
  35233. import { Nullable } from "babylonjs/types";
  35234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35235. import { Vector3 } from "babylonjs/Maths/math";
  35236. /**
  35237. * 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.
  35238. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35239. */
  35240. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35241. /**
  35242. * Gets the name of the behavior.
  35243. */
  35244. readonly name: string;
  35245. private _mode;
  35246. private _radiusScale;
  35247. private _positionScale;
  35248. private _defaultElevation;
  35249. private _elevationReturnTime;
  35250. private _elevationReturnWaitTime;
  35251. private _zoomStopsAnimation;
  35252. private _framingTime;
  35253. /**
  35254. * The easing function used by animations
  35255. */
  35256. static EasingFunction: ExponentialEase;
  35257. /**
  35258. * The easing mode used by animations
  35259. */
  35260. static EasingMode: number;
  35261. /**
  35262. * Sets the current mode used by the behavior
  35263. */
  35264. /**
  35265. * Gets current mode used by the behavior.
  35266. */
  35267. mode: number;
  35268. /**
  35269. * Sets the scale applied to the radius (1 by default)
  35270. */
  35271. /**
  35272. * Gets the scale applied to the radius
  35273. */
  35274. radiusScale: number;
  35275. /**
  35276. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35277. */
  35278. /**
  35279. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35280. */
  35281. positionScale: number;
  35282. /**
  35283. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35284. * behaviour is triggered, in radians.
  35285. */
  35286. /**
  35287. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35288. * behaviour is triggered, in radians.
  35289. */
  35290. defaultElevation: number;
  35291. /**
  35292. * Sets the time (in milliseconds) taken to return to the default beta position.
  35293. * Negative value indicates camera should not return to default.
  35294. */
  35295. /**
  35296. * Gets the time (in milliseconds) taken to return to the default beta position.
  35297. * Negative value indicates camera should not return to default.
  35298. */
  35299. elevationReturnTime: number;
  35300. /**
  35301. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35302. */
  35303. /**
  35304. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35305. */
  35306. elevationReturnWaitTime: number;
  35307. /**
  35308. * Sets the flag that indicates if user zooming should stop animation.
  35309. */
  35310. /**
  35311. * Gets the flag that indicates if user zooming should stop animation.
  35312. */
  35313. zoomStopsAnimation: boolean;
  35314. /**
  35315. * Sets the transition time when framing the mesh, in milliseconds
  35316. */
  35317. /**
  35318. * Gets the transition time when framing the mesh, in milliseconds
  35319. */
  35320. framingTime: number;
  35321. /**
  35322. * Define if the behavior should automatically change the configured
  35323. * camera limits and sensibilities.
  35324. */
  35325. autoCorrectCameraLimitsAndSensibility: boolean;
  35326. private _onPrePointerObservableObserver;
  35327. private _onAfterCheckInputsObserver;
  35328. private _onMeshTargetChangedObserver;
  35329. private _attachedCamera;
  35330. private _isPointerDown;
  35331. private _lastInteractionTime;
  35332. /**
  35333. * Initializes the behavior.
  35334. */
  35335. init(): void;
  35336. /**
  35337. * Attaches the behavior to its arc rotate camera.
  35338. * @param camera Defines the camera to attach the behavior to
  35339. */
  35340. attach(camera: ArcRotateCamera): void;
  35341. /**
  35342. * Detaches the behavior from its current arc rotate camera.
  35343. */
  35344. detach(): void;
  35345. private _animatables;
  35346. private _betaIsAnimating;
  35347. private _betaTransition;
  35348. private _radiusTransition;
  35349. private _vectorTransition;
  35350. /**
  35351. * Targets the given mesh and updates zoom level accordingly.
  35352. * @param mesh The mesh to target.
  35353. * @param radius Optional. If a cached radius position already exists, overrides default.
  35354. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35355. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35356. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35357. */
  35358. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35359. /**
  35360. * Targets the given mesh with its children and updates zoom level accordingly.
  35361. * @param mesh The mesh to target.
  35362. * @param radius Optional. If a cached radius position already exists, overrides default.
  35363. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35364. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35365. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35366. */
  35367. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35368. /**
  35369. * Targets the given meshes with their children and updates zoom level accordingly.
  35370. * @param meshes The mesh to target.
  35371. * @param radius Optional. If a cached radius position already exists, overrides default.
  35372. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35373. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35374. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35375. */
  35376. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35377. /**
  35378. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35379. * @param minimumWorld Determines the smaller position of the bounding box extend
  35380. * @param maximumWorld Determines the bigger position of the bounding box extend
  35381. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35382. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35383. */
  35384. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35385. /**
  35386. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35387. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35388. * frustum width.
  35389. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35390. * to fully enclose the mesh in the viewing frustum.
  35391. */
  35392. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35393. /**
  35394. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35395. * is automatically returned to its default position (expected to be above ground plane).
  35396. */
  35397. private _maintainCameraAboveGround;
  35398. /**
  35399. * Returns the frustum slope based on the canvas ratio and camera FOV
  35400. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35401. */
  35402. private _getFrustumSlope;
  35403. /**
  35404. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35405. */
  35406. private _clearAnimationLocks;
  35407. /**
  35408. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35409. */
  35410. private _applyUserInteraction;
  35411. /**
  35412. * Stops and removes all animations that have been applied to the camera
  35413. */
  35414. stopAllAnimations(): void;
  35415. /**
  35416. * Gets a value indicating if the user is moving the camera
  35417. */
  35418. readonly isUserIsMoving: boolean;
  35419. /**
  35420. * The camera can move all the way towards the mesh.
  35421. */
  35422. static IgnoreBoundsSizeMode: number;
  35423. /**
  35424. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35425. */
  35426. static FitFrustumSidesMode: number;
  35427. }
  35428. }
  35429. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35430. import { Nullable } from "babylonjs/types";
  35431. import { Camera } from "babylonjs/Cameras/camera";
  35432. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35433. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35434. /**
  35435. * Base class for Camera Pointer Inputs.
  35436. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35437. * for example usage.
  35438. */
  35439. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35440. /**
  35441. * Defines the camera the input is attached to.
  35442. */
  35443. abstract camera: Camera;
  35444. /**
  35445. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35446. */
  35447. protected _altKey: boolean;
  35448. protected _ctrlKey: boolean;
  35449. protected _metaKey: boolean;
  35450. protected _shiftKey: boolean;
  35451. /**
  35452. * Which mouse buttons were pressed at time of last mouse event.
  35453. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35454. */
  35455. protected _buttonsPressed: number;
  35456. /**
  35457. * Defines the buttons associated with the input to handle camera move.
  35458. */
  35459. buttons: number[];
  35460. /**
  35461. * Attach the input controls to a specific dom element to get the input from.
  35462. * @param element Defines the element the controls should be listened from
  35463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35464. */
  35465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35466. /**
  35467. * Detach the current controls from the specified dom element.
  35468. * @param element Defines the element to stop listening the inputs from
  35469. */
  35470. detachControl(element: Nullable<HTMLElement>): void;
  35471. /**
  35472. * Gets the class name of the current input.
  35473. * @returns the class name
  35474. */
  35475. getClassName(): string;
  35476. /**
  35477. * Get the friendly name associated with the input class.
  35478. * @returns the input friendly name
  35479. */
  35480. getSimpleName(): string;
  35481. /**
  35482. * Called on pointer POINTERDOUBLETAP event.
  35483. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35484. */
  35485. protected onDoubleTap(type: string): void;
  35486. /**
  35487. * Called on pointer POINTERMOVE event if only a single touch is active.
  35488. * Override this method to provide functionality.
  35489. */
  35490. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35491. /**
  35492. * Called on pointer POINTERMOVE event if multiple touches are active.
  35493. * Override this method to provide functionality.
  35494. */
  35495. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35496. /**
  35497. * Called on JS contextmenu event.
  35498. * Override this method to provide functionality.
  35499. */
  35500. protected onContextMenu(evt: PointerEvent): void;
  35501. /**
  35502. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35503. * press.
  35504. * Override this method to provide functionality.
  35505. */
  35506. protected onButtonDown(evt: PointerEvent): void;
  35507. /**
  35508. * Called each time a new POINTERUP event occurs. Ie, for each button
  35509. * release.
  35510. * Override this method to provide functionality.
  35511. */
  35512. protected onButtonUp(evt: PointerEvent): void;
  35513. /**
  35514. * Called when window becomes inactive.
  35515. * Override this method to provide functionality.
  35516. */
  35517. protected onLostFocus(): void;
  35518. private _pointerInput;
  35519. private _observer;
  35520. private _onLostFocus;
  35521. private pointA;
  35522. private pointB;
  35523. }
  35524. }
  35525. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35526. import { Nullable } from "babylonjs/types";
  35527. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35528. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35529. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35530. /**
  35531. * Manage the pointers inputs to control an arc rotate camera.
  35532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35533. */
  35534. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35535. /**
  35536. * Defines the camera the input is attached to.
  35537. */
  35538. camera: ArcRotateCamera;
  35539. /**
  35540. * Gets the class name of the current input.
  35541. * @returns the class name
  35542. */
  35543. getClassName(): string;
  35544. /**
  35545. * Defines the buttons associated with the input to handle camera move.
  35546. */
  35547. buttons: number[];
  35548. /**
  35549. * Defines the pointer angular sensibility along the X axis or how fast is
  35550. * the camera rotating.
  35551. */
  35552. angularSensibilityX: number;
  35553. /**
  35554. * Defines the pointer angular sensibility along the Y axis or how fast is
  35555. * the camera rotating.
  35556. */
  35557. angularSensibilityY: number;
  35558. /**
  35559. * Defines the pointer pinch precision or how fast is the camera zooming.
  35560. */
  35561. pinchPrecision: number;
  35562. /**
  35563. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35564. * from 0.
  35565. * It defines the percentage of current camera.radius to use as delta when
  35566. * pinch zoom is used.
  35567. */
  35568. pinchDeltaPercentage: number;
  35569. /**
  35570. * Defines the pointer panning sensibility or how fast is the camera moving.
  35571. */
  35572. panningSensibility: number;
  35573. /**
  35574. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35575. */
  35576. multiTouchPanning: boolean;
  35577. /**
  35578. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35579. * zoom (pinch) through multitouch.
  35580. */
  35581. multiTouchPanAndZoom: boolean;
  35582. /**
  35583. * Revers pinch action direction.
  35584. */
  35585. pinchInwards: boolean;
  35586. private _isPanClick;
  35587. private _twoFingerActivityCount;
  35588. private _isPinching;
  35589. /**
  35590. * Called on pointer POINTERMOVE event if only a single touch is active.
  35591. */
  35592. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35593. /**
  35594. * Called on pointer POINTERDOUBLETAP event.
  35595. */
  35596. protected onDoubleTap(type: string): void;
  35597. /**
  35598. * Called on pointer POINTERMOVE event if multiple touches are active.
  35599. */
  35600. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35601. /**
  35602. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35603. * press.
  35604. */
  35605. protected onButtonDown(evt: PointerEvent): void;
  35606. /**
  35607. * Called each time a new POINTERUP event occurs. Ie, for each button
  35608. * release.
  35609. */
  35610. protected onButtonUp(evt: PointerEvent): void;
  35611. /**
  35612. * Called when window becomes inactive.
  35613. */
  35614. protected onLostFocus(): void;
  35615. }
  35616. }
  35617. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35618. import { Nullable } from "babylonjs/types";
  35619. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35620. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35621. /**
  35622. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35624. */
  35625. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35626. /**
  35627. * Defines the camera the input is attached to.
  35628. */
  35629. camera: ArcRotateCamera;
  35630. /**
  35631. * Defines the list of key codes associated with the up action (increase alpha)
  35632. */
  35633. keysUp: number[];
  35634. /**
  35635. * Defines the list of key codes associated with the down action (decrease alpha)
  35636. */
  35637. keysDown: number[];
  35638. /**
  35639. * Defines the list of key codes associated with the left action (increase beta)
  35640. */
  35641. keysLeft: number[];
  35642. /**
  35643. * Defines the list of key codes associated with the right action (decrease beta)
  35644. */
  35645. keysRight: number[];
  35646. /**
  35647. * Defines the list of key codes associated with the reset action.
  35648. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35649. */
  35650. keysReset: number[];
  35651. /**
  35652. * Defines the panning sensibility of the inputs.
  35653. * (How fast is the camera paning)
  35654. */
  35655. panningSensibility: number;
  35656. /**
  35657. * Defines the zooming sensibility of the inputs.
  35658. * (How fast is the camera zooming)
  35659. */
  35660. zoomingSensibility: number;
  35661. /**
  35662. * Defines wether maintaining the alt key down switch the movement mode from
  35663. * orientation to zoom.
  35664. */
  35665. useAltToZoom: boolean;
  35666. /**
  35667. * Rotation speed of the camera
  35668. */
  35669. angularSpeed: number;
  35670. private _keys;
  35671. private _ctrlPressed;
  35672. private _altPressed;
  35673. private _onCanvasBlurObserver;
  35674. private _onKeyboardObserver;
  35675. private _engine;
  35676. private _scene;
  35677. /**
  35678. * Attach the input controls to a specific dom element to get the input from.
  35679. * @param element Defines the element the controls should be listened from
  35680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35681. */
  35682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35683. /**
  35684. * Detach the current controls from the specified dom element.
  35685. * @param element Defines the element to stop listening the inputs from
  35686. */
  35687. detachControl(element: Nullable<HTMLElement>): void;
  35688. /**
  35689. * Update the current camera state depending on the inputs that have been used this frame.
  35690. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35691. */
  35692. checkInputs(): void;
  35693. /**
  35694. * Gets the class name of the current intput.
  35695. * @returns the class name
  35696. */
  35697. getClassName(): string;
  35698. /**
  35699. * Get the friendly name associated with the input class.
  35700. * @returns the input friendly name
  35701. */
  35702. getSimpleName(): string;
  35703. }
  35704. }
  35705. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35706. import { Nullable } from "babylonjs/types";
  35707. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35708. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35709. /**
  35710. * Manage the mouse wheel inputs to control an arc rotate camera.
  35711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35712. */
  35713. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35714. /**
  35715. * Defines the camera the input is attached to.
  35716. */
  35717. camera: ArcRotateCamera;
  35718. /**
  35719. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35720. */
  35721. wheelPrecision: number;
  35722. /**
  35723. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35724. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35725. */
  35726. wheelDeltaPercentage: number;
  35727. private _wheel;
  35728. private _observer;
  35729. /**
  35730. * Attach the input controls to a specific dom element to get the input from.
  35731. * @param element Defines the element the controls should be listened from
  35732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35733. */
  35734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35735. /**
  35736. * Detach the current controls from the specified dom element.
  35737. * @param element Defines the element to stop listening the inputs from
  35738. */
  35739. detachControl(element: Nullable<HTMLElement>): void;
  35740. /**
  35741. * Gets the class name of the current intput.
  35742. * @returns the class name
  35743. */
  35744. getClassName(): string;
  35745. /**
  35746. * Get the friendly name associated with the input class.
  35747. * @returns the input friendly name
  35748. */
  35749. getSimpleName(): string;
  35750. }
  35751. }
  35752. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35753. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35754. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35755. /**
  35756. * Default Inputs manager for the ArcRotateCamera.
  35757. * It groups all the default supported inputs for ease of use.
  35758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35759. */
  35760. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35761. /**
  35762. * Instantiates a new ArcRotateCameraInputsManager.
  35763. * @param camera Defines the camera the inputs belong to
  35764. */
  35765. constructor(camera: ArcRotateCamera);
  35766. /**
  35767. * Add mouse wheel input support to the input manager.
  35768. * @returns the current input manager
  35769. */
  35770. addMouseWheel(): ArcRotateCameraInputsManager;
  35771. /**
  35772. * Add pointers input support to the input manager.
  35773. * @returns the current input manager
  35774. */
  35775. addPointers(): ArcRotateCameraInputsManager;
  35776. /**
  35777. * Add keyboard input support to the input manager.
  35778. * @returns the current input manager
  35779. */
  35780. addKeyboard(): ArcRotateCameraInputsManager;
  35781. }
  35782. }
  35783. declare module "babylonjs/Cameras/arcRotateCamera" {
  35784. import { Observable } from "babylonjs/Misc/observable";
  35785. import { Nullable } from "babylonjs/types";
  35786. import { Scene } from "babylonjs/scene";
  35787. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35789. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35790. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35791. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35792. import { Camera } from "babylonjs/Cameras/camera";
  35793. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35794. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35795. import { Collider } from "babylonjs/Collisions/collider";
  35796. /**
  35797. * This represents an orbital type of camera.
  35798. *
  35799. * 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.
  35800. * 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.
  35801. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35802. */
  35803. export class ArcRotateCamera extends TargetCamera {
  35804. /**
  35805. * Defines the rotation angle of the camera along the longitudinal axis.
  35806. */
  35807. alpha: number;
  35808. /**
  35809. * Defines the rotation angle of the camera along the latitudinal axis.
  35810. */
  35811. beta: number;
  35812. /**
  35813. * Defines the radius of the camera from it s target point.
  35814. */
  35815. radius: number;
  35816. protected _target: Vector3;
  35817. protected _targetHost: Nullable<AbstractMesh>;
  35818. /**
  35819. * Defines the target point of the camera.
  35820. * The camera looks towards it form the radius distance.
  35821. */
  35822. target: Vector3;
  35823. /**
  35824. * Define the current local position of the camera in the scene
  35825. */
  35826. position: Vector3;
  35827. /**
  35828. * Current inertia value on the longitudinal axis.
  35829. * The bigger this number the longer it will take for the camera to stop.
  35830. */
  35831. inertialAlphaOffset: number;
  35832. /**
  35833. * Current inertia value on the latitudinal axis.
  35834. * The bigger this number the longer it will take for the camera to stop.
  35835. */
  35836. inertialBetaOffset: number;
  35837. /**
  35838. * Current inertia value on the radius axis.
  35839. * The bigger this number the longer it will take for the camera to stop.
  35840. */
  35841. inertialRadiusOffset: number;
  35842. /**
  35843. * Minimum allowed angle on the longitudinal axis.
  35844. * This can help limiting how the Camera is able to move in the scene.
  35845. */
  35846. lowerAlphaLimit: Nullable<number>;
  35847. /**
  35848. * Maximum allowed angle on the longitudinal axis.
  35849. * This can help limiting how the Camera is able to move in the scene.
  35850. */
  35851. upperAlphaLimit: Nullable<number>;
  35852. /**
  35853. * Minimum allowed angle on the latitudinal axis.
  35854. * This can help limiting how the Camera is able to move in the scene.
  35855. */
  35856. lowerBetaLimit: number;
  35857. /**
  35858. * Maximum allowed angle on the latitudinal axis.
  35859. * This can help limiting how the Camera is able to move in the scene.
  35860. */
  35861. upperBetaLimit: number;
  35862. /**
  35863. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35864. * This can help limiting how the Camera is able to move in the scene.
  35865. */
  35866. lowerRadiusLimit: Nullable<number>;
  35867. /**
  35868. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35869. * This can help limiting how the Camera is able to move in the scene.
  35870. */
  35871. upperRadiusLimit: Nullable<number>;
  35872. /**
  35873. * Defines the current inertia value used during panning of the camera along the X axis.
  35874. */
  35875. inertialPanningX: number;
  35876. /**
  35877. * Defines the current inertia value used during panning of the camera along the Y axis.
  35878. */
  35879. inertialPanningY: number;
  35880. /**
  35881. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35882. * Basically if your fingers moves away from more than this distance you will be considered
  35883. * in pinch mode.
  35884. */
  35885. pinchToPanMaxDistance: number;
  35886. /**
  35887. * Defines the maximum distance the camera can pan.
  35888. * This could help keeping the cammera always in your scene.
  35889. */
  35890. panningDistanceLimit: Nullable<number>;
  35891. /**
  35892. * Defines the target of the camera before paning.
  35893. */
  35894. panningOriginTarget: Vector3;
  35895. /**
  35896. * Defines the value of the inertia used during panning.
  35897. * 0 would mean stop inertia and one would mean no decelleration at all.
  35898. */
  35899. panningInertia: number;
  35900. /**
  35901. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35902. */
  35903. angularSensibilityX: number;
  35904. /**
  35905. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35906. */
  35907. angularSensibilityY: number;
  35908. /**
  35909. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35910. */
  35911. pinchPrecision: number;
  35912. /**
  35913. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35914. * It will be used instead of pinchDeltaPrecision if different from 0.
  35915. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35916. */
  35917. pinchDeltaPercentage: number;
  35918. /**
  35919. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35920. */
  35921. panningSensibility: number;
  35922. /**
  35923. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35924. */
  35925. keysUp: number[];
  35926. /**
  35927. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35928. */
  35929. keysDown: number[];
  35930. /**
  35931. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35932. */
  35933. keysLeft: number[];
  35934. /**
  35935. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35936. */
  35937. keysRight: number[];
  35938. /**
  35939. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35940. */
  35941. wheelPrecision: number;
  35942. /**
  35943. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35944. * It will be used instead of pinchDeltaPrecision if different from 0.
  35945. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35946. */
  35947. wheelDeltaPercentage: number;
  35948. /**
  35949. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35950. */
  35951. zoomOnFactor: number;
  35952. /**
  35953. * Defines a screen offset for the camera position.
  35954. */
  35955. targetScreenOffset: Vector2;
  35956. /**
  35957. * Allows the camera to be completely reversed.
  35958. * If false the camera can not arrive upside down.
  35959. */
  35960. allowUpsideDown: boolean;
  35961. /**
  35962. * Define if double tap/click is used to restore the previously saved state of the camera.
  35963. */
  35964. useInputToRestoreState: boolean;
  35965. /** @hidden */
  35966. _viewMatrix: Matrix;
  35967. /** @hidden */
  35968. _useCtrlForPanning: boolean;
  35969. /** @hidden */
  35970. _panningMouseButton: number;
  35971. /**
  35972. * Defines the input associated to the camera.
  35973. */
  35974. inputs: ArcRotateCameraInputsManager;
  35975. /** @hidden */
  35976. _reset: () => void;
  35977. /**
  35978. * Defines the allowed panning axis.
  35979. */
  35980. panningAxis: Vector3;
  35981. protected _localDirection: Vector3;
  35982. protected _transformedDirection: Vector3;
  35983. private _bouncingBehavior;
  35984. /**
  35985. * Gets the bouncing behavior of the camera if it has been enabled.
  35986. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35987. */
  35988. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35989. /**
  35990. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35991. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35992. */
  35993. useBouncingBehavior: boolean;
  35994. private _framingBehavior;
  35995. /**
  35996. * Gets the framing behavior of the camera if it has been enabled.
  35997. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35998. */
  35999. readonly framingBehavior: Nullable<FramingBehavior>;
  36000. /**
  36001. * Defines if the framing behavior of the camera is enabled on the camera.
  36002. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36003. */
  36004. useFramingBehavior: boolean;
  36005. private _autoRotationBehavior;
  36006. /**
  36007. * Gets the auto rotation behavior of the camera if it has been enabled.
  36008. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36009. */
  36010. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36011. /**
  36012. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36013. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36014. */
  36015. useAutoRotationBehavior: boolean;
  36016. /**
  36017. * Observable triggered when the mesh target has been changed on the camera.
  36018. */
  36019. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36020. /**
  36021. * Event raised when the camera is colliding with a mesh.
  36022. */
  36023. onCollide: (collidedMesh: AbstractMesh) => void;
  36024. /**
  36025. * Defines whether the camera should check collision with the objects oh the scene.
  36026. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36027. */
  36028. checkCollisions: boolean;
  36029. /**
  36030. * Defines the collision radius of the camera.
  36031. * This simulates a sphere around the camera.
  36032. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36033. */
  36034. collisionRadius: Vector3;
  36035. protected _collider: Collider;
  36036. protected _previousPosition: Vector3;
  36037. protected _collisionVelocity: Vector3;
  36038. protected _newPosition: Vector3;
  36039. protected _previousAlpha: number;
  36040. protected _previousBeta: number;
  36041. protected _previousRadius: number;
  36042. protected _collisionTriggered: boolean;
  36043. protected _targetBoundingCenter: Nullable<Vector3>;
  36044. private _computationVector;
  36045. private _tempAxisVector;
  36046. private _tempAxisRotationMatrix;
  36047. /**
  36048. * Instantiates a new ArcRotateCamera in a given scene
  36049. * @param name Defines the name of the camera
  36050. * @param alpha Defines the camera rotation along the logitudinal axis
  36051. * @param beta Defines the camera rotation along the latitudinal axis
  36052. * @param radius Defines the camera distance from its target
  36053. * @param target Defines the camera target
  36054. * @param scene Defines the scene the camera belongs to
  36055. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36056. */
  36057. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36058. /** @hidden */
  36059. _initCache(): void;
  36060. /** @hidden */
  36061. _updateCache(ignoreParentClass?: boolean): void;
  36062. protected _getTargetPosition(): Vector3;
  36063. private _storedAlpha;
  36064. private _storedBeta;
  36065. private _storedRadius;
  36066. private _storedTarget;
  36067. /**
  36068. * Stores the current state of the camera (alpha, beta, radius and target)
  36069. * @returns the camera itself
  36070. */
  36071. storeState(): Camera;
  36072. /**
  36073. * @hidden
  36074. * Restored camera state. You must call storeState() first
  36075. */
  36076. _restoreStateValues(): boolean;
  36077. /** @hidden */
  36078. _isSynchronizedViewMatrix(): boolean;
  36079. /**
  36080. * Attached controls to the current camera.
  36081. * @param element Defines the element the controls should be listened from
  36082. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36083. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36084. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36085. */
  36086. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36087. /**
  36088. * Detach the current controls from the camera.
  36089. * The camera will stop reacting to inputs.
  36090. * @param element Defines the element to stop listening the inputs from
  36091. */
  36092. detachControl(element: HTMLElement): void;
  36093. /** @hidden */
  36094. _checkInputs(): void;
  36095. protected _checkLimits(): void;
  36096. /**
  36097. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36098. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  36099. */
  36100. rebuildAnglesAndRadius(updateView?: boolean): void;
  36101. /**
  36102. * Use a position to define the current camera related information like aplha, beta and radius
  36103. * @param position Defines the position to set the camera at
  36104. */
  36105. setPosition(position: Vector3): void;
  36106. /**
  36107. * Defines the target the camera should look at.
  36108. * This will automatically adapt alpha beta and radius to fit within the new target.
  36109. * @param target Defines the new target as a Vector or a mesh
  36110. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36111. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36112. */
  36113. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36114. /** @hidden */
  36115. _getViewMatrix(): Matrix;
  36116. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36117. /**
  36118. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36119. * @param meshes Defines the mesh to zoom on
  36120. * @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)
  36121. */
  36122. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36123. /**
  36124. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36125. * The target will be changed but the radius
  36126. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36127. * @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)
  36128. */
  36129. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36130. min: Vector3;
  36131. max: Vector3;
  36132. distance: number;
  36133. }, doNotUpdateMaxZ?: boolean): void;
  36134. /**
  36135. * @override
  36136. * Override Camera.createRigCamera
  36137. */
  36138. createRigCamera(name: string, cameraIndex: number): Camera;
  36139. /**
  36140. * @hidden
  36141. * @override
  36142. * Override Camera._updateRigCameras
  36143. */
  36144. _updateRigCameras(): void;
  36145. /**
  36146. * Destroy the camera and release the current resources hold by it.
  36147. */
  36148. dispose(): void;
  36149. /**
  36150. * Gets the current object class name.
  36151. * @return the class name
  36152. */
  36153. getClassName(): string;
  36154. }
  36155. }
  36156. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36157. import { Behavior } from "babylonjs/Behaviors/behavior";
  36158. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36159. /**
  36160. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36161. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36162. */
  36163. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36164. /**
  36165. * Gets the name of the behavior.
  36166. */
  36167. readonly name: string;
  36168. private _zoomStopsAnimation;
  36169. private _idleRotationSpeed;
  36170. private _idleRotationWaitTime;
  36171. private _idleRotationSpinupTime;
  36172. /**
  36173. * Sets the flag that indicates if user zooming should stop animation.
  36174. */
  36175. /**
  36176. * Gets the flag that indicates if user zooming should stop animation.
  36177. */
  36178. zoomStopsAnimation: boolean;
  36179. /**
  36180. * Sets the default speed at which the camera rotates around the model.
  36181. */
  36182. /**
  36183. * Gets the default speed at which the camera rotates around the model.
  36184. */
  36185. idleRotationSpeed: number;
  36186. /**
  36187. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36188. */
  36189. /**
  36190. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36191. */
  36192. idleRotationWaitTime: number;
  36193. /**
  36194. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36195. */
  36196. /**
  36197. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36198. */
  36199. idleRotationSpinupTime: number;
  36200. /**
  36201. * Gets a value indicating if the camera is currently rotating because of this behavior
  36202. */
  36203. readonly rotationInProgress: boolean;
  36204. private _onPrePointerObservableObserver;
  36205. private _onAfterCheckInputsObserver;
  36206. private _attachedCamera;
  36207. private _isPointerDown;
  36208. private _lastFrameTime;
  36209. private _lastInteractionTime;
  36210. private _cameraRotationSpeed;
  36211. /**
  36212. * Initializes the behavior.
  36213. */
  36214. init(): void;
  36215. /**
  36216. * Attaches the behavior to its arc rotate camera.
  36217. * @param camera Defines the camera to attach the behavior to
  36218. */
  36219. attach(camera: ArcRotateCamera): void;
  36220. /**
  36221. * Detaches the behavior from its current arc rotate camera.
  36222. */
  36223. detach(): void;
  36224. /**
  36225. * Returns true if user is scrolling.
  36226. * @return true if user is scrolling.
  36227. */
  36228. private _userIsZooming;
  36229. private _lastFrameRadius;
  36230. private _shouldAnimationStopForInteraction;
  36231. /**
  36232. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36233. */
  36234. private _applyUserInteraction;
  36235. private _userIsMoving;
  36236. }
  36237. }
  36238. declare module "babylonjs/Behaviors/Cameras/index" {
  36239. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36240. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36241. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36242. }
  36243. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36244. import { Mesh } from "babylonjs/Meshes/mesh";
  36245. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36246. import { Behavior } from "babylonjs/Behaviors/behavior";
  36247. /**
  36248. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36249. */
  36250. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36251. private ui;
  36252. /**
  36253. * The name of the behavior
  36254. */
  36255. name: string;
  36256. /**
  36257. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36258. */
  36259. distanceAwayFromFace: number;
  36260. /**
  36261. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36262. */
  36263. distanceAwayFromBottomOfFace: number;
  36264. private _faceVectors;
  36265. private _target;
  36266. private _scene;
  36267. private _onRenderObserver;
  36268. private _tmpMatrix;
  36269. private _tmpVector;
  36270. /**
  36271. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36272. * @param ui The transform node that should be attched to the mesh
  36273. */
  36274. constructor(ui: TransformNode);
  36275. /**
  36276. * Initializes the behavior
  36277. */
  36278. init(): void;
  36279. private _closestFace;
  36280. private _zeroVector;
  36281. private _lookAtTmpMatrix;
  36282. private _lookAtToRef;
  36283. /**
  36284. * Attaches the AttachToBoxBehavior to the passed in mesh
  36285. * @param target The mesh that the specified node will be attached to
  36286. */
  36287. attach(target: Mesh): void;
  36288. /**
  36289. * Detaches the behavior from the mesh
  36290. */
  36291. detach(): void;
  36292. }
  36293. }
  36294. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36295. import { Behavior } from "babylonjs/Behaviors/behavior";
  36296. import { Mesh } from "babylonjs/Meshes/mesh";
  36297. /**
  36298. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36299. */
  36300. export class FadeInOutBehavior implements Behavior<Mesh> {
  36301. /**
  36302. * Time in milliseconds to delay before fading in (Default: 0)
  36303. */
  36304. delay: number;
  36305. /**
  36306. * Time in milliseconds for the mesh to fade in (Default: 300)
  36307. */
  36308. fadeInTime: number;
  36309. private _millisecondsPerFrame;
  36310. private _hovered;
  36311. private _hoverValue;
  36312. private _ownerNode;
  36313. /**
  36314. * Instatiates the FadeInOutBehavior
  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. /**
  36326. * Attaches the fade behavior on the passed in mesh
  36327. * @param ownerNode The mesh that will be faded in/out once attached
  36328. */
  36329. attach(ownerNode: Mesh): void;
  36330. /**
  36331. * Detaches the behavior from the mesh
  36332. */
  36333. detach(): void;
  36334. /**
  36335. * Triggers the mesh to begin fading in or out
  36336. * @param value if the object should fade in or out (true to fade in)
  36337. */
  36338. fadeIn(value: boolean): void;
  36339. private _update;
  36340. private _setAllVisibility;
  36341. }
  36342. }
  36343. declare module "babylonjs/Misc/pivotTools" {
  36344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36345. /**
  36346. * Class containing a set of static utilities functions for managing Pivots
  36347. * @hidden
  36348. */
  36349. export class PivotTools {
  36350. private static _PivotCached;
  36351. private static _OldPivotPoint;
  36352. private static _PivotTranslation;
  36353. private static _PivotTmpVector;
  36354. /** @hidden */
  36355. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36356. /** @hidden */
  36357. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36358. }
  36359. }
  36360. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36361. import { Scene } from "babylonjs/scene";
  36362. import { Vector4, Plane } from "babylonjs/Maths/math";
  36363. import { Mesh } from "babylonjs/Meshes/mesh";
  36364. /**
  36365. * Class containing static functions to help procedurally build meshes
  36366. */
  36367. export class PlaneBuilder {
  36368. /**
  36369. * Creates a plane mesh
  36370. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36371. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36372. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36376. * @param name defines the name of the mesh
  36377. * @param options defines the options used to create the mesh
  36378. * @param scene defines the hosting scene
  36379. * @returns the plane mesh
  36380. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36381. */
  36382. static CreatePlane(name: string, options: {
  36383. size?: number;
  36384. width?: number;
  36385. height?: number;
  36386. sideOrientation?: number;
  36387. frontUVs?: Vector4;
  36388. backUVs?: Vector4;
  36389. updatable?: boolean;
  36390. sourcePlane?: Plane;
  36391. }, scene: Scene): Mesh;
  36392. }
  36393. }
  36394. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36395. import { Behavior } from "babylonjs/Behaviors/behavior";
  36396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36397. import { Observable } from "babylonjs/Misc/observable";
  36398. import { Vector3 } from "babylonjs/Maths/math";
  36399. import { Ray } from "babylonjs/Culling/ray";
  36400. import "babylonjs/Meshes/Builders/planeBuilder";
  36401. /**
  36402. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36403. */
  36404. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36405. private static _AnyMouseID;
  36406. private _attachedNode;
  36407. private _dragPlane;
  36408. private _scene;
  36409. private _pointerObserver;
  36410. private _beforeRenderObserver;
  36411. private static _planeScene;
  36412. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36413. /**
  36414. * 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)
  36415. */
  36416. maxDragAngle: number;
  36417. /**
  36418. * @hidden
  36419. */
  36420. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36421. /**
  36422. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36423. */
  36424. currentDraggingPointerID: number;
  36425. /**
  36426. * The last position where the pointer hit the drag plane in world space
  36427. */
  36428. lastDragPosition: Vector3;
  36429. /**
  36430. * If the behavior is currently in a dragging state
  36431. */
  36432. dragging: boolean;
  36433. /**
  36434. * 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)
  36435. */
  36436. dragDeltaRatio: number;
  36437. /**
  36438. * If the drag plane orientation should be updated during the dragging (Default: true)
  36439. */
  36440. updateDragPlane: boolean;
  36441. private _debugMode;
  36442. private _moving;
  36443. /**
  36444. * Fires each time the attached mesh is dragged with the pointer
  36445. * * delta between last drag position and current drag position in world space
  36446. * * dragDistance along the drag axis
  36447. * * dragPlaneNormal normal of the current drag plane used during the drag
  36448. * * dragPlanePoint in world space where the drag intersects the drag plane
  36449. */
  36450. onDragObservable: Observable<{
  36451. delta: Vector3;
  36452. dragPlanePoint: Vector3;
  36453. dragPlaneNormal: Vector3;
  36454. dragDistance: number;
  36455. pointerId: number;
  36456. }>;
  36457. /**
  36458. * Fires each time a drag begins (eg. mouse down on mesh)
  36459. */
  36460. onDragStartObservable: Observable<{
  36461. dragPlanePoint: Vector3;
  36462. pointerId: number;
  36463. }>;
  36464. /**
  36465. * Fires each time a drag ends (eg. mouse release after drag)
  36466. */
  36467. onDragEndObservable: Observable<{
  36468. dragPlanePoint: Vector3;
  36469. pointerId: number;
  36470. }>;
  36471. /**
  36472. * If the attached mesh should be moved when dragged
  36473. */
  36474. moveAttached: boolean;
  36475. /**
  36476. * If the drag behavior will react to drag events (Default: true)
  36477. */
  36478. enabled: boolean;
  36479. /**
  36480. * If camera controls should be detached during the drag
  36481. */
  36482. detachCameraControls: boolean;
  36483. /**
  36484. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36485. */
  36486. useObjectOrienationForDragging: boolean;
  36487. private _options;
  36488. /**
  36489. * Creates a pointer drag behavior that can be attached to a mesh
  36490. * @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)
  36491. */
  36492. constructor(options?: {
  36493. dragAxis?: Vector3;
  36494. dragPlaneNormal?: Vector3;
  36495. });
  36496. /**
  36497. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36498. */
  36499. validateDrag: (targetPosition: Vector3) => boolean;
  36500. /**
  36501. * The name of the behavior
  36502. */
  36503. readonly name: string;
  36504. /**
  36505. * Initializes the behavior
  36506. */
  36507. init(): void;
  36508. private _tmpVector;
  36509. private _alternatePickedPoint;
  36510. private _worldDragAxis;
  36511. private _targetPosition;
  36512. private _attachedElement;
  36513. /**
  36514. * Attaches the drag behavior the passed in mesh
  36515. * @param ownerNode The mesh that will be dragged around once attached
  36516. */
  36517. attach(ownerNode: AbstractMesh): void;
  36518. /**
  36519. * Force relase the drag action by code.
  36520. */
  36521. releaseDrag(): void;
  36522. private _startDragRay;
  36523. private _lastPointerRay;
  36524. /**
  36525. * Simulates the start of a pointer drag event on the behavior
  36526. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36527. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36528. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36529. */
  36530. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36531. private _startDrag;
  36532. private _dragDelta;
  36533. private _moveDrag;
  36534. private _pickWithRayOnDragPlane;
  36535. private _pointA;
  36536. private _pointB;
  36537. private _pointC;
  36538. private _lineA;
  36539. private _lineB;
  36540. private _localAxis;
  36541. private _lookAt;
  36542. private _updateDragPlanePosition;
  36543. /**
  36544. * Detaches the behavior from the mesh
  36545. */
  36546. detach(): void;
  36547. }
  36548. }
  36549. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36550. import { Mesh } from "babylonjs/Meshes/mesh";
  36551. import { Behavior } from "babylonjs/Behaviors/behavior";
  36552. /**
  36553. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36554. */
  36555. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36556. private _dragBehaviorA;
  36557. private _dragBehaviorB;
  36558. private _startDistance;
  36559. private _initialScale;
  36560. private _targetScale;
  36561. private _ownerNode;
  36562. private _sceneRenderObserver;
  36563. /**
  36564. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36565. */
  36566. constructor();
  36567. /**
  36568. * The name of the behavior
  36569. */
  36570. readonly name: string;
  36571. /**
  36572. * Initializes the behavior
  36573. */
  36574. init(): void;
  36575. private _getCurrentDistance;
  36576. /**
  36577. * Attaches the scale behavior the passed in mesh
  36578. * @param ownerNode The mesh that will be scaled around once attached
  36579. */
  36580. attach(ownerNode: Mesh): void;
  36581. /**
  36582. * Detaches the behavior from the mesh
  36583. */
  36584. detach(): void;
  36585. }
  36586. }
  36587. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36588. import { Behavior } from "babylonjs/Behaviors/behavior";
  36589. import { Mesh } from "babylonjs/Meshes/mesh";
  36590. import { Observable } from "babylonjs/Misc/observable";
  36591. /**
  36592. * 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
  36593. */
  36594. export class SixDofDragBehavior implements Behavior<Mesh> {
  36595. private static _virtualScene;
  36596. private _ownerNode;
  36597. private _sceneRenderObserver;
  36598. private _scene;
  36599. private _targetPosition;
  36600. private _virtualOriginMesh;
  36601. private _virtualDragMesh;
  36602. private _pointerObserver;
  36603. private _moving;
  36604. private _startingOrientation;
  36605. /**
  36606. * 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)
  36607. */
  36608. private zDragFactor;
  36609. /**
  36610. * If the object should rotate to face the drag origin
  36611. */
  36612. rotateDraggedObject: boolean;
  36613. /**
  36614. * If the behavior is currently in a dragging state
  36615. */
  36616. dragging: boolean;
  36617. /**
  36618. * 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)
  36619. */
  36620. dragDeltaRatio: number;
  36621. /**
  36622. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36623. */
  36624. currentDraggingPointerID: number;
  36625. /**
  36626. * If camera controls should be detached during the drag
  36627. */
  36628. detachCameraControls: boolean;
  36629. /**
  36630. * Fires each time a drag starts
  36631. */
  36632. onDragStartObservable: Observable<{}>;
  36633. /**
  36634. * Fires each time a drag ends (eg. mouse release after drag)
  36635. */
  36636. onDragEndObservable: Observable<{}>;
  36637. /**
  36638. * 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
  36639. */
  36640. constructor();
  36641. /**
  36642. * The name of the behavior
  36643. */
  36644. readonly name: string;
  36645. /**
  36646. * Initializes the behavior
  36647. */
  36648. init(): void;
  36649. /**
  36650. * Attaches the scale behavior the passed in mesh
  36651. * @param ownerNode The mesh that will be scaled around once attached
  36652. */
  36653. attach(ownerNode: Mesh): void;
  36654. /**
  36655. * Detaches the behavior from the mesh
  36656. */
  36657. detach(): void;
  36658. }
  36659. }
  36660. declare module "babylonjs/Behaviors/Meshes/index" {
  36661. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36662. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36663. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36664. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36665. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36666. }
  36667. declare module "babylonjs/Behaviors/index" {
  36668. export * from "babylonjs/Behaviors/behavior";
  36669. export * from "babylonjs/Behaviors/Cameras/index";
  36670. export * from "babylonjs/Behaviors/Meshes/index";
  36671. }
  36672. declare module "babylonjs/Bones/boneIKController" {
  36673. import { Bone } from "babylonjs/Bones/bone";
  36674. import { Vector3 } from "babylonjs/Maths/math";
  36675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36676. import { Nullable } from "babylonjs/types";
  36677. /**
  36678. * Class used to apply inverse kinematics to bones
  36679. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36680. */
  36681. export class BoneIKController {
  36682. private static _tmpVecs;
  36683. private static _tmpQuat;
  36684. private static _tmpMats;
  36685. /**
  36686. * Gets or sets the target mesh
  36687. */
  36688. targetMesh: AbstractMesh;
  36689. /** Gets or sets the mesh used as pole */
  36690. poleTargetMesh: AbstractMesh;
  36691. /**
  36692. * Gets or sets the bone used as pole
  36693. */
  36694. poleTargetBone: Nullable<Bone>;
  36695. /**
  36696. * Gets or sets the target position
  36697. */
  36698. targetPosition: Vector3;
  36699. /**
  36700. * Gets or sets the pole target position
  36701. */
  36702. poleTargetPosition: Vector3;
  36703. /**
  36704. * Gets or sets the pole target local offset
  36705. */
  36706. poleTargetLocalOffset: Vector3;
  36707. /**
  36708. * Gets or sets the pole angle
  36709. */
  36710. poleAngle: number;
  36711. /**
  36712. * Gets or sets the mesh associated with the controller
  36713. */
  36714. mesh: AbstractMesh;
  36715. /**
  36716. * 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)
  36717. */
  36718. slerpAmount: number;
  36719. private _bone1Quat;
  36720. private _bone1Mat;
  36721. private _bone2Ang;
  36722. private _bone1;
  36723. private _bone2;
  36724. private _bone1Length;
  36725. private _bone2Length;
  36726. private _maxAngle;
  36727. private _maxReach;
  36728. private _rightHandedSystem;
  36729. private _bendAxis;
  36730. private _slerping;
  36731. private _adjustRoll;
  36732. /**
  36733. * Gets or sets maximum allowed angle
  36734. */
  36735. maxAngle: number;
  36736. /**
  36737. * Creates a new BoneIKController
  36738. * @param mesh defines the mesh to control
  36739. * @param bone defines the bone to control
  36740. * @param options defines options to set up the controller
  36741. */
  36742. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36743. targetMesh?: AbstractMesh;
  36744. poleTargetMesh?: AbstractMesh;
  36745. poleTargetBone?: Bone;
  36746. poleTargetLocalOffset?: Vector3;
  36747. poleAngle?: number;
  36748. bendAxis?: Vector3;
  36749. maxAngle?: number;
  36750. slerpAmount?: number;
  36751. });
  36752. private _setMaxAngle;
  36753. /**
  36754. * Force the controller to update the bones
  36755. */
  36756. update(): void;
  36757. }
  36758. }
  36759. declare module "babylonjs/Bones/boneLookController" {
  36760. import { Vector3, Space } from "babylonjs/Maths/math";
  36761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36762. import { Bone } from "babylonjs/Bones/bone";
  36763. /**
  36764. * Class used to make a bone look toward a point in space
  36765. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36766. */
  36767. export class BoneLookController {
  36768. private static _tmpVecs;
  36769. private static _tmpQuat;
  36770. private static _tmpMats;
  36771. /**
  36772. * The target Vector3 that the bone will look at
  36773. */
  36774. target: Vector3;
  36775. /**
  36776. * The mesh that the bone is attached to
  36777. */
  36778. mesh: AbstractMesh;
  36779. /**
  36780. * The bone that will be looking to the target
  36781. */
  36782. bone: Bone;
  36783. /**
  36784. * The up axis of the coordinate system that is used when the bone is rotated
  36785. */
  36786. upAxis: Vector3;
  36787. /**
  36788. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36789. */
  36790. upAxisSpace: Space;
  36791. /**
  36792. * Used to make an adjustment to the yaw of the bone
  36793. */
  36794. adjustYaw: number;
  36795. /**
  36796. * Used to make an adjustment to the pitch of the bone
  36797. */
  36798. adjustPitch: number;
  36799. /**
  36800. * Used to make an adjustment to the roll of the bone
  36801. */
  36802. adjustRoll: number;
  36803. /**
  36804. * 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)
  36805. */
  36806. slerpAmount: number;
  36807. private _minYaw;
  36808. private _maxYaw;
  36809. private _minPitch;
  36810. private _maxPitch;
  36811. private _minYawSin;
  36812. private _minYawCos;
  36813. private _maxYawSin;
  36814. private _maxYawCos;
  36815. private _midYawConstraint;
  36816. private _minPitchTan;
  36817. private _maxPitchTan;
  36818. private _boneQuat;
  36819. private _slerping;
  36820. private _transformYawPitch;
  36821. private _transformYawPitchInv;
  36822. private _firstFrameSkipped;
  36823. private _yawRange;
  36824. private _fowardAxis;
  36825. /**
  36826. * Gets or sets the minimum yaw angle that the bone can look to
  36827. */
  36828. minYaw: number;
  36829. /**
  36830. * Gets or sets the maximum yaw angle that the bone can look to
  36831. */
  36832. maxYaw: number;
  36833. /**
  36834. * Gets or sets the minimum pitch angle that the bone can look to
  36835. */
  36836. minPitch: number;
  36837. /**
  36838. * Gets or sets the maximum pitch angle that the bone can look to
  36839. */
  36840. maxPitch: number;
  36841. /**
  36842. * Create a BoneLookController
  36843. * @param mesh the mesh that the bone belongs to
  36844. * @param bone the bone that will be looking to the target
  36845. * @param target the target Vector3 to look at
  36846. * @param options optional settings:
  36847. * * maxYaw: the maximum angle the bone will yaw to
  36848. * * minYaw: the minimum angle the bone will yaw to
  36849. * * maxPitch: the maximum angle the bone will pitch to
  36850. * * minPitch: the minimum angle the bone will yaw to
  36851. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36852. * * upAxis: the up axis of the coordinate system
  36853. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36854. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36855. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36856. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36857. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36858. * * adjustRoll: used to make an adjustment to the roll of the bone
  36859. **/
  36860. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36861. maxYaw?: number;
  36862. minYaw?: number;
  36863. maxPitch?: number;
  36864. minPitch?: number;
  36865. slerpAmount?: number;
  36866. upAxis?: Vector3;
  36867. upAxisSpace?: Space;
  36868. yawAxis?: Vector3;
  36869. pitchAxis?: Vector3;
  36870. adjustYaw?: number;
  36871. adjustPitch?: number;
  36872. adjustRoll?: number;
  36873. });
  36874. /**
  36875. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36876. */
  36877. update(): void;
  36878. private _getAngleDiff;
  36879. private _getAngleBetween;
  36880. private _isAngleBetween;
  36881. }
  36882. }
  36883. declare module "babylonjs/Bones/index" {
  36884. export * from "babylonjs/Bones/bone";
  36885. export * from "babylonjs/Bones/boneIKController";
  36886. export * from "babylonjs/Bones/boneLookController";
  36887. export * from "babylonjs/Bones/skeleton";
  36888. }
  36889. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36890. import { Nullable } from "babylonjs/types";
  36891. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36892. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36893. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36894. /**
  36895. * Manage the gamepad inputs to control an arc rotate camera.
  36896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36897. */
  36898. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36899. /**
  36900. * Defines the camera the input is attached to.
  36901. */
  36902. camera: ArcRotateCamera;
  36903. /**
  36904. * Defines the gamepad the input is gathering event from.
  36905. */
  36906. gamepad: Nullable<Gamepad>;
  36907. /**
  36908. * Defines the gamepad rotation sensiblity.
  36909. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36910. */
  36911. gamepadRotationSensibility: number;
  36912. /**
  36913. * Defines the gamepad move sensiblity.
  36914. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36915. */
  36916. gamepadMoveSensibility: number;
  36917. private _onGamepadConnectedObserver;
  36918. private _onGamepadDisconnectedObserver;
  36919. /**
  36920. * Attach the input controls to a specific dom element to get the input from.
  36921. * @param element Defines the element the controls should be listened from
  36922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36923. */
  36924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36925. /**
  36926. * Detach the current controls from the specified dom element.
  36927. * @param element Defines the element to stop listening the inputs from
  36928. */
  36929. detachControl(element: Nullable<HTMLElement>): void;
  36930. /**
  36931. * Update the current camera state depending on the inputs that have been used this frame.
  36932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36933. */
  36934. checkInputs(): void;
  36935. /**
  36936. * Gets the class name of the current intput.
  36937. * @returns the class name
  36938. */
  36939. getClassName(): string;
  36940. /**
  36941. * Get the friendly name associated with the input class.
  36942. * @returns the input friendly name
  36943. */
  36944. getSimpleName(): string;
  36945. }
  36946. }
  36947. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36948. import { Nullable } from "babylonjs/types";
  36949. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36950. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36951. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36952. interface ArcRotateCameraInputsManager {
  36953. /**
  36954. * Add orientation input support to the input manager.
  36955. * @returns the current input manager
  36956. */
  36957. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36958. }
  36959. }
  36960. /**
  36961. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36962. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36963. */
  36964. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36965. /**
  36966. * Defines the camera the input is attached to.
  36967. */
  36968. camera: ArcRotateCamera;
  36969. /**
  36970. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36971. */
  36972. alphaCorrection: number;
  36973. /**
  36974. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36975. */
  36976. gammaCorrection: number;
  36977. private _alpha;
  36978. private _gamma;
  36979. private _dirty;
  36980. private _deviceOrientationHandler;
  36981. /**
  36982. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36983. */
  36984. constructor();
  36985. /**
  36986. * Attach the input controls to a specific dom element to get the input from.
  36987. * @param element Defines the element the controls should be listened from
  36988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36989. */
  36990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36991. /** @hidden */
  36992. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36993. /**
  36994. * Update the current camera state depending on the inputs that have been used this frame.
  36995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36996. */
  36997. checkInputs(): void;
  36998. /**
  36999. * Detach the current controls from the specified dom element.
  37000. * @param element Defines the element to stop listening the inputs from
  37001. */
  37002. detachControl(element: Nullable<HTMLElement>): void;
  37003. /**
  37004. * Gets the class name of the current intput.
  37005. * @returns the class name
  37006. */
  37007. getClassName(): string;
  37008. /**
  37009. * Get the friendly name associated with the input class.
  37010. * @returns the input friendly name
  37011. */
  37012. getSimpleName(): string;
  37013. }
  37014. }
  37015. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37016. import { Nullable } from "babylonjs/types";
  37017. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37018. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37019. /**
  37020. * Listen to mouse events to control the camera.
  37021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37022. */
  37023. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37024. /**
  37025. * Defines the camera the input is attached to.
  37026. */
  37027. camera: FlyCamera;
  37028. /**
  37029. * Defines if touch is enabled. (Default is true.)
  37030. */
  37031. touchEnabled: boolean;
  37032. /**
  37033. * Defines the buttons associated with the input to handle camera rotation.
  37034. */
  37035. buttons: number[];
  37036. /**
  37037. * Assign buttons for Yaw control.
  37038. */
  37039. buttonsYaw: number[];
  37040. /**
  37041. * Assign buttons for Pitch control.
  37042. */
  37043. buttonsPitch: number[];
  37044. /**
  37045. * Assign buttons for Roll control.
  37046. */
  37047. buttonsRoll: number[];
  37048. /**
  37049. * Detect if any button is being pressed while mouse is moved.
  37050. * -1 = Mouse locked.
  37051. * 0 = Left button.
  37052. * 1 = Middle Button.
  37053. * 2 = Right Button.
  37054. */
  37055. activeButton: number;
  37056. /**
  37057. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37058. * Higher values reduce its sensitivity.
  37059. */
  37060. angularSensibility: number;
  37061. private _mousemoveCallback;
  37062. private _observer;
  37063. private _rollObserver;
  37064. private previousPosition;
  37065. private noPreventDefault;
  37066. private element;
  37067. /**
  37068. * Listen to mouse events to control the camera.
  37069. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37071. */
  37072. constructor(touchEnabled?: boolean);
  37073. /**
  37074. * Attach the mouse control to the HTML DOM element.
  37075. * @param element Defines the element that listens to the input events.
  37076. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37077. */
  37078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37079. /**
  37080. * Detach the current controls from the specified dom element.
  37081. * @param element Defines the element to stop listening the inputs from
  37082. */
  37083. detachControl(element: Nullable<HTMLElement>): void;
  37084. /**
  37085. * Gets the class name of the current input.
  37086. * @returns the class name.
  37087. */
  37088. getClassName(): string;
  37089. /**
  37090. * Get the friendly name associated with the input class.
  37091. * @returns the input's friendly name.
  37092. */
  37093. getSimpleName(): string;
  37094. private _pointerInput;
  37095. private _onMouseMove;
  37096. /**
  37097. * Rotate camera by mouse offset.
  37098. */
  37099. private rotateCamera;
  37100. }
  37101. }
  37102. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37103. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37104. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37105. /**
  37106. * Default Inputs manager for the FlyCamera.
  37107. * It groups all the default supported inputs for ease of use.
  37108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37109. */
  37110. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37111. /**
  37112. * Instantiates a new FlyCameraInputsManager.
  37113. * @param camera Defines the camera the inputs belong to.
  37114. */
  37115. constructor(camera: FlyCamera);
  37116. /**
  37117. * Add keyboard input support to the input manager.
  37118. * @returns the new FlyCameraKeyboardMoveInput().
  37119. */
  37120. addKeyboard(): FlyCameraInputsManager;
  37121. /**
  37122. * Add mouse input support to the input manager.
  37123. * @param touchEnabled Enable touch screen support.
  37124. * @returns the new FlyCameraMouseInput().
  37125. */
  37126. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37127. }
  37128. }
  37129. declare module "babylonjs/Cameras/flyCamera" {
  37130. import { Scene } from "babylonjs/scene";
  37131. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37133. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37134. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37135. /**
  37136. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37137. * such as in a 3D Space Shooter or a Flight Simulator.
  37138. */
  37139. export class FlyCamera extends TargetCamera {
  37140. /**
  37141. * Define the collision ellipsoid of the camera.
  37142. * This is helpful for simulating a camera body, like a player's body.
  37143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37144. */
  37145. ellipsoid: Vector3;
  37146. /**
  37147. * Define an offset for the position of the ellipsoid around the camera.
  37148. * This can be helpful if the camera is attached away from the player's body center,
  37149. * such as at its head.
  37150. */
  37151. ellipsoidOffset: Vector3;
  37152. /**
  37153. * Enable or disable collisions of the camera with the rest of the scene objects.
  37154. */
  37155. checkCollisions: boolean;
  37156. /**
  37157. * Enable or disable gravity on the camera.
  37158. */
  37159. applyGravity: boolean;
  37160. /**
  37161. * Define the current direction the camera is moving to.
  37162. */
  37163. cameraDirection: Vector3;
  37164. /**
  37165. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37166. * This overrides and empties cameraRotation.
  37167. */
  37168. rotationQuaternion: Quaternion;
  37169. /**
  37170. * Track Roll to maintain the wanted Rolling when looking around.
  37171. */
  37172. _trackRoll: number;
  37173. /**
  37174. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37175. */
  37176. rollCorrect: number;
  37177. /**
  37178. * Mimic a banked turn, Rolling the camera when Yawing.
  37179. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37180. */
  37181. bankedTurn: boolean;
  37182. /**
  37183. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37184. */
  37185. bankedTurnLimit: number;
  37186. /**
  37187. * Value of 0 disables the banked Roll.
  37188. * Value of 1 is equal to the Yaw angle in radians.
  37189. */
  37190. bankedTurnMultiplier: number;
  37191. /**
  37192. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37193. */
  37194. inputs: FlyCameraInputsManager;
  37195. /**
  37196. * Gets the input sensibility for mouse input.
  37197. * Higher values reduce sensitivity.
  37198. */
  37199. /**
  37200. * Sets the input sensibility for a mouse input.
  37201. * Higher values reduce sensitivity.
  37202. */
  37203. angularSensibility: number;
  37204. /**
  37205. * Get the keys for camera movement forward.
  37206. */
  37207. /**
  37208. * Set the keys for camera movement forward.
  37209. */
  37210. keysForward: number[];
  37211. /**
  37212. * Get the keys for camera movement backward.
  37213. */
  37214. keysBackward: number[];
  37215. /**
  37216. * Get the keys for camera movement up.
  37217. */
  37218. /**
  37219. * Set the keys for camera movement up.
  37220. */
  37221. keysUp: number[];
  37222. /**
  37223. * Get the keys for camera movement down.
  37224. */
  37225. /**
  37226. * Set the keys for camera movement down.
  37227. */
  37228. keysDown: number[];
  37229. /**
  37230. * Get the keys for camera movement left.
  37231. */
  37232. /**
  37233. * Set the keys for camera movement left.
  37234. */
  37235. keysLeft: number[];
  37236. /**
  37237. * Set the keys for camera movement right.
  37238. */
  37239. /**
  37240. * Set the keys for camera movement right.
  37241. */
  37242. keysRight: number[];
  37243. /**
  37244. * Event raised when the camera collides with a mesh in the scene.
  37245. */
  37246. onCollide: (collidedMesh: AbstractMesh) => void;
  37247. private _collider;
  37248. private _needMoveForGravity;
  37249. private _oldPosition;
  37250. private _diffPosition;
  37251. private _newPosition;
  37252. /** @hidden */
  37253. _localDirection: Vector3;
  37254. /** @hidden */
  37255. _transformedDirection: Vector3;
  37256. /**
  37257. * Instantiates a FlyCamera.
  37258. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37259. * such as in a 3D Space Shooter or a Flight Simulator.
  37260. * @param name Define the name of the camera in the scene.
  37261. * @param position Define the starting position of the camera in the scene.
  37262. * @param scene Define the scene the camera belongs to.
  37263. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37264. */
  37265. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37266. /**
  37267. * Attach a control to the HTML DOM element.
  37268. * @param element Defines the element that listens to the input events.
  37269. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37270. */
  37271. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37272. /**
  37273. * Detach a control from the HTML DOM element.
  37274. * The camera will stop reacting to that input.
  37275. * @param element Defines the element that listens to the input events.
  37276. */
  37277. detachControl(element: HTMLElement): void;
  37278. private _collisionMask;
  37279. /**
  37280. * Get the mask that the camera ignores in collision events.
  37281. */
  37282. /**
  37283. * Set the mask that the camera ignores in collision events.
  37284. */
  37285. collisionMask: number;
  37286. /** @hidden */
  37287. _collideWithWorld(displacement: Vector3): void;
  37288. /** @hidden */
  37289. private _onCollisionPositionChange;
  37290. /** @hidden */
  37291. _checkInputs(): void;
  37292. /** @hidden */
  37293. _decideIfNeedsToMove(): boolean;
  37294. /** @hidden */
  37295. _updatePosition(): void;
  37296. /**
  37297. * Restore the Roll to its target value at the rate specified.
  37298. * @param rate - Higher means slower restoring.
  37299. * @hidden
  37300. */
  37301. restoreRoll(rate: number): void;
  37302. /**
  37303. * Destroy the camera and release the current resources held by it.
  37304. */
  37305. dispose(): void;
  37306. /**
  37307. * Get the current object class name.
  37308. * @returns the class name.
  37309. */
  37310. getClassName(): string;
  37311. }
  37312. }
  37313. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37314. import { Nullable } from "babylonjs/types";
  37315. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37316. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37317. /**
  37318. * Listen to keyboard events to control the camera.
  37319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37320. */
  37321. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37322. /**
  37323. * Defines the camera the input is attached to.
  37324. */
  37325. camera: FlyCamera;
  37326. /**
  37327. * The list of keyboard keys used to control the forward move of the camera.
  37328. */
  37329. keysForward: number[];
  37330. /**
  37331. * The list of keyboard keys used to control the backward move of the camera.
  37332. */
  37333. keysBackward: number[];
  37334. /**
  37335. * The list of keyboard keys used to control the forward move of the camera.
  37336. */
  37337. keysUp: number[];
  37338. /**
  37339. * The list of keyboard keys used to control the backward move of the camera.
  37340. */
  37341. keysDown: number[];
  37342. /**
  37343. * The list of keyboard keys used to control the right strafe move of the camera.
  37344. */
  37345. keysRight: number[];
  37346. /**
  37347. * The list of keyboard keys used to control the left strafe move of the camera.
  37348. */
  37349. keysLeft: number[];
  37350. private _keys;
  37351. private _onCanvasBlurObserver;
  37352. private _onKeyboardObserver;
  37353. private _engine;
  37354. private _scene;
  37355. /**
  37356. * Attach the input controls to a specific dom element to get the input from.
  37357. * @param element Defines the element the controls should be listened from
  37358. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37359. */
  37360. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37361. /**
  37362. * Detach the current controls from the specified dom element.
  37363. * @param element Defines the element to stop listening the inputs from
  37364. */
  37365. detachControl(element: Nullable<HTMLElement>): void;
  37366. /**
  37367. * Gets the class name of the current intput.
  37368. * @returns the class name
  37369. */
  37370. getClassName(): string;
  37371. /** @hidden */
  37372. _onLostFocus(e: FocusEvent): void;
  37373. /**
  37374. * Get the friendly name associated with the input class.
  37375. * @returns the input friendly name
  37376. */
  37377. getSimpleName(): string;
  37378. /**
  37379. * Update the current camera state depending on the inputs that have been used this frame.
  37380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37381. */
  37382. checkInputs(): void;
  37383. }
  37384. }
  37385. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37386. import { Nullable } from "babylonjs/types";
  37387. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37388. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37389. /**
  37390. * Manage the mouse wheel inputs to control a follow camera.
  37391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37392. */
  37393. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37394. /**
  37395. * Defines the camera the input is attached to.
  37396. */
  37397. camera: FollowCamera;
  37398. /**
  37399. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37400. */
  37401. axisControlRadius: boolean;
  37402. /**
  37403. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37404. */
  37405. axisControlHeight: boolean;
  37406. /**
  37407. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37408. */
  37409. axisControlRotation: boolean;
  37410. /**
  37411. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37412. * relation to mouseWheel events.
  37413. */
  37414. wheelPrecision: number;
  37415. /**
  37416. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37417. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37418. */
  37419. wheelDeltaPercentage: number;
  37420. private _wheel;
  37421. private _observer;
  37422. /**
  37423. * Attach the input controls to a specific dom element to get the input from.
  37424. * @param element Defines the element the controls should be listened from
  37425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37426. */
  37427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37428. /**
  37429. * Detach the current controls from the specified dom element.
  37430. * @param element Defines the element to stop listening the inputs from
  37431. */
  37432. detachControl(element: Nullable<HTMLElement>): void;
  37433. /**
  37434. * Gets the class name of the current intput.
  37435. * @returns the class name
  37436. */
  37437. getClassName(): string;
  37438. /**
  37439. * Get the friendly name associated with the input class.
  37440. * @returns the input friendly name
  37441. */
  37442. getSimpleName(): string;
  37443. }
  37444. }
  37445. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37446. import { Nullable } from "babylonjs/types";
  37447. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37448. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37449. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37450. /**
  37451. * Manage the pointers inputs to control an follow camera.
  37452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37453. */
  37454. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37455. /**
  37456. * Defines the camera the input is attached to.
  37457. */
  37458. camera: FollowCamera;
  37459. /**
  37460. * Gets the class name of the current input.
  37461. * @returns the class name
  37462. */
  37463. getClassName(): string;
  37464. /**
  37465. * Defines the pointer angular sensibility along the X axis or how fast is
  37466. * the camera rotating.
  37467. * A negative number will reverse the axis direction.
  37468. */
  37469. angularSensibilityX: number;
  37470. /**
  37471. * Defines the pointer angular sensibility along the Y axis or how fast is
  37472. * the camera rotating.
  37473. * A negative number will reverse the axis direction.
  37474. */
  37475. angularSensibilityY: number;
  37476. /**
  37477. * Defines the pointer pinch precision or how fast is the camera zooming.
  37478. * A negative number will reverse the axis direction.
  37479. */
  37480. pinchPrecision: number;
  37481. /**
  37482. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37483. * from 0.
  37484. * It defines the percentage of current camera.radius to use as delta when
  37485. * pinch zoom is used.
  37486. */
  37487. pinchDeltaPercentage: number;
  37488. /**
  37489. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37490. */
  37491. axisXControlRadius: boolean;
  37492. /**
  37493. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37494. */
  37495. axisXControlHeight: boolean;
  37496. /**
  37497. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37498. */
  37499. axisXControlRotation: boolean;
  37500. /**
  37501. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37502. */
  37503. axisYControlRadius: boolean;
  37504. /**
  37505. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37506. */
  37507. axisYControlHeight: boolean;
  37508. /**
  37509. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37510. */
  37511. axisYControlRotation: boolean;
  37512. /**
  37513. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37514. */
  37515. axisPinchControlRadius: boolean;
  37516. /**
  37517. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37518. */
  37519. axisPinchControlHeight: boolean;
  37520. /**
  37521. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37522. */
  37523. axisPinchControlRotation: boolean;
  37524. /**
  37525. * Log error messages if basic misconfiguration has occurred.
  37526. */
  37527. warningEnable: boolean;
  37528. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37529. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37530. private _warningCounter;
  37531. private _warning;
  37532. }
  37533. }
  37534. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37535. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37536. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37537. /**
  37538. * Default Inputs manager for the FollowCamera.
  37539. * It groups all the default supported inputs for ease of use.
  37540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37541. */
  37542. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37543. /**
  37544. * Instantiates a new FollowCameraInputsManager.
  37545. * @param camera Defines the camera the inputs belong to
  37546. */
  37547. constructor(camera: FollowCamera);
  37548. /**
  37549. * Add keyboard input support to the input manager.
  37550. * @returns the current input manager
  37551. */
  37552. addKeyboard(): FollowCameraInputsManager;
  37553. /**
  37554. * Add mouse wheel input support to the input manager.
  37555. * @returns the current input manager
  37556. */
  37557. addMouseWheel(): FollowCameraInputsManager;
  37558. /**
  37559. * Add pointers input support to the input manager.
  37560. * @returns the current input manager
  37561. */
  37562. addPointers(): FollowCameraInputsManager;
  37563. /**
  37564. * Add orientation input support to the input manager.
  37565. * @returns the current input manager
  37566. */
  37567. addVRDeviceOrientation(): FollowCameraInputsManager;
  37568. }
  37569. }
  37570. declare module "babylonjs/Cameras/followCamera" {
  37571. import { Nullable } from "babylonjs/types";
  37572. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37573. import { Scene } from "babylonjs/scene";
  37574. import { Vector3 } from "babylonjs/Maths/math";
  37575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37576. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37577. /**
  37578. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37579. * an arc rotate version arcFollowCamera are available.
  37580. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37581. */
  37582. export class FollowCamera extends TargetCamera {
  37583. /**
  37584. * Distance the follow camera should follow an object at
  37585. */
  37586. radius: number;
  37587. /**
  37588. * Minimum allowed distance of the camera to the axis of rotation
  37589. * (The camera can not get closer).
  37590. * This can help limiting how the Camera is able to move in the scene.
  37591. */
  37592. lowerRadiusLimit: Nullable<number>;
  37593. /**
  37594. * Maximum allowed distance of the camera to the axis of rotation
  37595. * (The camera can not get further).
  37596. * This can help limiting how the Camera is able to move in the scene.
  37597. */
  37598. upperRadiusLimit: Nullable<number>;
  37599. /**
  37600. * Define a rotation offset between the camera and the object it follows
  37601. */
  37602. rotationOffset: number;
  37603. /**
  37604. * Minimum allowed angle to camera position relative to target object.
  37605. * This can help limiting how the Camera is able to move in the scene.
  37606. */
  37607. lowerRotationOffsetLimit: Nullable<number>;
  37608. /**
  37609. * Maximum allowed angle to camera position relative to target object.
  37610. * This can help limiting how the Camera is able to move in the scene.
  37611. */
  37612. upperRotationOffsetLimit: Nullable<number>;
  37613. /**
  37614. * Define a height offset between the camera and the object it follows.
  37615. * It can help following an object from the top (like a car chaing a plane)
  37616. */
  37617. heightOffset: number;
  37618. /**
  37619. * Minimum allowed height of camera position relative to target object.
  37620. * This can help limiting how the Camera is able to move in the scene.
  37621. */
  37622. lowerHeightOffsetLimit: Nullable<number>;
  37623. /**
  37624. * Maximum allowed height of camera position relative to target object.
  37625. * This can help limiting how the Camera is able to move in the scene.
  37626. */
  37627. upperHeightOffsetLimit: Nullable<number>;
  37628. /**
  37629. * Define how fast the camera can accelerate to follow it s target.
  37630. */
  37631. cameraAcceleration: number;
  37632. /**
  37633. * Define the speed limit of the camera following an object.
  37634. */
  37635. maxCameraSpeed: number;
  37636. /**
  37637. * Define the target of the camera.
  37638. */
  37639. lockedTarget: Nullable<AbstractMesh>;
  37640. /**
  37641. * Defines the input associated with the camera.
  37642. */
  37643. inputs: FollowCameraInputsManager;
  37644. /**
  37645. * Instantiates the follow camera.
  37646. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37647. * @param name Define the name of the camera in the scene
  37648. * @param position Define the position of the camera
  37649. * @param scene Define the scene the camera belong to
  37650. * @param lockedTarget Define the target of the camera
  37651. */
  37652. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37653. private _follow;
  37654. /**
  37655. * Attached controls to the current camera.
  37656. * @param element Defines the element the controls should be listened from
  37657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37658. */
  37659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37660. /**
  37661. * Detach the current controls from the camera.
  37662. * The camera will stop reacting to inputs.
  37663. * @param element Defines the element to stop listening the inputs from
  37664. */
  37665. detachControl(element: HTMLElement): void;
  37666. /** @hidden */
  37667. _checkInputs(): void;
  37668. private _checkLimits;
  37669. /**
  37670. * Gets the camera class name.
  37671. * @returns the class name
  37672. */
  37673. getClassName(): string;
  37674. }
  37675. /**
  37676. * Arc Rotate version of the follow camera.
  37677. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37678. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37679. */
  37680. export class ArcFollowCamera extends TargetCamera {
  37681. /** The longitudinal angle of the camera */
  37682. alpha: number;
  37683. /** The latitudinal angle of the camera */
  37684. beta: number;
  37685. /** The radius of the camera from its target */
  37686. radius: number;
  37687. /** Define the camera target (the messh it should follow) */
  37688. target: Nullable<AbstractMesh>;
  37689. private _cartesianCoordinates;
  37690. /**
  37691. * Instantiates a new ArcFollowCamera
  37692. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37693. * @param name Define the name of the camera
  37694. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37695. * @param beta Define the rotation angle of the camera around the elevation axis
  37696. * @param radius Define the radius of the camera from its target point
  37697. * @param target Define the target of the camera
  37698. * @param scene Define the scene the camera belongs to
  37699. */
  37700. constructor(name: string,
  37701. /** The longitudinal angle of the camera */
  37702. alpha: number,
  37703. /** The latitudinal angle of the camera */
  37704. beta: number,
  37705. /** The radius of the camera from its target */
  37706. radius: number,
  37707. /** Define the camera target (the messh it should follow) */
  37708. target: Nullable<AbstractMesh>, scene: Scene);
  37709. private _follow;
  37710. /** @hidden */
  37711. _checkInputs(): void;
  37712. /**
  37713. * Returns the class name of the object.
  37714. * It is mostly used internally for serialization purposes.
  37715. */
  37716. getClassName(): string;
  37717. }
  37718. }
  37719. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37720. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37721. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37722. import { Nullable } from "babylonjs/types";
  37723. /**
  37724. * Manage the keyboard inputs to control the movement of a follow camera.
  37725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37726. */
  37727. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37728. /**
  37729. * Defines the camera the input is attached to.
  37730. */
  37731. camera: FollowCamera;
  37732. /**
  37733. * Defines the list of key codes associated with the up action (increase heightOffset)
  37734. */
  37735. keysHeightOffsetIncr: number[];
  37736. /**
  37737. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37738. */
  37739. keysHeightOffsetDecr: number[];
  37740. /**
  37741. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37742. */
  37743. keysHeightOffsetModifierAlt: boolean;
  37744. /**
  37745. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37746. */
  37747. keysHeightOffsetModifierCtrl: boolean;
  37748. /**
  37749. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37750. */
  37751. keysHeightOffsetModifierShift: boolean;
  37752. /**
  37753. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37754. */
  37755. keysRotationOffsetIncr: number[];
  37756. /**
  37757. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37758. */
  37759. keysRotationOffsetDecr: number[];
  37760. /**
  37761. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37762. */
  37763. keysRotationOffsetModifierAlt: boolean;
  37764. /**
  37765. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37766. */
  37767. keysRotationOffsetModifierCtrl: boolean;
  37768. /**
  37769. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37770. */
  37771. keysRotationOffsetModifierShift: boolean;
  37772. /**
  37773. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37774. */
  37775. keysRadiusIncr: number[];
  37776. /**
  37777. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37778. */
  37779. keysRadiusDecr: number[];
  37780. /**
  37781. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37782. */
  37783. keysRadiusModifierAlt: boolean;
  37784. /**
  37785. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37786. */
  37787. keysRadiusModifierCtrl: boolean;
  37788. /**
  37789. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37790. */
  37791. keysRadiusModifierShift: boolean;
  37792. /**
  37793. * Defines the rate of change of heightOffset.
  37794. */
  37795. heightSensibility: number;
  37796. /**
  37797. * Defines the rate of change of rotationOffset.
  37798. */
  37799. rotationSensibility: number;
  37800. /**
  37801. * Defines the rate of change of radius.
  37802. */
  37803. radiusSensibility: number;
  37804. private _keys;
  37805. private _ctrlPressed;
  37806. private _altPressed;
  37807. private _shiftPressed;
  37808. private _onCanvasBlurObserver;
  37809. private _onKeyboardObserver;
  37810. private _engine;
  37811. private _scene;
  37812. /**
  37813. * Attach the input controls to a specific dom element to get the input from.
  37814. * @param element Defines the element the controls should be listened from
  37815. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37816. */
  37817. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37818. /**
  37819. * Detach the current controls from the specified dom element.
  37820. * @param element Defines the element to stop listening the inputs from
  37821. */
  37822. detachControl(element: Nullable<HTMLElement>): void;
  37823. /**
  37824. * Update the current camera state depending on the inputs that have been used this frame.
  37825. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37826. */
  37827. checkInputs(): void;
  37828. /**
  37829. * Gets the class name of the current input.
  37830. * @returns the class name
  37831. */
  37832. getClassName(): string;
  37833. /**
  37834. * Get the friendly name associated with the input class.
  37835. * @returns the input friendly name
  37836. */
  37837. getSimpleName(): string;
  37838. /**
  37839. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37840. * allow modification of the heightOffset value.
  37841. */
  37842. private _modifierHeightOffset;
  37843. /**
  37844. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37845. * allow modification of the rotationOffset value.
  37846. */
  37847. private _modifierRotationOffset;
  37848. /**
  37849. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37850. * allow modification of the radius value.
  37851. */
  37852. private _modifierRadius;
  37853. }
  37854. }
  37855. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37856. import { Nullable } from "babylonjs/types";
  37857. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37858. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37859. import { Observable } from "babylonjs/Misc/observable";
  37860. module "babylonjs/Cameras/freeCameraInputsManager" {
  37861. interface FreeCameraInputsManager {
  37862. /**
  37863. * @hidden
  37864. */
  37865. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37866. /**
  37867. * Add orientation input support to the input manager.
  37868. * @returns the current input manager
  37869. */
  37870. addDeviceOrientation(): FreeCameraInputsManager;
  37871. }
  37872. }
  37873. /**
  37874. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37875. * Screen rotation is taken into account.
  37876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37877. */
  37878. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37879. private _camera;
  37880. private _screenOrientationAngle;
  37881. private _constantTranform;
  37882. private _screenQuaternion;
  37883. private _alpha;
  37884. private _beta;
  37885. private _gamma;
  37886. /**
  37887. * @hidden
  37888. */
  37889. _onDeviceOrientationChangedObservable: Observable<void>;
  37890. /**
  37891. * Instantiates a new input
  37892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37893. */
  37894. constructor();
  37895. /**
  37896. * Define the camera controlled by the input.
  37897. */
  37898. camera: FreeCamera;
  37899. /**
  37900. * Attach the input controls to a specific dom element to get the input from.
  37901. * @param element Defines the element the controls should be listened from
  37902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37903. */
  37904. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37905. private _orientationChanged;
  37906. private _deviceOrientation;
  37907. /**
  37908. * Detach the current controls from the specified dom element.
  37909. * @param element Defines the element to stop listening the inputs from
  37910. */
  37911. detachControl(element: Nullable<HTMLElement>): void;
  37912. /**
  37913. * Update the current camera state depending on the inputs that have been used this frame.
  37914. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37915. */
  37916. checkInputs(): void;
  37917. /**
  37918. * Gets the class name of the current intput.
  37919. * @returns the class name
  37920. */
  37921. getClassName(): string;
  37922. /**
  37923. * Get the friendly name associated with the input class.
  37924. * @returns the input friendly name
  37925. */
  37926. getSimpleName(): string;
  37927. }
  37928. }
  37929. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37930. import { Nullable } from "babylonjs/types";
  37931. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37932. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37933. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37934. /**
  37935. * Manage the gamepad inputs to control a free camera.
  37936. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37937. */
  37938. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37939. /**
  37940. * Define the camera the input is attached to.
  37941. */
  37942. camera: FreeCamera;
  37943. /**
  37944. * Define the Gamepad controlling the input
  37945. */
  37946. gamepad: Nullable<Gamepad>;
  37947. /**
  37948. * Defines the gamepad rotation sensiblity.
  37949. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37950. */
  37951. gamepadAngularSensibility: number;
  37952. /**
  37953. * Defines the gamepad move sensiblity.
  37954. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37955. */
  37956. gamepadMoveSensibility: number;
  37957. private _onGamepadConnectedObserver;
  37958. private _onGamepadDisconnectedObserver;
  37959. private _cameraTransform;
  37960. private _deltaTransform;
  37961. private _vector3;
  37962. private _vector2;
  37963. /**
  37964. * Attach the input controls to a specific dom element to get the input from.
  37965. * @param element Defines the element the controls should be listened from
  37966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37967. */
  37968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37969. /**
  37970. * Detach the current controls from the specified dom element.
  37971. * @param element Defines the element to stop listening the inputs from
  37972. */
  37973. detachControl(element: Nullable<HTMLElement>): void;
  37974. /**
  37975. * Update the current camera state depending on the inputs that have been used this frame.
  37976. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37977. */
  37978. checkInputs(): void;
  37979. /**
  37980. * Gets the class name of the current intput.
  37981. * @returns the class name
  37982. */
  37983. getClassName(): string;
  37984. /**
  37985. * Get the friendly name associated with the input class.
  37986. * @returns the input friendly name
  37987. */
  37988. getSimpleName(): string;
  37989. }
  37990. }
  37991. declare module "babylonjs/Misc/virtualJoystick" {
  37992. import { Nullable } from "babylonjs/types";
  37993. import { Vector3 } from "babylonjs/Maths/math";
  37994. /**
  37995. * Defines the potential axis of a Joystick
  37996. */
  37997. export enum JoystickAxis {
  37998. /** X axis */
  37999. X = 0,
  38000. /** Y axis */
  38001. Y = 1,
  38002. /** Z axis */
  38003. Z = 2
  38004. }
  38005. /**
  38006. * Class used to define virtual joystick (used in touch mode)
  38007. */
  38008. export class VirtualJoystick {
  38009. /**
  38010. * Gets or sets a boolean indicating that left and right values must be inverted
  38011. */
  38012. reverseLeftRight: boolean;
  38013. /**
  38014. * Gets or sets a boolean indicating that up and down values must be inverted
  38015. */
  38016. reverseUpDown: boolean;
  38017. /**
  38018. * Gets the offset value for the position (ie. the change of the position value)
  38019. */
  38020. deltaPosition: Vector3;
  38021. /**
  38022. * Gets a boolean indicating if the virtual joystick was pressed
  38023. */
  38024. pressed: boolean;
  38025. /**
  38026. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38027. */
  38028. static Canvas: Nullable<HTMLCanvasElement>;
  38029. private static _globalJoystickIndex;
  38030. private static vjCanvasContext;
  38031. private static vjCanvasWidth;
  38032. private static vjCanvasHeight;
  38033. private static halfWidth;
  38034. private _action;
  38035. private _axisTargetedByLeftAndRight;
  38036. private _axisTargetedByUpAndDown;
  38037. private _joystickSensibility;
  38038. private _inversedSensibility;
  38039. private _joystickPointerID;
  38040. private _joystickColor;
  38041. private _joystickPointerPos;
  38042. private _joystickPreviousPointerPos;
  38043. private _joystickPointerStartPos;
  38044. private _deltaJoystickVector;
  38045. private _leftJoystick;
  38046. private _touches;
  38047. private _onPointerDownHandlerRef;
  38048. private _onPointerMoveHandlerRef;
  38049. private _onPointerUpHandlerRef;
  38050. private _onResize;
  38051. /**
  38052. * Creates a new virtual joystick
  38053. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38054. */
  38055. constructor(leftJoystick?: boolean);
  38056. /**
  38057. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38058. * @param newJoystickSensibility defines the new sensibility
  38059. */
  38060. setJoystickSensibility(newJoystickSensibility: number): void;
  38061. private _onPointerDown;
  38062. private _onPointerMove;
  38063. private _onPointerUp;
  38064. /**
  38065. * Change the color of the virtual joystick
  38066. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38067. */
  38068. setJoystickColor(newColor: string): void;
  38069. /**
  38070. * Defines a callback to call when the joystick is touched
  38071. * @param action defines the callback
  38072. */
  38073. setActionOnTouch(action: () => any): void;
  38074. /**
  38075. * Defines which axis you'd like to control for left & right
  38076. * @param axis defines the axis to use
  38077. */
  38078. setAxisForLeftRight(axis: JoystickAxis): void;
  38079. /**
  38080. * Defines which axis you'd like to control for up & down
  38081. * @param axis defines the axis to use
  38082. */
  38083. setAxisForUpDown(axis: JoystickAxis): void;
  38084. private _drawVirtualJoystick;
  38085. /**
  38086. * Release internal HTML canvas
  38087. */
  38088. releaseCanvas(): void;
  38089. }
  38090. }
  38091. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38092. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38093. import { Nullable } from "babylonjs/types";
  38094. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38095. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38096. module "babylonjs/Cameras/freeCameraInputsManager" {
  38097. interface FreeCameraInputsManager {
  38098. /**
  38099. * Add virtual joystick input support to the input manager.
  38100. * @returns the current input manager
  38101. */
  38102. addVirtualJoystick(): FreeCameraInputsManager;
  38103. }
  38104. }
  38105. /**
  38106. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38107. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38108. */
  38109. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38110. /**
  38111. * Defines the camera the input is attached to.
  38112. */
  38113. camera: FreeCamera;
  38114. private _leftjoystick;
  38115. private _rightjoystick;
  38116. /**
  38117. * Gets the left stick of the virtual joystick.
  38118. * @returns The virtual Joystick
  38119. */
  38120. getLeftJoystick(): VirtualJoystick;
  38121. /**
  38122. * Gets the right stick of the virtual joystick.
  38123. * @returns The virtual Joystick
  38124. */
  38125. getRightJoystick(): VirtualJoystick;
  38126. /**
  38127. * Update the current camera state depending on the inputs that have been used this frame.
  38128. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38129. */
  38130. checkInputs(): void;
  38131. /**
  38132. * Attach the input controls to a specific dom element to get the input from.
  38133. * @param element Defines the element the controls should be listened from
  38134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38135. */
  38136. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38137. /**
  38138. * Detach the current controls from the specified dom element.
  38139. * @param element Defines the element to stop listening the inputs from
  38140. */
  38141. detachControl(element: Nullable<HTMLElement>): void;
  38142. /**
  38143. * Gets the class name of the current intput.
  38144. * @returns the class name
  38145. */
  38146. getClassName(): string;
  38147. /**
  38148. * Get the friendly name associated with the input class.
  38149. * @returns the input friendly name
  38150. */
  38151. getSimpleName(): string;
  38152. }
  38153. }
  38154. declare module "babylonjs/Cameras/Inputs/index" {
  38155. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38156. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38157. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38158. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38159. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38160. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38161. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38162. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38163. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38164. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38165. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38166. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38167. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38168. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38169. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38170. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38171. }
  38172. declare module "babylonjs/Cameras/touchCamera" {
  38173. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38174. import { Scene } from "babylonjs/scene";
  38175. import { Vector3 } from "babylonjs/Maths/math";
  38176. /**
  38177. * This represents a FPS type of camera controlled by touch.
  38178. * This is like a universal camera minus the Gamepad controls.
  38179. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38180. */
  38181. export class TouchCamera extends FreeCamera {
  38182. /**
  38183. * Defines the touch sensibility for rotation.
  38184. * The higher the faster.
  38185. */
  38186. touchAngularSensibility: number;
  38187. /**
  38188. * Defines the touch sensibility for move.
  38189. * The higher the faster.
  38190. */
  38191. touchMoveSensibility: number;
  38192. /**
  38193. * Instantiates a new touch camera.
  38194. * This represents a FPS type of camera controlled by touch.
  38195. * This is like a universal camera minus the Gamepad controls.
  38196. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38197. * @param name Define the name of the camera in the scene
  38198. * @param position Define the start position of the camera in the scene
  38199. * @param scene Define the scene the camera belongs to
  38200. */
  38201. constructor(name: string, position: Vector3, scene: Scene);
  38202. /**
  38203. * Gets the current object class name.
  38204. * @return the class name
  38205. */
  38206. getClassName(): string;
  38207. /** @hidden */
  38208. _setupInputs(): void;
  38209. }
  38210. }
  38211. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38212. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38213. import { Scene } from "babylonjs/scene";
  38214. import { Vector3, Axis } from "babylonjs/Maths/math";
  38215. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38216. /**
  38217. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38218. * being tilted forward or back and left or right.
  38219. */
  38220. export class DeviceOrientationCamera extends FreeCamera {
  38221. private _initialQuaternion;
  38222. private _quaternionCache;
  38223. private _tmpDragQuaternion;
  38224. /**
  38225. * Creates a new device orientation camera
  38226. * @param name The name of the camera
  38227. * @param position The start position camera
  38228. * @param scene The scene the camera belongs to
  38229. */
  38230. constructor(name: string, position: Vector3, scene: Scene);
  38231. /**
  38232. * Disabled pointer input on first orientation sensor update (Default: true)
  38233. */
  38234. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38235. private _dragFactor;
  38236. /**
  38237. * Enabled turning on the y axis when the orientation sensor is active
  38238. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38239. */
  38240. enableHorizontalDragging(dragFactor?: number): void;
  38241. /**
  38242. * Gets the current instance class name ("DeviceOrientationCamera").
  38243. * This helps avoiding instanceof at run time.
  38244. * @returns the class name
  38245. */
  38246. getClassName(): string;
  38247. /**
  38248. * @hidden
  38249. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38250. */
  38251. _checkInputs(): void;
  38252. /**
  38253. * Reset the camera to its default orientation on the specified axis only.
  38254. * @param axis The axis to reset
  38255. */
  38256. resetToCurrentRotation(axis?: Axis): void;
  38257. }
  38258. }
  38259. declare module "babylonjs/Cameras/universalCamera" {
  38260. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38261. import { Scene } from "babylonjs/scene";
  38262. import { Vector3 } from "babylonjs/Maths/math";
  38263. /**
  38264. * 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,
  38265. * which still works and will still be found in many Playgrounds.
  38266. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38267. */
  38268. export class UniversalCamera extends TouchCamera {
  38269. /**
  38270. * Defines the gamepad rotation sensiblity.
  38271. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38272. */
  38273. gamepadAngularSensibility: number;
  38274. /**
  38275. * Defines the gamepad move sensiblity.
  38276. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38277. */
  38278. gamepadMoveSensibility: number;
  38279. /**
  38280. * 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,
  38281. * which still works and will still be found in many Playgrounds.
  38282. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38283. * @param name Define the name of the camera in the scene
  38284. * @param position Define the start position of the camera in the scene
  38285. * @param scene Define the scene the camera belongs to
  38286. */
  38287. constructor(name: string, position: Vector3, scene: Scene);
  38288. /**
  38289. * Gets the current object class name.
  38290. * @return the class name
  38291. */
  38292. getClassName(): string;
  38293. }
  38294. }
  38295. declare module "babylonjs/Cameras/gamepadCamera" {
  38296. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38297. import { Scene } from "babylonjs/scene";
  38298. import { Vector3 } from "babylonjs/Maths/math";
  38299. /**
  38300. * This represents a FPS type of camera. This is only here for back compat purpose.
  38301. * Please use the UniversalCamera instead as both are identical.
  38302. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38303. */
  38304. export class GamepadCamera extends UniversalCamera {
  38305. /**
  38306. * Instantiates a new Gamepad Camera
  38307. * This represents a FPS type of camera. This is only here for back compat purpose.
  38308. * Please use the UniversalCamera instead as both are identical.
  38309. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38310. * @param name Define the name of the camera in the scene
  38311. * @param position Define the start position of the camera in the scene
  38312. * @param scene Define the scene the camera belongs to
  38313. */
  38314. constructor(name: string, position: Vector3, scene: Scene);
  38315. /**
  38316. * Gets the current object class name.
  38317. * @return the class name
  38318. */
  38319. getClassName(): string;
  38320. }
  38321. }
  38322. declare module "babylonjs/Shaders/pass.fragment" {
  38323. /** @hidden */
  38324. export var passPixelShader: {
  38325. name: string;
  38326. shader: string;
  38327. };
  38328. }
  38329. declare module "babylonjs/Shaders/passCube.fragment" {
  38330. /** @hidden */
  38331. export var passCubePixelShader: {
  38332. name: string;
  38333. shader: string;
  38334. };
  38335. }
  38336. declare module "babylonjs/PostProcesses/passPostProcess" {
  38337. import { Nullable } from "babylonjs/types";
  38338. import { Camera } from "babylonjs/Cameras/camera";
  38339. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38340. import { Engine } from "babylonjs/Engines/engine";
  38341. import "babylonjs/Shaders/pass.fragment";
  38342. import "babylonjs/Shaders/passCube.fragment";
  38343. /**
  38344. * PassPostProcess which produces an output the same as it's input
  38345. */
  38346. export class PassPostProcess extends PostProcess {
  38347. /**
  38348. * Creates the PassPostProcess
  38349. * @param name The name of the effect.
  38350. * @param options The required width/height ratio to downsize to before computing the render pass.
  38351. * @param camera The camera to apply the render pass to.
  38352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38353. * @param engine The engine which the post process will be applied. (default: current engine)
  38354. * @param reusable If the post process can be reused on the same frame. (default: false)
  38355. * @param textureType The type of texture to be used when performing the post processing.
  38356. * @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)
  38357. */
  38358. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38359. }
  38360. /**
  38361. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38362. */
  38363. export class PassCubePostProcess extends PostProcess {
  38364. private _face;
  38365. /**
  38366. * Gets or sets the cube face to display.
  38367. * * 0 is +X
  38368. * * 1 is -X
  38369. * * 2 is +Y
  38370. * * 3 is -Y
  38371. * * 4 is +Z
  38372. * * 5 is -Z
  38373. */
  38374. face: number;
  38375. /**
  38376. * Creates the PassCubePostProcess
  38377. * @param name The name of the effect.
  38378. * @param options The required width/height ratio to downsize to before computing the render pass.
  38379. * @param camera The camera to apply the render pass to.
  38380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38381. * @param engine The engine which the post process will be applied. (default: current engine)
  38382. * @param reusable If the post process can be reused on the same frame. (default: false)
  38383. * @param textureType The type of texture to be used when performing the post processing.
  38384. * @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)
  38385. */
  38386. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38387. }
  38388. }
  38389. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38390. /** @hidden */
  38391. export var anaglyphPixelShader: {
  38392. name: string;
  38393. shader: string;
  38394. };
  38395. }
  38396. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38397. import { Engine } from "babylonjs/Engines/engine";
  38398. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38399. import { Camera } from "babylonjs/Cameras/camera";
  38400. import "babylonjs/Shaders/anaglyph.fragment";
  38401. /**
  38402. * Postprocess used to generate anaglyphic rendering
  38403. */
  38404. export class AnaglyphPostProcess extends PostProcess {
  38405. private _passedProcess;
  38406. /**
  38407. * Creates a new AnaglyphPostProcess
  38408. * @param name defines postprocess name
  38409. * @param options defines creation options or target ratio scale
  38410. * @param rigCameras defines cameras using this postprocess
  38411. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38412. * @param engine defines hosting engine
  38413. * @param reusable defines if the postprocess will be reused multiple times per frame
  38414. */
  38415. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38416. }
  38417. }
  38418. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38419. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38420. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38421. import { Scene } from "babylonjs/scene";
  38422. import { Vector3 } from "babylonjs/Maths/math";
  38423. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38424. /**
  38425. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38426. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38427. */
  38428. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38429. /**
  38430. * Creates a new AnaglyphArcRotateCamera
  38431. * @param name defines camera name
  38432. * @param alpha defines alpha angle (in radians)
  38433. * @param beta defines beta angle (in radians)
  38434. * @param radius defines radius
  38435. * @param target defines camera target
  38436. * @param interaxialDistance defines distance between each color axis
  38437. * @param scene defines the hosting scene
  38438. */
  38439. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38440. /**
  38441. * Gets camera class name
  38442. * @returns AnaglyphArcRotateCamera
  38443. */
  38444. getClassName(): string;
  38445. }
  38446. }
  38447. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38448. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38449. import { Scene } from "babylonjs/scene";
  38450. import { Vector3 } from "babylonjs/Maths/math";
  38451. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38452. /**
  38453. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38454. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38455. */
  38456. export class AnaglyphFreeCamera extends FreeCamera {
  38457. /**
  38458. * Creates a new AnaglyphFreeCamera
  38459. * @param name defines camera name
  38460. * @param position defines initial position
  38461. * @param interaxialDistance defines distance between each color axis
  38462. * @param scene defines the hosting scene
  38463. */
  38464. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38465. /**
  38466. * Gets camera class name
  38467. * @returns AnaglyphFreeCamera
  38468. */
  38469. getClassName(): string;
  38470. }
  38471. }
  38472. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38473. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38474. import { Scene } from "babylonjs/scene";
  38475. import { Vector3 } from "babylonjs/Maths/math";
  38476. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38477. /**
  38478. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38479. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38480. */
  38481. export class AnaglyphGamepadCamera extends GamepadCamera {
  38482. /**
  38483. * Creates a new AnaglyphGamepadCamera
  38484. * @param name defines camera name
  38485. * @param position defines initial position
  38486. * @param interaxialDistance defines distance between each color axis
  38487. * @param scene defines the hosting scene
  38488. */
  38489. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38490. /**
  38491. * Gets camera class name
  38492. * @returns AnaglyphGamepadCamera
  38493. */
  38494. getClassName(): string;
  38495. }
  38496. }
  38497. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38498. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38499. import { Scene } from "babylonjs/scene";
  38500. import { Vector3 } from "babylonjs/Maths/math";
  38501. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38502. /**
  38503. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38504. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38505. */
  38506. export class AnaglyphUniversalCamera extends UniversalCamera {
  38507. /**
  38508. * Creates a new AnaglyphUniversalCamera
  38509. * @param name defines camera name
  38510. * @param position defines initial position
  38511. * @param interaxialDistance defines distance between each color axis
  38512. * @param scene defines the hosting scene
  38513. */
  38514. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38515. /**
  38516. * Gets camera class name
  38517. * @returns AnaglyphUniversalCamera
  38518. */
  38519. getClassName(): string;
  38520. }
  38521. }
  38522. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38523. /** @hidden */
  38524. export var stereoscopicInterlacePixelShader: {
  38525. name: string;
  38526. shader: string;
  38527. };
  38528. }
  38529. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38530. import { Camera } from "babylonjs/Cameras/camera";
  38531. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38532. import { Engine } from "babylonjs/Engines/engine";
  38533. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38534. /**
  38535. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38536. */
  38537. export class StereoscopicInterlacePostProcess extends PostProcess {
  38538. private _stepSize;
  38539. private _passedProcess;
  38540. /**
  38541. * Initializes a StereoscopicInterlacePostProcess
  38542. * @param name The name of the effect.
  38543. * @param rigCameras The rig cameras to be appled to the post process
  38544. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38545. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38546. * @param engine The engine which the post process will be applied. (default: current engine)
  38547. * @param reusable If the post process can be reused on the same frame. (default: false)
  38548. */
  38549. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38550. }
  38551. }
  38552. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38553. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38554. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38555. import { Scene } from "babylonjs/scene";
  38556. import { Vector3 } from "babylonjs/Maths/math";
  38557. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38558. /**
  38559. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38560. * @see http://doc.babylonjs.com/features/cameras
  38561. */
  38562. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38563. /**
  38564. * Creates a new StereoscopicArcRotateCamera
  38565. * @param name defines camera name
  38566. * @param alpha defines alpha angle (in radians)
  38567. * @param beta defines beta angle (in radians)
  38568. * @param radius defines radius
  38569. * @param target defines camera target
  38570. * @param interaxialDistance defines distance between each color axis
  38571. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38572. * @param scene defines the hosting scene
  38573. */
  38574. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38575. /**
  38576. * Gets camera class name
  38577. * @returns StereoscopicArcRotateCamera
  38578. */
  38579. getClassName(): string;
  38580. }
  38581. }
  38582. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38583. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38584. import { Scene } from "babylonjs/scene";
  38585. import { Vector3 } from "babylonjs/Maths/math";
  38586. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38587. /**
  38588. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38589. * @see http://doc.babylonjs.com/features/cameras
  38590. */
  38591. export class StereoscopicFreeCamera extends FreeCamera {
  38592. /**
  38593. * Creates a new StereoscopicFreeCamera
  38594. * @param name defines camera name
  38595. * @param position defines initial position
  38596. * @param interaxialDistance defines distance between each color axis
  38597. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38598. * @param scene defines the hosting scene
  38599. */
  38600. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38601. /**
  38602. * Gets camera class name
  38603. * @returns StereoscopicFreeCamera
  38604. */
  38605. getClassName(): string;
  38606. }
  38607. }
  38608. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38609. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38610. import { Scene } from "babylonjs/scene";
  38611. import { Vector3 } from "babylonjs/Maths/math";
  38612. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38613. /**
  38614. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38615. * @see http://doc.babylonjs.com/features/cameras
  38616. */
  38617. export class StereoscopicGamepadCamera extends GamepadCamera {
  38618. /**
  38619. * Creates a new StereoscopicGamepadCamera
  38620. * @param name defines camera name
  38621. * @param position defines initial position
  38622. * @param interaxialDistance defines distance between each color axis
  38623. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38624. * @param scene defines the hosting scene
  38625. */
  38626. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38627. /**
  38628. * Gets camera class name
  38629. * @returns StereoscopicGamepadCamera
  38630. */
  38631. getClassName(): string;
  38632. }
  38633. }
  38634. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38635. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38636. import { Scene } from "babylonjs/scene";
  38637. import { Vector3 } from "babylonjs/Maths/math";
  38638. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38639. /**
  38640. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38641. * @see http://doc.babylonjs.com/features/cameras
  38642. */
  38643. export class StereoscopicUniversalCamera extends UniversalCamera {
  38644. /**
  38645. * Creates a new StereoscopicUniversalCamera
  38646. * @param name defines camera name
  38647. * @param position defines initial position
  38648. * @param interaxialDistance defines distance between each color axis
  38649. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38650. * @param scene defines the hosting scene
  38651. */
  38652. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38653. /**
  38654. * Gets camera class name
  38655. * @returns StereoscopicUniversalCamera
  38656. */
  38657. getClassName(): string;
  38658. }
  38659. }
  38660. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38661. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38662. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38663. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38664. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38665. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38666. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38667. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38668. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38669. }
  38670. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38671. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38672. import { Scene } from "babylonjs/scene";
  38673. import { Vector3 } from "babylonjs/Maths/math";
  38674. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38675. /**
  38676. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38677. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38678. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38679. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38680. */
  38681. export class VirtualJoysticksCamera extends FreeCamera {
  38682. /**
  38683. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38684. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38685. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38686. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38687. * @param name Define the name of the camera in the scene
  38688. * @param position Define the start position of the camera in the scene
  38689. * @param scene Define the scene the camera belongs to
  38690. */
  38691. constructor(name: string, position: Vector3, scene: Scene);
  38692. /**
  38693. * Gets the current object class name.
  38694. * @return the class name
  38695. */
  38696. getClassName(): string;
  38697. }
  38698. }
  38699. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38700. import { Matrix } from "babylonjs/Maths/math";
  38701. /**
  38702. * This represents all the required metrics to create a VR camera.
  38703. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38704. */
  38705. export class VRCameraMetrics {
  38706. /**
  38707. * Define the horizontal resolution off the screen.
  38708. */
  38709. hResolution: number;
  38710. /**
  38711. * Define the vertical resolution off the screen.
  38712. */
  38713. vResolution: number;
  38714. /**
  38715. * Define the horizontal screen size.
  38716. */
  38717. hScreenSize: number;
  38718. /**
  38719. * Define the vertical screen size.
  38720. */
  38721. vScreenSize: number;
  38722. /**
  38723. * Define the vertical screen center position.
  38724. */
  38725. vScreenCenter: number;
  38726. /**
  38727. * Define the distance of the eyes to the screen.
  38728. */
  38729. eyeToScreenDistance: number;
  38730. /**
  38731. * Define the distance between both lenses
  38732. */
  38733. lensSeparationDistance: number;
  38734. /**
  38735. * Define the distance between both viewer's eyes.
  38736. */
  38737. interpupillaryDistance: number;
  38738. /**
  38739. * Define the distortion factor of the VR postprocess.
  38740. * Please, touch with care.
  38741. */
  38742. distortionK: number[];
  38743. /**
  38744. * Define the chromatic aberration correction factors for the VR post process.
  38745. */
  38746. chromaAbCorrection: number[];
  38747. /**
  38748. * Define the scale factor of the post process.
  38749. * The smaller the better but the slower.
  38750. */
  38751. postProcessScaleFactor: number;
  38752. /**
  38753. * Define an offset for the lens center.
  38754. */
  38755. lensCenterOffset: number;
  38756. /**
  38757. * Define if the current vr camera should compensate the distortion of the lense or not.
  38758. */
  38759. compensateDistortion: boolean;
  38760. /**
  38761. * Defines if multiview should be enabled when rendering (Default: false)
  38762. */
  38763. multiviewEnabled: boolean;
  38764. /**
  38765. * Gets the rendering aspect ratio based on the provided resolutions.
  38766. */
  38767. readonly aspectRatio: number;
  38768. /**
  38769. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38770. */
  38771. readonly aspectRatioFov: number;
  38772. /**
  38773. * @hidden
  38774. */
  38775. readonly leftHMatrix: Matrix;
  38776. /**
  38777. * @hidden
  38778. */
  38779. readonly rightHMatrix: Matrix;
  38780. /**
  38781. * @hidden
  38782. */
  38783. readonly leftPreViewMatrix: Matrix;
  38784. /**
  38785. * @hidden
  38786. */
  38787. readonly rightPreViewMatrix: Matrix;
  38788. /**
  38789. * Get the default VRMetrics based on the most generic setup.
  38790. * @returns the default vr metrics
  38791. */
  38792. static GetDefault(): VRCameraMetrics;
  38793. }
  38794. }
  38795. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38796. /** @hidden */
  38797. export var vrDistortionCorrectionPixelShader: {
  38798. name: string;
  38799. shader: string;
  38800. };
  38801. }
  38802. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38803. import { Camera } from "babylonjs/Cameras/camera";
  38804. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38805. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38806. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38807. /**
  38808. * VRDistortionCorrectionPostProcess used for mobile VR
  38809. */
  38810. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38811. private _isRightEye;
  38812. private _distortionFactors;
  38813. private _postProcessScaleFactor;
  38814. private _lensCenterOffset;
  38815. private _scaleIn;
  38816. private _scaleFactor;
  38817. private _lensCenter;
  38818. /**
  38819. * Initializes the VRDistortionCorrectionPostProcess
  38820. * @param name The name of the effect.
  38821. * @param camera The camera to apply the render pass to.
  38822. * @param isRightEye If this is for the right eye distortion
  38823. * @param vrMetrics All the required metrics for the VR camera
  38824. */
  38825. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38826. }
  38827. }
  38828. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38829. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38830. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38831. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38832. import { Scene } from "babylonjs/scene";
  38833. import { Vector3 } from "babylonjs/Maths/math";
  38834. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38835. import "babylonjs/Cameras/RigModes/vrRigMode";
  38836. /**
  38837. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38838. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38839. */
  38840. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38841. /**
  38842. * Creates a new VRDeviceOrientationArcRotateCamera
  38843. * @param name defines camera name
  38844. * @param alpha defines the camera rotation along the logitudinal axis
  38845. * @param beta defines the camera rotation along the latitudinal axis
  38846. * @param radius defines the camera distance from its target
  38847. * @param target defines the camera target
  38848. * @param scene defines the scene the camera belongs to
  38849. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38850. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38851. */
  38852. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38853. /**
  38854. * Gets camera class name
  38855. * @returns VRDeviceOrientationArcRotateCamera
  38856. */
  38857. getClassName(): string;
  38858. }
  38859. }
  38860. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38861. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38862. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38863. import { Scene } from "babylonjs/scene";
  38864. import { Vector3 } from "babylonjs/Maths/math";
  38865. import "babylonjs/Cameras/RigModes/vrRigMode";
  38866. /**
  38867. * Camera used to simulate VR rendering (based on FreeCamera)
  38868. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38869. */
  38870. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38871. /**
  38872. * Creates a new VRDeviceOrientationFreeCamera
  38873. * @param name defines camera name
  38874. * @param position defines the start position of the camera
  38875. * @param scene defines the scene the camera belongs to
  38876. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38877. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38878. */
  38879. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38880. /**
  38881. * Gets camera class name
  38882. * @returns VRDeviceOrientationFreeCamera
  38883. */
  38884. getClassName(): string;
  38885. }
  38886. }
  38887. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38888. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38889. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38890. import { Scene } from "babylonjs/scene";
  38891. import { Vector3 } from "babylonjs/Maths/math";
  38892. /**
  38893. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38894. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38895. */
  38896. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38897. /**
  38898. * Creates a new VRDeviceOrientationGamepadCamera
  38899. * @param name defines camera name
  38900. * @param position defines the start position of the camera
  38901. * @param scene defines the scene the camera belongs to
  38902. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38903. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38904. */
  38905. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38906. /**
  38907. * Gets camera class name
  38908. * @returns VRDeviceOrientationGamepadCamera
  38909. */
  38910. getClassName(): string;
  38911. }
  38912. }
  38913. declare module "babylonjs/Gamepads/xboxGamepad" {
  38914. import { Observable } from "babylonjs/Misc/observable";
  38915. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38916. /**
  38917. * Defines supported buttons for XBox360 compatible gamepads
  38918. */
  38919. export enum Xbox360Button {
  38920. /** A */
  38921. A = 0,
  38922. /** B */
  38923. B = 1,
  38924. /** X */
  38925. X = 2,
  38926. /** Y */
  38927. Y = 3,
  38928. /** Start */
  38929. Start = 4,
  38930. /** Back */
  38931. Back = 5,
  38932. /** Left button */
  38933. LB = 6,
  38934. /** Right button */
  38935. RB = 7,
  38936. /** Left stick */
  38937. LeftStick = 8,
  38938. /** Right stick */
  38939. RightStick = 9
  38940. }
  38941. /** Defines values for XBox360 DPad */
  38942. export enum Xbox360Dpad {
  38943. /** Up */
  38944. Up = 0,
  38945. /** Down */
  38946. Down = 1,
  38947. /** Left */
  38948. Left = 2,
  38949. /** Right */
  38950. Right = 3
  38951. }
  38952. /**
  38953. * Defines a XBox360 gamepad
  38954. */
  38955. export class Xbox360Pad extends Gamepad {
  38956. private _leftTrigger;
  38957. private _rightTrigger;
  38958. private _onlefttriggerchanged;
  38959. private _onrighttriggerchanged;
  38960. private _onbuttondown;
  38961. private _onbuttonup;
  38962. private _ondpaddown;
  38963. private _ondpadup;
  38964. /** Observable raised when a button is pressed */
  38965. onButtonDownObservable: Observable<Xbox360Button>;
  38966. /** Observable raised when a button is released */
  38967. onButtonUpObservable: Observable<Xbox360Button>;
  38968. /** Observable raised when a pad is pressed */
  38969. onPadDownObservable: Observable<Xbox360Dpad>;
  38970. /** Observable raised when a pad is released */
  38971. onPadUpObservable: Observable<Xbox360Dpad>;
  38972. private _buttonA;
  38973. private _buttonB;
  38974. private _buttonX;
  38975. private _buttonY;
  38976. private _buttonBack;
  38977. private _buttonStart;
  38978. private _buttonLB;
  38979. private _buttonRB;
  38980. private _buttonLeftStick;
  38981. private _buttonRightStick;
  38982. private _dPadUp;
  38983. private _dPadDown;
  38984. private _dPadLeft;
  38985. private _dPadRight;
  38986. private _isXboxOnePad;
  38987. /**
  38988. * Creates a new XBox360 gamepad object
  38989. * @param id defines the id of this gamepad
  38990. * @param index defines its index
  38991. * @param gamepad defines the internal HTML gamepad object
  38992. * @param xboxOne defines if it is a XBox One gamepad
  38993. */
  38994. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38995. /**
  38996. * Defines the callback to call when left trigger is pressed
  38997. * @param callback defines the callback to use
  38998. */
  38999. onlefttriggerchanged(callback: (value: number) => void): void;
  39000. /**
  39001. * Defines the callback to call when right trigger is pressed
  39002. * @param callback defines the callback to use
  39003. */
  39004. onrighttriggerchanged(callback: (value: number) => void): void;
  39005. /**
  39006. * Gets the left trigger value
  39007. */
  39008. /**
  39009. * Sets the left trigger value
  39010. */
  39011. leftTrigger: number;
  39012. /**
  39013. * Gets the right trigger value
  39014. */
  39015. /**
  39016. * Sets the right trigger value
  39017. */
  39018. rightTrigger: number;
  39019. /**
  39020. * Defines the callback to call when a button is pressed
  39021. * @param callback defines the callback to use
  39022. */
  39023. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39024. /**
  39025. * Defines the callback to call when a button is released
  39026. * @param callback defines the callback to use
  39027. */
  39028. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39029. /**
  39030. * Defines the callback to call when a pad is pressed
  39031. * @param callback defines the callback to use
  39032. */
  39033. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39034. /**
  39035. * Defines the callback to call when a pad is released
  39036. * @param callback defines the callback to use
  39037. */
  39038. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39039. private _setButtonValue;
  39040. private _setDPadValue;
  39041. /**
  39042. * Gets the value of the `A` button
  39043. */
  39044. /**
  39045. * Sets the value of the `A` button
  39046. */
  39047. buttonA: number;
  39048. /**
  39049. * Gets the value of the `B` button
  39050. */
  39051. /**
  39052. * Sets the value of the `B` button
  39053. */
  39054. buttonB: number;
  39055. /**
  39056. * Gets the value of the `X` button
  39057. */
  39058. /**
  39059. * Sets the value of the `X` button
  39060. */
  39061. buttonX: number;
  39062. /**
  39063. * Gets the value of the `Y` button
  39064. */
  39065. /**
  39066. * Sets the value of the `Y` button
  39067. */
  39068. buttonY: number;
  39069. /**
  39070. * Gets the value of the `Start` button
  39071. */
  39072. /**
  39073. * Sets the value of the `Start` button
  39074. */
  39075. buttonStart: number;
  39076. /**
  39077. * Gets the value of the `Back` button
  39078. */
  39079. /**
  39080. * Sets the value of the `Back` button
  39081. */
  39082. buttonBack: number;
  39083. /**
  39084. * Gets the value of the `Left` button
  39085. */
  39086. /**
  39087. * Sets the value of the `Left` button
  39088. */
  39089. buttonLB: number;
  39090. /**
  39091. * Gets the value of the `Right` button
  39092. */
  39093. /**
  39094. * Sets the value of the `Right` button
  39095. */
  39096. buttonRB: number;
  39097. /**
  39098. * Gets the value of the Left joystick
  39099. */
  39100. /**
  39101. * Sets the value of the Left joystick
  39102. */
  39103. buttonLeftStick: number;
  39104. /**
  39105. * Gets the value of the Right joystick
  39106. */
  39107. /**
  39108. * Sets the value of the Right joystick
  39109. */
  39110. buttonRightStick: number;
  39111. /**
  39112. * Gets the value of D-pad up
  39113. */
  39114. /**
  39115. * Sets the value of D-pad up
  39116. */
  39117. dPadUp: number;
  39118. /**
  39119. * Gets the value of D-pad down
  39120. */
  39121. /**
  39122. * Sets the value of D-pad down
  39123. */
  39124. dPadDown: number;
  39125. /**
  39126. * Gets the value of D-pad left
  39127. */
  39128. /**
  39129. * Sets the value of D-pad left
  39130. */
  39131. dPadLeft: number;
  39132. /**
  39133. * Gets the value of D-pad right
  39134. */
  39135. /**
  39136. * Sets the value of D-pad right
  39137. */
  39138. dPadRight: number;
  39139. /**
  39140. * Force the gamepad to synchronize with device values
  39141. */
  39142. update(): void;
  39143. /**
  39144. * Disposes the gamepad
  39145. */
  39146. dispose(): void;
  39147. }
  39148. }
  39149. declare module "babylonjs/Materials/pushMaterial" {
  39150. import { Nullable } from "babylonjs/types";
  39151. import { Scene } from "babylonjs/scene";
  39152. import { Matrix } from "babylonjs/Maths/math";
  39153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39154. import { Mesh } from "babylonjs/Meshes/mesh";
  39155. import { Material } from "babylonjs/Materials/material";
  39156. import { Effect } from "babylonjs/Materials/effect";
  39157. /**
  39158. * Base class of materials working in push mode in babylon JS
  39159. * @hidden
  39160. */
  39161. export class PushMaterial extends Material {
  39162. protected _activeEffect: Effect;
  39163. protected _normalMatrix: Matrix;
  39164. /**
  39165. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39166. * This means that the material can keep using a previous shader while a new one is being compiled.
  39167. * This is mostly used when shader parallel compilation is supported (true by default)
  39168. */
  39169. allowShaderHotSwapping: boolean;
  39170. constructor(name: string, scene: Scene);
  39171. getEffect(): Effect;
  39172. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39173. /**
  39174. * Binds the given world matrix to the active effect
  39175. *
  39176. * @param world the matrix to bind
  39177. */
  39178. bindOnlyWorldMatrix(world: Matrix): void;
  39179. /**
  39180. * Binds the given normal matrix to the active effect
  39181. *
  39182. * @param normalMatrix the matrix to bind
  39183. */
  39184. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39185. bind(world: Matrix, mesh?: Mesh): void;
  39186. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39187. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39188. }
  39189. }
  39190. declare module "babylonjs/Materials/materialFlags" {
  39191. /**
  39192. * This groups all the flags used to control the materials channel.
  39193. */
  39194. export class MaterialFlags {
  39195. private static _DiffuseTextureEnabled;
  39196. /**
  39197. * Are diffuse textures enabled in the application.
  39198. */
  39199. static DiffuseTextureEnabled: boolean;
  39200. private static _AmbientTextureEnabled;
  39201. /**
  39202. * Are ambient textures enabled in the application.
  39203. */
  39204. static AmbientTextureEnabled: boolean;
  39205. private static _OpacityTextureEnabled;
  39206. /**
  39207. * Are opacity textures enabled in the application.
  39208. */
  39209. static OpacityTextureEnabled: boolean;
  39210. private static _ReflectionTextureEnabled;
  39211. /**
  39212. * Are reflection textures enabled in the application.
  39213. */
  39214. static ReflectionTextureEnabled: boolean;
  39215. private static _EmissiveTextureEnabled;
  39216. /**
  39217. * Are emissive textures enabled in the application.
  39218. */
  39219. static EmissiveTextureEnabled: boolean;
  39220. private static _SpecularTextureEnabled;
  39221. /**
  39222. * Are specular textures enabled in the application.
  39223. */
  39224. static SpecularTextureEnabled: boolean;
  39225. private static _BumpTextureEnabled;
  39226. /**
  39227. * Are bump textures enabled in the application.
  39228. */
  39229. static BumpTextureEnabled: boolean;
  39230. private static _LightmapTextureEnabled;
  39231. /**
  39232. * Are lightmap textures enabled in the application.
  39233. */
  39234. static LightmapTextureEnabled: boolean;
  39235. private static _RefractionTextureEnabled;
  39236. /**
  39237. * Are refraction textures enabled in the application.
  39238. */
  39239. static RefractionTextureEnabled: boolean;
  39240. private static _ColorGradingTextureEnabled;
  39241. /**
  39242. * Are color grading textures enabled in the application.
  39243. */
  39244. static ColorGradingTextureEnabled: boolean;
  39245. private static _FresnelEnabled;
  39246. /**
  39247. * Are fresnels enabled in the application.
  39248. */
  39249. static FresnelEnabled: boolean;
  39250. private static _ClearCoatTextureEnabled;
  39251. /**
  39252. * Are clear coat textures enabled in the application.
  39253. */
  39254. static ClearCoatTextureEnabled: boolean;
  39255. private static _ClearCoatBumpTextureEnabled;
  39256. /**
  39257. * Are clear coat bump textures enabled in the application.
  39258. */
  39259. static ClearCoatBumpTextureEnabled: boolean;
  39260. private static _ClearCoatTintTextureEnabled;
  39261. /**
  39262. * Are clear coat tint textures enabled in the application.
  39263. */
  39264. static ClearCoatTintTextureEnabled: boolean;
  39265. private static _SheenTextureEnabled;
  39266. /**
  39267. * Are sheen textures enabled in the application.
  39268. */
  39269. static SheenTextureEnabled: boolean;
  39270. private static _AnisotropicTextureEnabled;
  39271. /**
  39272. * Are anisotropic textures enabled in the application.
  39273. */
  39274. static AnisotropicTextureEnabled: boolean;
  39275. }
  39276. }
  39277. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39278. /** @hidden */
  39279. export var defaultFragmentDeclaration: {
  39280. name: string;
  39281. shader: string;
  39282. };
  39283. }
  39284. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39285. /** @hidden */
  39286. export var defaultUboDeclaration: {
  39287. name: string;
  39288. shader: string;
  39289. };
  39290. }
  39291. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39292. /** @hidden */
  39293. export var lightFragmentDeclaration: {
  39294. name: string;
  39295. shader: string;
  39296. };
  39297. }
  39298. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39299. /** @hidden */
  39300. export var lightUboDeclaration: {
  39301. name: string;
  39302. shader: string;
  39303. };
  39304. }
  39305. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39306. /** @hidden */
  39307. export var lightsFragmentFunctions: {
  39308. name: string;
  39309. shader: string;
  39310. };
  39311. }
  39312. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39313. /** @hidden */
  39314. export var shadowsFragmentFunctions: {
  39315. name: string;
  39316. shader: string;
  39317. };
  39318. }
  39319. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39320. /** @hidden */
  39321. export var fresnelFunction: {
  39322. name: string;
  39323. shader: string;
  39324. };
  39325. }
  39326. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39327. /** @hidden */
  39328. export var reflectionFunction: {
  39329. name: string;
  39330. shader: string;
  39331. };
  39332. }
  39333. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39334. /** @hidden */
  39335. export var bumpFragmentFunctions: {
  39336. name: string;
  39337. shader: string;
  39338. };
  39339. }
  39340. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39341. /** @hidden */
  39342. export var logDepthDeclaration: {
  39343. name: string;
  39344. shader: string;
  39345. };
  39346. }
  39347. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39348. /** @hidden */
  39349. export var bumpFragment: {
  39350. name: string;
  39351. shader: string;
  39352. };
  39353. }
  39354. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39355. /** @hidden */
  39356. export var depthPrePass: {
  39357. name: string;
  39358. shader: string;
  39359. };
  39360. }
  39361. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39362. /** @hidden */
  39363. export var lightFragment: {
  39364. name: string;
  39365. shader: string;
  39366. };
  39367. }
  39368. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39369. /** @hidden */
  39370. export var logDepthFragment: {
  39371. name: string;
  39372. shader: string;
  39373. };
  39374. }
  39375. declare module "babylonjs/Shaders/default.fragment" {
  39376. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39377. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39378. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39379. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39380. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39381. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39382. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39383. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39384. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39385. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39386. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39387. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39388. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39389. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39390. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39391. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39392. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39393. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39394. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39395. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39396. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39397. /** @hidden */
  39398. export var defaultPixelShader: {
  39399. name: string;
  39400. shader: string;
  39401. };
  39402. }
  39403. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39404. /** @hidden */
  39405. export var defaultVertexDeclaration: {
  39406. name: string;
  39407. shader: string;
  39408. };
  39409. }
  39410. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39411. /** @hidden */
  39412. export var bumpVertexDeclaration: {
  39413. name: string;
  39414. shader: string;
  39415. };
  39416. }
  39417. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39418. /** @hidden */
  39419. export var bumpVertex: {
  39420. name: string;
  39421. shader: string;
  39422. };
  39423. }
  39424. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39425. /** @hidden */
  39426. export var fogVertex: {
  39427. name: string;
  39428. shader: string;
  39429. };
  39430. }
  39431. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39432. /** @hidden */
  39433. export var shadowsVertex: {
  39434. name: string;
  39435. shader: string;
  39436. };
  39437. }
  39438. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39439. /** @hidden */
  39440. export var pointCloudVertex: {
  39441. name: string;
  39442. shader: string;
  39443. };
  39444. }
  39445. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39446. /** @hidden */
  39447. export var logDepthVertex: {
  39448. name: string;
  39449. shader: string;
  39450. };
  39451. }
  39452. declare module "babylonjs/Shaders/default.vertex" {
  39453. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39454. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39455. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39456. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39457. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39458. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39459. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39460. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39461. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39462. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39463. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39464. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39465. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39466. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39467. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39468. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39469. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39471. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39472. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39473. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39474. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39475. /** @hidden */
  39476. export var defaultVertexShader: {
  39477. name: string;
  39478. shader: string;
  39479. };
  39480. }
  39481. declare module "babylonjs/Materials/standardMaterial" {
  39482. import { SmartArray } from "babylonjs/Misc/smartArray";
  39483. import { IAnimatable } from "babylonjs/Misc/tools";
  39484. import { Nullable } from "babylonjs/types";
  39485. import { Scene } from "babylonjs/scene";
  39486. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39487. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39489. import { Mesh } from "babylonjs/Meshes/mesh";
  39490. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39491. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39492. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39493. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39494. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39495. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39496. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39497. import "babylonjs/Shaders/default.fragment";
  39498. import "babylonjs/Shaders/default.vertex";
  39499. /** @hidden */
  39500. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39501. MAINUV1: boolean;
  39502. MAINUV2: boolean;
  39503. DIFFUSE: boolean;
  39504. DIFFUSEDIRECTUV: number;
  39505. AMBIENT: boolean;
  39506. AMBIENTDIRECTUV: number;
  39507. OPACITY: boolean;
  39508. OPACITYDIRECTUV: number;
  39509. OPACITYRGB: boolean;
  39510. REFLECTION: boolean;
  39511. EMISSIVE: boolean;
  39512. EMISSIVEDIRECTUV: number;
  39513. SPECULAR: boolean;
  39514. SPECULARDIRECTUV: number;
  39515. BUMP: boolean;
  39516. BUMPDIRECTUV: number;
  39517. PARALLAX: boolean;
  39518. PARALLAXOCCLUSION: boolean;
  39519. SPECULAROVERALPHA: boolean;
  39520. CLIPPLANE: boolean;
  39521. CLIPPLANE2: boolean;
  39522. CLIPPLANE3: boolean;
  39523. CLIPPLANE4: boolean;
  39524. ALPHATEST: boolean;
  39525. DEPTHPREPASS: boolean;
  39526. ALPHAFROMDIFFUSE: boolean;
  39527. POINTSIZE: boolean;
  39528. FOG: boolean;
  39529. SPECULARTERM: boolean;
  39530. DIFFUSEFRESNEL: boolean;
  39531. OPACITYFRESNEL: boolean;
  39532. REFLECTIONFRESNEL: boolean;
  39533. REFRACTIONFRESNEL: boolean;
  39534. EMISSIVEFRESNEL: boolean;
  39535. FRESNEL: boolean;
  39536. NORMAL: boolean;
  39537. UV1: boolean;
  39538. UV2: boolean;
  39539. VERTEXCOLOR: boolean;
  39540. VERTEXALPHA: boolean;
  39541. NUM_BONE_INFLUENCERS: number;
  39542. BonesPerMesh: number;
  39543. BONETEXTURE: boolean;
  39544. INSTANCES: boolean;
  39545. GLOSSINESS: boolean;
  39546. ROUGHNESS: boolean;
  39547. EMISSIVEASILLUMINATION: boolean;
  39548. LINKEMISSIVEWITHDIFFUSE: boolean;
  39549. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39550. LIGHTMAP: boolean;
  39551. LIGHTMAPDIRECTUV: number;
  39552. OBJECTSPACE_NORMALMAP: boolean;
  39553. USELIGHTMAPASSHADOWMAP: boolean;
  39554. REFLECTIONMAP_3D: boolean;
  39555. REFLECTIONMAP_SPHERICAL: boolean;
  39556. REFLECTIONMAP_PLANAR: boolean;
  39557. REFLECTIONMAP_CUBIC: boolean;
  39558. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39559. REFLECTIONMAP_PROJECTION: boolean;
  39560. REFLECTIONMAP_SKYBOX: boolean;
  39561. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39562. REFLECTIONMAP_EXPLICIT: boolean;
  39563. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39564. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39565. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39566. INVERTCUBICMAP: boolean;
  39567. LOGARITHMICDEPTH: boolean;
  39568. REFRACTION: boolean;
  39569. REFRACTIONMAP_3D: boolean;
  39570. REFLECTIONOVERALPHA: boolean;
  39571. TWOSIDEDLIGHTING: boolean;
  39572. SHADOWFLOAT: boolean;
  39573. MORPHTARGETS: boolean;
  39574. MORPHTARGETS_NORMAL: boolean;
  39575. MORPHTARGETS_TANGENT: boolean;
  39576. NUM_MORPH_INFLUENCERS: number;
  39577. NONUNIFORMSCALING: boolean;
  39578. PREMULTIPLYALPHA: boolean;
  39579. IMAGEPROCESSING: boolean;
  39580. VIGNETTE: boolean;
  39581. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39582. VIGNETTEBLENDMODEOPAQUE: boolean;
  39583. TONEMAPPING: boolean;
  39584. TONEMAPPING_ACES: boolean;
  39585. CONTRAST: boolean;
  39586. COLORCURVES: boolean;
  39587. COLORGRADING: boolean;
  39588. COLORGRADING3D: boolean;
  39589. SAMPLER3DGREENDEPTH: boolean;
  39590. SAMPLER3DBGRMAP: boolean;
  39591. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39592. MULTIVIEW: boolean;
  39593. /**
  39594. * If the reflection texture on this material is in linear color space
  39595. * @hidden
  39596. */
  39597. IS_REFLECTION_LINEAR: boolean;
  39598. /**
  39599. * If the refraction texture on this material is in linear color space
  39600. * @hidden
  39601. */
  39602. IS_REFRACTION_LINEAR: boolean;
  39603. EXPOSURE: boolean;
  39604. constructor();
  39605. setReflectionMode(modeToEnable: string): void;
  39606. }
  39607. /**
  39608. * This is the default material used in Babylon. It is the best trade off between quality
  39609. * and performances.
  39610. * @see http://doc.babylonjs.com/babylon101/materials
  39611. */
  39612. export class StandardMaterial extends PushMaterial {
  39613. private _diffuseTexture;
  39614. /**
  39615. * The basic texture of the material as viewed under a light.
  39616. */
  39617. diffuseTexture: Nullable<BaseTexture>;
  39618. private _ambientTexture;
  39619. /**
  39620. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39621. */
  39622. ambientTexture: Nullable<BaseTexture>;
  39623. private _opacityTexture;
  39624. /**
  39625. * Define the transparency of the material from a texture.
  39626. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39627. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39628. */
  39629. opacityTexture: Nullable<BaseTexture>;
  39630. private _reflectionTexture;
  39631. /**
  39632. * Define the texture used to display the reflection.
  39633. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39634. */
  39635. reflectionTexture: Nullable<BaseTexture>;
  39636. private _emissiveTexture;
  39637. /**
  39638. * Define texture of the material as if self lit.
  39639. * This will be mixed in the final result even in the absence of light.
  39640. */
  39641. emissiveTexture: Nullable<BaseTexture>;
  39642. private _specularTexture;
  39643. /**
  39644. * Define how the color and intensity of the highlight given by the light in the material.
  39645. */
  39646. specularTexture: Nullable<BaseTexture>;
  39647. private _bumpTexture;
  39648. /**
  39649. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39650. * 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.
  39651. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39652. */
  39653. bumpTexture: Nullable<BaseTexture>;
  39654. private _lightmapTexture;
  39655. /**
  39656. * Complex lighting can be computationally expensive to compute at runtime.
  39657. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39658. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39659. */
  39660. lightmapTexture: Nullable<BaseTexture>;
  39661. private _refractionTexture;
  39662. /**
  39663. * Define the texture used to display the refraction.
  39664. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39665. */
  39666. refractionTexture: Nullable<BaseTexture>;
  39667. /**
  39668. * The color of the material lit by the environmental background lighting.
  39669. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39670. */
  39671. ambientColor: Color3;
  39672. /**
  39673. * The basic color of the material as viewed under a light.
  39674. */
  39675. diffuseColor: Color3;
  39676. /**
  39677. * Define how the color and intensity of the highlight given by the light in the material.
  39678. */
  39679. specularColor: Color3;
  39680. /**
  39681. * Define the color of the material as if self lit.
  39682. * This will be mixed in the final result even in the absence of light.
  39683. */
  39684. emissiveColor: Color3;
  39685. /**
  39686. * Defines how sharp are the highlights in the material.
  39687. * The bigger the value the sharper giving a more glossy feeling to the result.
  39688. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39689. */
  39690. specularPower: number;
  39691. private _useAlphaFromDiffuseTexture;
  39692. /**
  39693. * Does the transparency come from the diffuse texture alpha channel.
  39694. */
  39695. useAlphaFromDiffuseTexture: boolean;
  39696. private _useEmissiveAsIllumination;
  39697. /**
  39698. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39699. */
  39700. useEmissiveAsIllumination: boolean;
  39701. private _linkEmissiveWithDiffuse;
  39702. /**
  39703. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39704. * the emissive level when the final color is close to one.
  39705. */
  39706. linkEmissiveWithDiffuse: boolean;
  39707. private _useSpecularOverAlpha;
  39708. /**
  39709. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39710. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39711. */
  39712. useSpecularOverAlpha: boolean;
  39713. private _useReflectionOverAlpha;
  39714. /**
  39715. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39716. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39717. */
  39718. useReflectionOverAlpha: boolean;
  39719. private _disableLighting;
  39720. /**
  39721. * Does lights from the scene impacts this material.
  39722. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39723. */
  39724. disableLighting: boolean;
  39725. private _useObjectSpaceNormalMap;
  39726. /**
  39727. * Allows using an object space normal map (instead of tangent space).
  39728. */
  39729. useObjectSpaceNormalMap: boolean;
  39730. private _useParallax;
  39731. /**
  39732. * Is parallax enabled or not.
  39733. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39734. */
  39735. useParallax: boolean;
  39736. private _useParallaxOcclusion;
  39737. /**
  39738. * Is parallax occlusion enabled or not.
  39739. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39740. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39741. */
  39742. useParallaxOcclusion: boolean;
  39743. /**
  39744. * 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.
  39745. */
  39746. parallaxScaleBias: number;
  39747. private _roughness;
  39748. /**
  39749. * Helps to define how blurry the reflections should appears in the material.
  39750. */
  39751. roughness: number;
  39752. /**
  39753. * In case of refraction, define the value of the indice of refraction.
  39754. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39755. */
  39756. indexOfRefraction: number;
  39757. /**
  39758. * Invert the refraction texture alongside the y axis.
  39759. * It can be useful with procedural textures or probe for instance.
  39760. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39761. */
  39762. invertRefractionY: boolean;
  39763. /**
  39764. * Defines the alpha limits in alpha test mode.
  39765. */
  39766. alphaCutOff: number;
  39767. private _useLightmapAsShadowmap;
  39768. /**
  39769. * In case of light mapping, define whether the map contains light or shadow informations.
  39770. */
  39771. useLightmapAsShadowmap: boolean;
  39772. private _diffuseFresnelParameters;
  39773. /**
  39774. * Define the diffuse fresnel parameters of the material.
  39775. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39776. */
  39777. diffuseFresnelParameters: FresnelParameters;
  39778. private _opacityFresnelParameters;
  39779. /**
  39780. * Define the opacity fresnel parameters of the material.
  39781. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39782. */
  39783. opacityFresnelParameters: FresnelParameters;
  39784. private _reflectionFresnelParameters;
  39785. /**
  39786. * Define the reflection fresnel parameters of the material.
  39787. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39788. */
  39789. reflectionFresnelParameters: FresnelParameters;
  39790. private _refractionFresnelParameters;
  39791. /**
  39792. * Define the refraction fresnel parameters of the material.
  39793. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39794. */
  39795. refractionFresnelParameters: FresnelParameters;
  39796. private _emissiveFresnelParameters;
  39797. /**
  39798. * Define the emissive fresnel parameters of the material.
  39799. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39800. */
  39801. emissiveFresnelParameters: FresnelParameters;
  39802. private _useReflectionFresnelFromSpecular;
  39803. /**
  39804. * If true automatically deducts the fresnels values from the material specularity.
  39805. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39806. */
  39807. useReflectionFresnelFromSpecular: boolean;
  39808. private _useGlossinessFromSpecularMapAlpha;
  39809. /**
  39810. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39811. */
  39812. useGlossinessFromSpecularMapAlpha: boolean;
  39813. private _maxSimultaneousLights;
  39814. /**
  39815. * Defines the maximum number of lights that can be used in the material
  39816. */
  39817. maxSimultaneousLights: number;
  39818. private _invertNormalMapX;
  39819. /**
  39820. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39821. */
  39822. invertNormalMapX: boolean;
  39823. private _invertNormalMapY;
  39824. /**
  39825. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39826. */
  39827. invertNormalMapY: boolean;
  39828. private _twoSidedLighting;
  39829. /**
  39830. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39831. */
  39832. twoSidedLighting: boolean;
  39833. /**
  39834. * Default configuration related to image processing available in the standard Material.
  39835. */
  39836. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39837. /**
  39838. * Gets the image processing configuration used either in this material.
  39839. */
  39840. /**
  39841. * Sets the Default image processing configuration used either in the this material.
  39842. *
  39843. * If sets to null, the scene one is in use.
  39844. */
  39845. imageProcessingConfiguration: ImageProcessingConfiguration;
  39846. /**
  39847. * Keep track of the image processing observer to allow dispose and replace.
  39848. */
  39849. private _imageProcessingObserver;
  39850. /**
  39851. * Attaches a new image processing configuration to the Standard Material.
  39852. * @param configuration
  39853. */
  39854. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39855. /**
  39856. * Gets wether the color curves effect is enabled.
  39857. */
  39858. /**
  39859. * Sets wether the color curves effect is enabled.
  39860. */
  39861. cameraColorCurvesEnabled: boolean;
  39862. /**
  39863. * Gets wether the color grading effect is enabled.
  39864. */
  39865. /**
  39866. * Gets wether the color grading effect is enabled.
  39867. */
  39868. cameraColorGradingEnabled: boolean;
  39869. /**
  39870. * Gets wether tonemapping is enabled or not.
  39871. */
  39872. /**
  39873. * Sets wether tonemapping is enabled or not
  39874. */
  39875. cameraToneMappingEnabled: boolean;
  39876. /**
  39877. * The camera exposure used on this material.
  39878. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39879. * This corresponds to a photographic exposure.
  39880. */
  39881. /**
  39882. * The camera exposure used on this material.
  39883. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39884. * This corresponds to a photographic exposure.
  39885. */
  39886. cameraExposure: number;
  39887. /**
  39888. * Gets The camera contrast used on this material.
  39889. */
  39890. /**
  39891. * Sets The camera contrast used on this material.
  39892. */
  39893. cameraContrast: number;
  39894. /**
  39895. * Gets the Color Grading 2D Lookup Texture.
  39896. */
  39897. /**
  39898. * Sets the Color Grading 2D Lookup Texture.
  39899. */
  39900. cameraColorGradingTexture: Nullable<BaseTexture>;
  39901. /**
  39902. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39903. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39904. * 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;
  39905. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39906. */
  39907. /**
  39908. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39909. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39910. * 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;
  39911. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39912. */
  39913. cameraColorCurves: Nullable<ColorCurves>;
  39914. /**
  39915. * Custom callback helping to override the default shader used in the material.
  39916. */
  39917. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39918. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39919. protected _worldViewProjectionMatrix: Matrix;
  39920. protected _globalAmbientColor: Color3;
  39921. protected _useLogarithmicDepth: boolean;
  39922. /**
  39923. * Instantiates a new standard material.
  39924. * This is the default material used in Babylon. It is the best trade off between quality
  39925. * and performances.
  39926. * @see http://doc.babylonjs.com/babylon101/materials
  39927. * @param name Define the name of the material in the scene
  39928. * @param scene Define the scene the material belong to
  39929. */
  39930. constructor(name: string, scene: Scene);
  39931. /**
  39932. * Gets a boolean indicating that current material needs to register RTT
  39933. */
  39934. readonly hasRenderTargetTextures: boolean;
  39935. /**
  39936. * Gets the current class name of the material e.g. "StandardMaterial"
  39937. * Mainly use in serialization.
  39938. * @returns the class name
  39939. */
  39940. getClassName(): string;
  39941. /**
  39942. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39943. * You can try switching to logarithmic depth.
  39944. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39945. */
  39946. useLogarithmicDepth: boolean;
  39947. /**
  39948. * Specifies if the material will require alpha blending
  39949. * @returns a boolean specifying if alpha blending is needed
  39950. */
  39951. needAlphaBlending(): boolean;
  39952. /**
  39953. * Specifies if this material should be rendered in alpha test mode
  39954. * @returns a boolean specifying if an alpha test is needed.
  39955. */
  39956. needAlphaTesting(): boolean;
  39957. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39958. /**
  39959. * Get the texture used for alpha test purpose.
  39960. * @returns the diffuse texture in case of the standard material.
  39961. */
  39962. getAlphaTestTexture(): Nullable<BaseTexture>;
  39963. /**
  39964. * Get if the submesh is ready to be used and all its information available.
  39965. * Child classes can use it to update shaders
  39966. * @param mesh defines the mesh to check
  39967. * @param subMesh defines which submesh to check
  39968. * @param useInstances specifies that instances should be used
  39969. * @returns a boolean indicating that the submesh is ready or not
  39970. */
  39971. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39972. /**
  39973. * Builds the material UBO layouts.
  39974. * Used internally during the effect preparation.
  39975. */
  39976. buildUniformLayout(): void;
  39977. /**
  39978. * Unbinds the material from the mesh
  39979. */
  39980. unbind(): void;
  39981. /**
  39982. * Binds the submesh to this material by preparing the effect and shader to draw
  39983. * @param world defines the world transformation matrix
  39984. * @param mesh defines the mesh containing the submesh
  39985. * @param subMesh defines the submesh to bind the material to
  39986. */
  39987. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39988. /**
  39989. * Get the list of animatables in the material.
  39990. * @returns the list of animatables object used in the material
  39991. */
  39992. getAnimatables(): IAnimatable[];
  39993. /**
  39994. * Gets the active textures from the material
  39995. * @returns an array of textures
  39996. */
  39997. getActiveTextures(): BaseTexture[];
  39998. /**
  39999. * Specifies if the material uses a texture
  40000. * @param texture defines the texture to check against the material
  40001. * @returns a boolean specifying if the material uses the texture
  40002. */
  40003. hasTexture(texture: BaseTexture): boolean;
  40004. /**
  40005. * Disposes the material
  40006. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40007. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40008. */
  40009. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40010. /**
  40011. * Makes a duplicate of the material, and gives it a new name
  40012. * @param name defines the new name for the duplicated material
  40013. * @returns the cloned material
  40014. */
  40015. clone(name: string): StandardMaterial;
  40016. /**
  40017. * Serializes this material in a JSON representation
  40018. * @returns the serialized material object
  40019. */
  40020. serialize(): any;
  40021. /**
  40022. * Creates a standard material from parsed material data
  40023. * @param source defines the JSON representation of the material
  40024. * @param scene defines the hosting scene
  40025. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40026. * @returns a new standard material
  40027. */
  40028. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40029. /**
  40030. * Are diffuse textures enabled in the application.
  40031. */
  40032. static DiffuseTextureEnabled: boolean;
  40033. /**
  40034. * Are ambient textures enabled in the application.
  40035. */
  40036. static AmbientTextureEnabled: boolean;
  40037. /**
  40038. * Are opacity textures enabled in the application.
  40039. */
  40040. static OpacityTextureEnabled: boolean;
  40041. /**
  40042. * Are reflection textures enabled in the application.
  40043. */
  40044. static ReflectionTextureEnabled: boolean;
  40045. /**
  40046. * Are emissive textures enabled in the application.
  40047. */
  40048. static EmissiveTextureEnabled: boolean;
  40049. /**
  40050. * Are specular textures enabled in the application.
  40051. */
  40052. static SpecularTextureEnabled: boolean;
  40053. /**
  40054. * Are bump textures enabled in the application.
  40055. */
  40056. static BumpTextureEnabled: boolean;
  40057. /**
  40058. * Are lightmap textures enabled in the application.
  40059. */
  40060. static LightmapTextureEnabled: boolean;
  40061. /**
  40062. * Are refraction textures enabled in the application.
  40063. */
  40064. static RefractionTextureEnabled: boolean;
  40065. /**
  40066. * Are color grading textures enabled in the application.
  40067. */
  40068. static ColorGradingTextureEnabled: boolean;
  40069. /**
  40070. * Are fresnels enabled in the application.
  40071. */
  40072. static FresnelEnabled: boolean;
  40073. }
  40074. }
  40075. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40076. import { Scene } from "babylonjs/scene";
  40077. import { Texture } from "babylonjs/Materials/Textures/texture";
  40078. /**
  40079. * A class extending Texture allowing drawing on a texture
  40080. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40081. */
  40082. export class DynamicTexture extends Texture {
  40083. private _generateMipMaps;
  40084. private _canvas;
  40085. private _context;
  40086. private _engine;
  40087. /**
  40088. * Creates a DynamicTexture
  40089. * @param name defines the name of the texture
  40090. * @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
  40091. * @param scene defines the scene where you want the texture
  40092. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40093. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40094. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40095. */
  40096. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40097. /**
  40098. * Get the current class name of the texture useful for serialization or dynamic coding.
  40099. * @returns "DynamicTexture"
  40100. */
  40101. getClassName(): string;
  40102. /**
  40103. * Gets the current state of canRescale
  40104. */
  40105. readonly canRescale: boolean;
  40106. private _recreate;
  40107. /**
  40108. * Scales the texture
  40109. * @param ratio the scale factor to apply to both width and height
  40110. */
  40111. scale(ratio: number): void;
  40112. /**
  40113. * Resizes the texture
  40114. * @param width the new width
  40115. * @param height the new height
  40116. */
  40117. scaleTo(width: number, height: number): void;
  40118. /**
  40119. * Gets the context of the canvas used by the texture
  40120. * @returns the canvas context of the dynamic texture
  40121. */
  40122. getContext(): CanvasRenderingContext2D;
  40123. /**
  40124. * Clears the texture
  40125. */
  40126. clear(): void;
  40127. /**
  40128. * Updates the texture
  40129. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40130. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40131. */
  40132. update(invertY?: boolean, premulAlpha?: boolean): void;
  40133. /**
  40134. * Draws text onto the texture
  40135. * @param text defines the text to be drawn
  40136. * @param x defines the placement of the text from the left
  40137. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40138. * @param font defines the font to be used with font-style, font-size, font-name
  40139. * @param color defines the color used for the text
  40140. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40141. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40142. * @param update defines whether texture is immediately update (default is true)
  40143. */
  40144. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40145. /**
  40146. * Clones the texture
  40147. * @returns the clone of the texture.
  40148. */
  40149. clone(): DynamicTexture;
  40150. /**
  40151. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40152. * @returns a serialized dynamic texture object
  40153. */
  40154. serialize(): any;
  40155. /** @hidden */
  40156. _rebuild(): void;
  40157. }
  40158. }
  40159. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40160. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40161. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40162. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40163. /** @hidden */
  40164. export var imageProcessingPixelShader: {
  40165. name: string;
  40166. shader: string;
  40167. };
  40168. }
  40169. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40170. import { Nullable } from "babylonjs/types";
  40171. import { Color4 } from "babylonjs/Maths/math";
  40172. import { Camera } from "babylonjs/Cameras/camera";
  40173. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40174. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40175. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40176. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40177. import { Engine } from "babylonjs/Engines/engine";
  40178. import "babylonjs/Shaders/imageProcessing.fragment";
  40179. import "babylonjs/Shaders/postprocess.vertex";
  40180. /**
  40181. * ImageProcessingPostProcess
  40182. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40183. */
  40184. export class ImageProcessingPostProcess extends PostProcess {
  40185. /**
  40186. * Default configuration related to image processing available in the PBR Material.
  40187. */
  40188. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40189. /**
  40190. * Gets the image processing configuration used either in this material.
  40191. */
  40192. /**
  40193. * Sets the Default image processing configuration used either in the this material.
  40194. *
  40195. * If sets to null, the scene one is in use.
  40196. */
  40197. imageProcessingConfiguration: ImageProcessingConfiguration;
  40198. /**
  40199. * Keep track of the image processing observer to allow dispose and replace.
  40200. */
  40201. private _imageProcessingObserver;
  40202. /**
  40203. * Attaches a new image processing configuration to the PBR Material.
  40204. * @param configuration
  40205. */
  40206. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40207. /**
  40208. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40209. */
  40210. /**
  40211. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40212. */
  40213. colorCurves: Nullable<ColorCurves>;
  40214. /**
  40215. * Gets wether the color curves effect is enabled.
  40216. */
  40217. /**
  40218. * Sets wether the color curves effect is enabled.
  40219. */
  40220. colorCurvesEnabled: boolean;
  40221. /**
  40222. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40223. */
  40224. /**
  40225. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40226. */
  40227. colorGradingTexture: Nullable<BaseTexture>;
  40228. /**
  40229. * Gets wether the color grading effect is enabled.
  40230. */
  40231. /**
  40232. * Gets wether the color grading effect is enabled.
  40233. */
  40234. colorGradingEnabled: boolean;
  40235. /**
  40236. * Gets exposure used in the effect.
  40237. */
  40238. /**
  40239. * Sets exposure used in the effect.
  40240. */
  40241. exposure: number;
  40242. /**
  40243. * Gets wether tonemapping is enabled or not.
  40244. */
  40245. /**
  40246. * Sets wether tonemapping is enabled or not
  40247. */
  40248. toneMappingEnabled: boolean;
  40249. /**
  40250. * Gets the type of tone mapping effect.
  40251. */
  40252. /**
  40253. * Sets the type of tone mapping effect.
  40254. */
  40255. toneMappingType: number;
  40256. /**
  40257. * Gets contrast used in the effect.
  40258. */
  40259. /**
  40260. * Sets contrast used in the effect.
  40261. */
  40262. contrast: number;
  40263. /**
  40264. * Gets Vignette stretch size.
  40265. */
  40266. /**
  40267. * Sets Vignette stretch size.
  40268. */
  40269. vignetteStretch: number;
  40270. /**
  40271. * Gets Vignette centre X Offset.
  40272. */
  40273. /**
  40274. * Sets Vignette centre X Offset.
  40275. */
  40276. vignetteCentreX: number;
  40277. /**
  40278. * Gets Vignette centre Y Offset.
  40279. */
  40280. /**
  40281. * Sets Vignette centre Y Offset.
  40282. */
  40283. vignetteCentreY: number;
  40284. /**
  40285. * Gets Vignette weight or intensity of the vignette effect.
  40286. */
  40287. /**
  40288. * Sets Vignette weight or intensity of the vignette effect.
  40289. */
  40290. vignetteWeight: number;
  40291. /**
  40292. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40293. * if vignetteEnabled is set to true.
  40294. */
  40295. /**
  40296. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40297. * if vignetteEnabled is set to true.
  40298. */
  40299. vignetteColor: Color4;
  40300. /**
  40301. * Gets Camera field of view used by the Vignette effect.
  40302. */
  40303. /**
  40304. * Sets Camera field of view used by the Vignette effect.
  40305. */
  40306. vignetteCameraFov: number;
  40307. /**
  40308. * Gets the vignette blend mode allowing different kind of effect.
  40309. */
  40310. /**
  40311. * Sets the vignette blend mode allowing different kind of effect.
  40312. */
  40313. vignetteBlendMode: number;
  40314. /**
  40315. * Gets wether the vignette effect is enabled.
  40316. */
  40317. /**
  40318. * Sets wether the vignette effect is enabled.
  40319. */
  40320. vignetteEnabled: boolean;
  40321. private _fromLinearSpace;
  40322. /**
  40323. * Gets wether the input of the processing is in Gamma or Linear Space.
  40324. */
  40325. /**
  40326. * Sets wether the input of the processing is in Gamma or Linear Space.
  40327. */
  40328. fromLinearSpace: boolean;
  40329. /**
  40330. * Defines cache preventing GC.
  40331. */
  40332. private _defines;
  40333. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40334. /**
  40335. * "ImageProcessingPostProcess"
  40336. * @returns "ImageProcessingPostProcess"
  40337. */
  40338. getClassName(): string;
  40339. protected _updateParameters(): void;
  40340. dispose(camera?: Camera): void;
  40341. }
  40342. }
  40343. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40344. import { Scene } from "babylonjs/scene";
  40345. import { Color3 } from "babylonjs/Maths/math";
  40346. import { Mesh } from "babylonjs/Meshes/mesh";
  40347. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40348. /**
  40349. * Class containing static functions to help procedurally build meshes
  40350. */
  40351. export class GroundBuilder {
  40352. /**
  40353. * Creates a ground mesh
  40354. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40355. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40357. * @param name defines the name of the mesh
  40358. * @param options defines the options used to create the mesh
  40359. * @param scene defines the hosting scene
  40360. * @returns the ground mesh
  40361. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40362. */
  40363. static CreateGround(name: string, options: {
  40364. width?: number;
  40365. height?: number;
  40366. subdivisions?: number;
  40367. subdivisionsX?: number;
  40368. subdivisionsY?: number;
  40369. updatable?: boolean;
  40370. }, scene: any): Mesh;
  40371. /**
  40372. * Creates a tiled ground mesh
  40373. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40374. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40375. * * 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
  40376. * * 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
  40377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40378. * @param name defines the name of the mesh
  40379. * @param options defines the options used to create the mesh
  40380. * @param scene defines the hosting scene
  40381. * @returns the tiled ground mesh
  40382. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40383. */
  40384. static CreateTiledGround(name: string, options: {
  40385. xmin: number;
  40386. zmin: number;
  40387. xmax: number;
  40388. zmax: number;
  40389. subdivisions?: {
  40390. w: number;
  40391. h: number;
  40392. };
  40393. precision?: {
  40394. w: number;
  40395. h: number;
  40396. };
  40397. updatable?: boolean;
  40398. }, scene: Scene): Mesh;
  40399. /**
  40400. * Creates a ground mesh from a height map
  40401. * * The parameter `url` sets the URL of the height map image resource.
  40402. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40403. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40404. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40405. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40406. * * 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.
  40407. * * 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).
  40408. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40410. * @param name defines the name of the mesh
  40411. * @param url defines the url to the height map
  40412. * @param options defines the options used to create the mesh
  40413. * @param scene defines the hosting scene
  40414. * @returns the ground mesh
  40415. * @see https://doc.babylonjs.com/babylon101/height_map
  40416. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40417. */
  40418. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40419. width?: number;
  40420. height?: number;
  40421. subdivisions?: number;
  40422. minHeight?: number;
  40423. maxHeight?: number;
  40424. colorFilter?: Color3;
  40425. alphaFilter?: number;
  40426. updatable?: boolean;
  40427. onReady?: (mesh: GroundMesh) => void;
  40428. }, scene: Scene): GroundMesh;
  40429. }
  40430. }
  40431. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40432. import { Vector4 } from "babylonjs/Maths/math";
  40433. import { Mesh } from "babylonjs/Meshes/mesh";
  40434. /**
  40435. * Class containing static functions to help procedurally build meshes
  40436. */
  40437. export class TorusBuilder {
  40438. /**
  40439. * Creates a torus mesh
  40440. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40441. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40442. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40444. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40446. * @param name defines the name of the mesh
  40447. * @param options defines the options used to create the mesh
  40448. * @param scene defines the hosting scene
  40449. * @returns the torus mesh
  40450. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40451. */
  40452. static CreateTorus(name: string, options: {
  40453. diameter?: number;
  40454. thickness?: number;
  40455. tessellation?: number;
  40456. updatable?: boolean;
  40457. sideOrientation?: number;
  40458. frontUVs?: Vector4;
  40459. backUVs?: Vector4;
  40460. }, scene: any): Mesh;
  40461. }
  40462. }
  40463. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40464. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40465. import { Mesh } from "babylonjs/Meshes/mesh";
  40466. /**
  40467. * Class containing static functions to help procedurally build meshes
  40468. */
  40469. export class CylinderBuilder {
  40470. /**
  40471. * Creates a cylinder or a cone mesh
  40472. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40473. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40474. * * 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.
  40475. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40476. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40477. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40478. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40479. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40480. * * 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).
  40481. * * 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
  40482. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40483. * * 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
  40484. * * 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.
  40485. * * If `enclose` is false, a ring surface is one element.
  40486. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40487. * * 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
  40488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40491. * @param name defines the name of the mesh
  40492. * @param options defines the options used to create the mesh
  40493. * @param scene defines the hosting scene
  40494. * @returns the cylinder mesh
  40495. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40496. */
  40497. static CreateCylinder(name: string, options: {
  40498. height?: number;
  40499. diameterTop?: number;
  40500. diameterBottom?: number;
  40501. diameter?: number;
  40502. tessellation?: number;
  40503. subdivisions?: number;
  40504. arc?: number;
  40505. faceColors?: Color4[];
  40506. faceUV?: Vector4[];
  40507. updatable?: boolean;
  40508. hasRings?: boolean;
  40509. enclose?: boolean;
  40510. sideOrientation?: number;
  40511. frontUVs?: Vector4;
  40512. backUVs?: Vector4;
  40513. }, scene: any): Mesh;
  40514. }
  40515. }
  40516. declare module "babylonjs/Gamepads/gamepadManager" {
  40517. import { Observable } from "babylonjs/Misc/observable";
  40518. import { Nullable } from "babylonjs/types";
  40519. import { Scene } from "babylonjs/scene";
  40520. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40521. /**
  40522. * Manager for handling gamepads
  40523. */
  40524. export class GamepadManager {
  40525. private _scene?;
  40526. private _babylonGamepads;
  40527. private _oneGamepadConnected;
  40528. /** @hidden */
  40529. _isMonitoring: boolean;
  40530. private _gamepadEventSupported;
  40531. private _gamepadSupport;
  40532. /**
  40533. * observable to be triggered when the gamepad controller has been connected
  40534. */
  40535. onGamepadConnectedObservable: Observable<Gamepad>;
  40536. /**
  40537. * observable to be triggered when the gamepad controller has been disconnected
  40538. */
  40539. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40540. private _onGamepadConnectedEvent;
  40541. private _onGamepadDisconnectedEvent;
  40542. /**
  40543. * Initializes the gamepad manager
  40544. * @param _scene BabylonJS scene
  40545. */
  40546. constructor(_scene?: Scene | undefined);
  40547. /**
  40548. * The gamepads in the game pad manager
  40549. */
  40550. readonly gamepads: Gamepad[];
  40551. /**
  40552. * Get the gamepad controllers based on type
  40553. * @param type The type of gamepad controller
  40554. * @returns Nullable gamepad
  40555. */
  40556. getGamepadByType(type?: number): Nullable<Gamepad>;
  40557. /**
  40558. * Disposes the gamepad manager
  40559. */
  40560. dispose(): void;
  40561. private _addNewGamepad;
  40562. private _startMonitoringGamepads;
  40563. private _stopMonitoringGamepads;
  40564. /** @hidden */
  40565. _checkGamepadsStatus(): void;
  40566. private _updateGamepadObjects;
  40567. }
  40568. }
  40569. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40570. import { Nullable } from "babylonjs/types";
  40571. import { Scene } from "babylonjs/scene";
  40572. import { ISceneComponent } from "babylonjs/sceneComponent";
  40573. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40574. module "babylonjs/scene" {
  40575. interface Scene {
  40576. /** @hidden */
  40577. _gamepadManager: Nullable<GamepadManager>;
  40578. /**
  40579. * Gets the gamepad manager associated with the scene
  40580. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40581. */
  40582. gamepadManager: GamepadManager;
  40583. }
  40584. }
  40585. module "babylonjs/Cameras/freeCameraInputsManager" {
  40586. /**
  40587. * Interface representing a free camera inputs manager
  40588. */
  40589. interface FreeCameraInputsManager {
  40590. /**
  40591. * Adds gamepad input support to the FreeCameraInputsManager.
  40592. * @returns the FreeCameraInputsManager
  40593. */
  40594. addGamepad(): FreeCameraInputsManager;
  40595. }
  40596. }
  40597. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40598. /**
  40599. * Interface representing an arc rotate camera inputs manager
  40600. */
  40601. interface ArcRotateCameraInputsManager {
  40602. /**
  40603. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40604. * @returns the camera inputs manager
  40605. */
  40606. addGamepad(): ArcRotateCameraInputsManager;
  40607. }
  40608. }
  40609. /**
  40610. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40611. */
  40612. export class GamepadSystemSceneComponent implements ISceneComponent {
  40613. /**
  40614. * The component name helpfull to identify the component in the list of scene components.
  40615. */
  40616. readonly name: string;
  40617. /**
  40618. * The scene the component belongs to.
  40619. */
  40620. scene: Scene;
  40621. /**
  40622. * Creates a new instance of the component for the given scene
  40623. * @param scene Defines the scene to register the component in
  40624. */
  40625. constructor(scene: Scene);
  40626. /**
  40627. * Registers the component in a given scene
  40628. */
  40629. register(): void;
  40630. /**
  40631. * Rebuilds the elements related to this component in case of
  40632. * context lost for instance.
  40633. */
  40634. rebuild(): void;
  40635. /**
  40636. * Disposes the component and the associated ressources
  40637. */
  40638. dispose(): void;
  40639. private _beforeCameraUpdate;
  40640. }
  40641. }
  40642. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40643. import { Observable } from "babylonjs/Misc/observable";
  40644. import { Nullable } from "babylonjs/types";
  40645. import { Camera } from "babylonjs/Cameras/camera";
  40646. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40647. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40648. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40649. import { Scene } from "babylonjs/scene";
  40650. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40651. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40653. import { Mesh } from "babylonjs/Meshes/mesh";
  40654. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40655. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40656. import "babylonjs/Meshes/Builders/groundBuilder";
  40657. import "babylonjs/Meshes/Builders/torusBuilder";
  40658. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40659. import "babylonjs/Gamepads/gamepadSceneComponent";
  40660. import "babylonjs/Animations/animatable";
  40661. /**
  40662. * Options to modify the vr teleportation behavior.
  40663. */
  40664. export interface VRTeleportationOptions {
  40665. /**
  40666. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40667. */
  40668. floorMeshName?: string;
  40669. /**
  40670. * A list of meshes to be used as the teleportation floor. (default: empty)
  40671. */
  40672. floorMeshes?: Mesh[];
  40673. }
  40674. /**
  40675. * Options to modify the vr experience helper's behavior.
  40676. */
  40677. export interface VRExperienceHelperOptions extends WebVROptions {
  40678. /**
  40679. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40680. */
  40681. createDeviceOrientationCamera?: boolean;
  40682. /**
  40683. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40684. */
  40685. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40686. /**
  40687. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40688. */
  40689. laserToggle?: boolean;
  40690. /**
  40691. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40692. */
  40693. floorMeshes?: Mesh[];
  40694. /**
  40695. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40696. */
  40697. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40698. }
  40699. /**
  40700. * Event containing information after VR has been entered
  40701. */
  40702. export class OnAfterEnteringVRObservableEvent {
  40703. /**
  40704. * If entering vr was successful
  40705. */
  40706. success: boolean;
  40707. }
  40708. /**
  40709. * Helps to quickly add VR support to an existing scene.
  40710. * See http://doc.babylonjs.com/how_to/webvr_helper
  40711. */
  40712. export class VRExperienceHelper {
  40713. /** Options to modify the vr experience helper's behavior. */
  40714. webVROptions: VRExperienceHelperOptions;
  40715. private _scene;
  40716. private _position;
  40717. private _btnVR;
  40718. private _btnVRDisplayed;
  40719. private _webVRsupported;
  40720. private _webVRready;
  40721. private _webVRrequesting;
  40722. private _webVRpresenting;
  40723. private _hasEnteredVR;
  40724. private _fullscreenVRpresenting;
  40725. private _canvas;
  40726. private _webVRCamera;
  40727. private _vrDeviceOrientationCamera;
  40728. private _deviceOrientationCamera;
  40729. private _existingCamera;
  40730. private _onKeyDown;
  40731. private _onVrDisplayPresentChange;
  40732. private _onVRDisplayChanged;
  40733. private _onVRRequestPresentStart;
  40734. private _onVRRequestPresentComplete;
  40735. /**
  40736. * Observable raised right before entering VR.
  40737. */
  40738. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40739. /**
  40740. * Observable raised when entering VR has completed.
  40741. */
  40742. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40743. /**
  40744. * Observable raised when exiting VR.
  40745. */
  40746. onExitingVRObservable: Observable<VRExperienceHelper>;
  40747. /**
  40748. * Observable raised when controller mesh is loaded.
  40749. */
  40750. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40751. /** Return this.onEnteringVRObservable
  40752. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40753. */
  40754. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40755. /** Return this.onExitingVRObservable
  40756. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40757. */
  40758. readonly onExitingVR: Observable<VRExperienceHelper>;
  40759. /** Return this.onControllerMeshLoadedObservable
  40760. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40761. */
  40762. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40763. private _rayLength;
  40764. private _useCustomVRButton;
  40765. private _teleportationRequested;
  40766. private _teleportActive;
  40767. private _floorMeshName;
  40768. private _floorMeshesCollection;
  40769. private _rotationAllowed;
  40770. private _teleportBackwardsVector;
  40771. private _teleportationTarget;
  40772. private _isDefaultTeleportationTarget;
  40773. private _postProcessMove;
  40774. private _teleportationFillColor;
  40775. private _teleportationBorderColor;
  40776. private _rotationAngle;
  40777. private _haloCenter;
  40778. private _cameraGazer;
  40779. private _padSensibilityUp;
  40780. private _padSensibilityDown;
  40781. private _leftController;
  40782. private _rightController;
  40783. /**
  40784. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40785. */
  40786. onNewMeshSelected: Observable<AbstractMesh>;
  40787. /**
  40788. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40789. */
  40790. onNewMeshPicked: Observable<PickingInfo>;
  40791. private _circleEase;
  40792. /**
  40793. * Observable raised before camera teleportation
  40794. */
  40795. onBeforeCameraTeleport: Observable<Vector3>;
  40796. /**
  40797. * Observable raised after camera teleportation
  40798. */
  40799. onAfterCameraTeleport: Observable<Vector3>;
  40800. /**
  40801. * Observable raised when current selected mesh gets unselected
  40802. */
  40803. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40804. private _raySelectionPredicate;
  40805. /**
  40806. * To be optionaly changed by user to define custom ray selection
  40807. */
  40808. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40809. /**
  40810. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40811. */
  40812. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40813. /**
  40814. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40815. */
  40816. teleportationEnabled: boolean;
  40817. private _defaultHeight;
  40818. private _teleportationInitialized;
  40819. private _interactionsEnabled;
  40820. private _interactionsRequested;
  40821. private _displayGaze;
  40822. private _displayLaserPointer;
  40823. /**
  40824. * The mesh used to display where the user is going to teleport.
  40825. */
  40826. /**
  40827. * Sets the mesh to be used to display where the user is going to teleport.
  40828. */
  40829. teleportationTarget: Mesh;
  40830. /**
  40831. * 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
  40832. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40833. * See http://doc.babylonjs.com/resources/baking_transformations
  40834. */
  40835. gazeTrackerMesh: Mesh;
  40836. /**
  40837. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40838. */
  40839. updateGazeTrackerScale: boolean;
  40840. /**
  40841. * If the gaze trackers color should be updated when selecting meshes
  40842. */
  40843. updateGazeTrackerColor: boolean;
  40844. /**
  40845. * The gaze tracking mesh corresponding to the left controller
  40846. */
  40847. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40848. /**
  40849. * The gaze tracking mesh corresponding to the right controller
  40850. */
  40851. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40852. /**
  40853. * If the ray of the gaze should be displayed.
  40854. */
  40855. /**
  40856. * Sets if the ray of the gaze should be displayed.
  40857. */
  40858. displayGaze: boolean;
  40859. /**
  40860. * If the ray of the LaserPointer should be displayed.
  40861. */
  40862. /**
  40863. * Sets if the ray of the LaserPointer should be displayed.
  40864. */
  40865. displayLaserPointer: boolean;
  40866. /**
  40867. * The deviceOrientationCamera used as the camera when not in VR.
  40868. */
  40869. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40870. /**
  40871. * Based on the current WebVR support, returns the current VR camera used.
  40872. */
  40873. readonly currentVRCamera: Nullable<Camera>;
  40874. /**
  40875. * The webVRCamera which is used when in VR.
  40876. */
  40877. readonly webVRCamera: WebVRFreeCamera;
  40878. /**
  40879. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40880. */
  40881. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40882. private readonly _teleportationRequestInitiated;
  40883. /**
  40884. * Defines wether or not Pointer lock should be requested when switching to
  40885. * full screen.
  40886. */
  40887. requestPointerLockOnFullScreen: boolean;
  40888. /**
  40889. * Instantiates a VRExperienceHelper.
  40890. * Helps to quickly add VR support to an existing scene.
  40891. * @param scene The scene the VRExperienceHelper belongs to.
  40892. * @param webVROptions Options to modify the vr experience helper's behavior.
  40893. */
  40894. constructor(scene: Scene,
  40895. /** Options to modify the vr experience helper's behavior. */
  40896. webVROptions?: VRExperienceHelperOptions);
  40897. private _onDefaultMeshLoaded;
  40898. private _onResize;
  40899. private _onFullscreenChange;
  40900. /**
  40901. * Gets a value indicating if we are currently in VR mode.
  40902. */
  40903. readonly isInVRMode: boolean;
  40904. private onVrDisplayPresentChange;
  40905. private onVRDisplayChanged;
  40906. private moveButtonToBottomRight;
  40907. private displayVRButton;
  40908. private updateButtonVisibility;
  40909. private _cachedAngularSensibility;
  40910. /**
  40911. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40912. * Otherwise, will use the fullscreen API.
  40913. */
  40914. enterVR(): void;
  40915. /**
  40916. * Attempt to exit VR, or fullscreen.
  40917. */
  40918. exitVR(): void;
  40919. /**
  40920. * The position of the vr experience helper.
  40921. */
  40922. /**
  40923. * Sets the position of the vr experience helper.
  40924. */
  40925. position: Vector3;
  40926. /**
  40927. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40928. */
  40929. enableInteractions(): void;
  40930. private readonly _noControllerIsActive;
  40931. private beforeRender;
  40932. private _isTeleportationFloor;
  40933. /**
  40934. * Adds a floor mesh to be used for teleportation.
  40935. * @param floorMesh the mesh to be used for teleportation.
  40936. */
  40937. addFloorMesh(floorMesh: Mesh): void;
  40938. /**
  40939. * Removes a floor mesh from being used for teleportation.
  40940. * @param floorMesh the mesh to be removed.
  40941. */
  40942. removeFloorMesh(floorMesh: Mesh): void;
  40943. /**
  40944. * Enables interactions and teleportation using the VR controllers and gaze.
  40945. * @param vrTeleportationOptions options to modify teleportation behavior.
  40946. */
  40947. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40948. private _onNewGamepadConnected;
  40949. private _tryEnableInteractionOnController;
  40950. private _onNewGamepadDisconnected;
  40951. private _enableInteractionOnController;
  40952. private _checkTeleportWithRay;
  40953. private _checkRotate;
  40954. private _checkTeleportBackwards;
  40955. private _enableTeleportationOnController;
  40956. private _createTeleportationCircles;
  40957. private _displayTeleportationTarget;
  40958. private _hideTeleportationTarget;
  40959. private _rotateCamera;
  40960. private _moveTeleportationSelectorTo;
  40961. private _workingVector;
  40962. private _workingQuaternion;
  40963. private _workingMatrix;
  40964. /**
  40965. * Teleports the users feet to the desired location
  40966. * @param location The location where the user's feet should be placed
  40967. */
  40968. teleportCamera(location: Vector3): void;
  40969. private _convertNormalToDirectionOfRay;
  40970. private _castRayAndSelectObject;
  40971. private _notifySelectedMeshUnselected;
  40972. /**
  40973. * Sets the color of the laser ray from the vr controllers.
  40974. * @param color new color for the ray.
  40975. */
  40976. changeLaserColor(color: Color3): void;
  40977. /**
  40978. * Sets the color of the ray from the vr headsets gaze.
  40979. * @param color new color for the ray.
  40980. */
  40981. changeGazeColor(color: Color3): void;
  40982. /**
  40983. * Exits VR and disposes of the vr experience helper
  40984. */
  40985. dispose(): void;
  40986. /**
  40987. * Gets the name of the VRExperienceHelper class
  40988. * @returns "VRExperienceHelper"
  40989. */
  40990. getClassName(): string;
  40991. }
  40992. }
  40993. declare module "babylonjs/Cameras/VR/index" {
  40994. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40995. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40996. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40997. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40998. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40999. export * from "babylonjs/Cameras/VR/webVRCamera";
  41000. }
  41001. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41002. import { Observable } from "babylonjs/Misc/observable";
  41003. import { Nullable } from "babylonjs/types";
  41004. import { IDisposable, Scene } from "babylonjs/scene";
  41005. import { Vector3 } from "babylonjs/Maths/math";
  41006. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41007. import { Ray } from "babylonjs/Culling/ray";
  41008. /**
  41009. * Manages an XRSession
  41010. * @see https://doc.babylonjs.com/how_to/webxr
  41011. */
  41012. export class WebXRSessionManager implements IDisposable {
  41013. private scene;
  41014. /**
  41015. * Fires every time a new xrFrame arrives which can be used to update the camera
  41016. */
  41017. onXRFrameObservable: Observable<any>;
  41018. /**
  41019. * Fires when the xr session is ended either by the device or manually done
  41020. */
  41021. onXRSessionEnded: Observable<any>;
  41022. /** @hidden */
  41023. _xrSession: XRSession;
  41024. /** @hidden */
  41025. _frameOfReference: XRFrameOfReference;
  41026. /** @hidden */
  41027. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41028. /** @hidden */
  41029. _currentXRFrame: Nullable<XRFrame>;
  41030. private _xrNavigator;
  41031. private _xrDevice;
  41032. private _tmpMatrix;
  41033. /**
  41034. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41035. * @param scene The scene which the session should be created for
  41036. */
  41037. constructor(scene: Scene);
  41038. /**
  41039. * Initializes the manager
  41040. * After initialization enterXR can be called to start an XR session
  41041. * @returns Promise which resolves after it is initialized
  41042. */
  41043. initializeAsync(): Promise<void>;
  41044. /**
  41045. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41046. * @param sessionCreationOptions xr options to create the session with
  41047. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41048. * @returns Promise which resolves after it enters XR
  41049. */
  41050. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41051. /**
  41052. * Stops the xrSession and restores the renderloop
  41053. * @returns Promise which resolves after it exits XR
  41054. */
  41055. exitXRAsync(): Promise<void>;
  41056. /**
  41057. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41058. * @param ray ray to cast into the environment
  41059. * @returns Promise which resolves with a collision point in the environment if it exists
  41060. */
  41061. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41062. /**
  41063. * Checks if a session would be supported for the creation options specified
  41064. * @param options creation options to check if they are supported
  41065. * @returns true if supported
  41066. */
  41067. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41068. /**
  41069. * @hidden
  41070. * Converts the render layer of xrSession to a render target
  41071. * @param session session to create render target for
  41072. * @param scene scene the new render target should be created for
  41073. */
  41074. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41075. /**
  41076. * Disposes of the session manager
  41077. */
  41078. dispose(): void;
  41079. }
  41080. }
  41081. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41082. import { Scene } from "babylonjs/scene";
  41083. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41084. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41085. /**
  41086. * WebXR Camera which holds the views for the xrSession
  41087. * @see https://doc.babylonjs.com/how_to/webxr
  41088. */
  41089. export class WebXRCamera extends FreeCamera {
  41090. private static _TmpMatrix;
  41091. /**
  41092. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41093. * @param name the name of the camera
  41094. * @param scene the scene to add the camera to
  41095. */
  41096. constructor(name: string, scene: Scene);
  41097. private _updateNumberOfRigCameras;
  41098. /** @hidden */
  41099. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41100. /**
  41101. * Updates the cameras position from the current pose information of the XR session
  41102. * @param xrSessionManager the session containing pose information
  41103. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41104. */
  41105. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41106. }
  41107. }
  41108. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41109. import { Nullable } from "babylonjs/types";
  41110. import { Observable } from "babylonjs/Misc/observable";
  41111. import { IDisposable, Scene } from "babylonjs/scene";
  41112. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41114. import { Ray } from "babylonjs/Culling/ray";
  41115. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41116. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41117. /**
  41118. * States of the webXR experience
  41119. */
  41120. export enum WebXRState {
  41121. /**
  41122. * Transitioning to being in XR mode
  41123. */
  41124. ENTERING_XR = 0,
  41125. /**
  41126. * Transitioning to non XR mode
  41127. */
  41128. EXITING_XR = 1,
  41129. /**
  41130. * In XR mode and presenting
  41131. */
  41132. IN_XR = 2,
  41133. /**
  41134. * Not entered XR mode
  41135. */
  41136. NOT_IN_XR = 3
  41137. }
  41138. /**
  41139. * Helper class used to enable XR
  41140. * @see https://doc.babylonjs.com/how_to/webxr
  41141. */
  41142. export class WebXRExperienceHelper implements IDisposable {
  41143. private scene;
  41144. /**
  41145. * 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
  41146. */
  41147. container: AbstractMesh;
  41148. /**
  41149. * Camera used to render xr content
  41150. */
  41151. camera: WebXRCamera;
  41152. /**
  41153. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41154. */
  41155. state: WebXRState;
  41156. private _setState;
  41157. private static _TmpVector;
  41158. /**
  41159. * Fires when the state of the experience helper has changed
  41160. */
  41161. onStateChangedObservable: Observable<WebXRState>;
  41162. /** @hidden */
  41163. _sessionManager: WebXRSessionManager;
  41164. private _nonVRCamera;
  41165. private _originalSceneAutoClear;
  41166. private _supported;
  41167. /**
  41168. * Creates the experience helper
  41169. * @param scene the scene to attach the experience helper to
  41170. * @returns a promise for the experience helper
  41171. */
  41172. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41173. /**
  41174. * Creates a WebXRExperienceHelper
  41175. * @param scene The scene the helper should be created in
  41176. */
  41177. private constructor();
  41178. /**
  41179. * Exits XR mode and returns the scene to its original state
  41180. * @returns promise that resolves after xr mode has exited
  41181. */
  41182. exitXRAsync(): Promise<void>;
  41183. /**
  41184. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41185. * @param sessionCreationOptions options for the XR session
  41186. * @param frameOfReference frame of reference of the XR session
  41187. * @returns promise that resolves after xr mode has entered
  41188. */
  41189. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41190. /**
  41191. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41192. * @param ray ray to cast into the environment
  41193. * @returns Promise which resolves with a collision point in the environment if it exists
  41194. */
  41195. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41196. /**
  41197. * Updates the global position of the camera by moving the camera's container
  41198. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41199. * @param position The desired global position of the camera
  41200. */
  41201. setPositionOfCameraUsingContainer(position: Vector3): void;
  41202. /**
  41203. * Rotates the xr camera by rotating the camera's container around the camera's position
  41204. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41205. * @param rotation the desired quaternion rotation to apply to the camera
  41206. */
  41207. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41208. /**
  41209. * Checks if the creation options are supported by the xr session
  41210. * @param options creation options
  41211. * @returns true if supported
  41212. */
  41213. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41214. /**
  41215. * Disposes of the experience helper
  41216. */
  41217. dispose(): void;
  41218. }
  41219. }
  41220. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41221. import { Nullable } from "babylonjs/types";
  41222. import { Observable } from "babylonjs/Misc/observable";
  41223. import { IDisposable, Scene } from "babylonjs/scene";
  41224. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41225. /**
  41226. * Button which can be used to enter a different mode of XR
  41227. */
  41228. export class WebXREnterExitUIButton {
  41229. /** button element */
  41230. element: HTMLElement;
  41231. /** XR initialization options for the button */
  41232. initializationOptions: XRSessionCreationOptions;
  41233. /**
  41234. * Creates a WebXREnterExitUIButton
  41235. * @param element button element
  41236. * @param initializationOptions XR initialization options for the button
  41237. */
  41238. constructor(
  41239. /** button element */
  41240. element: HTMLElement,
  41241. /** XR initialization options for the button */
  41242. initializationOptions: XRSessionCreationOptions);
  41243. /**
  41244. * Overwritable function which can be used to update the button's visuals when the state changes
  41245. * @param activeButton the current active button in the UI
  41246. */
  41247. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41248. }
  41249. /**
  41250. * Options to create the webXR UI
  41251. */
  41252. export class WebXREnterExitUIOptions {
  41253. /**
  41254. * Context to enter xr with
  41255. */
  41256. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41257. /**
  41258. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41259. */
  41260. customButtons?: Array<WebXREnterExitUIButton>;
  41261. }
  41262. /**
  41263. * UI to allow the user to enter/exit XR mode
  41264. */
  41265. export class WebXREnterExitUI implements IDisposable {
  41266. private scene;
  41267. private _overlay;
  41268. private _buttons;
  41269. private _activeButton;
  41270. /**
  41271. * Fired every time the active button is changed.
  41272. *
  41273. * When xr is entered via a button that launches xr that button will be the callback parameter
  41274. *
  41275. * When exiting xr the callback parameter will be null)
  41276. */
  41277. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41278. /**
  41279. * Creates UI to allow the user to enter/exit XR mode
  41280. * @param scene the scene to add the ui to
  41281. * @param helper the xr experience helper to enter/exit xr with
  41282. * @param options options to configure the UI
  41283. * @returns the created ui
  41284. */
  41285. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41286. private constructor();
  41287. private _updateButtons;
  41288. /**
  41289. * Disposes of the object
  41290. */
  41291. dispose(): void;
  41292. }
  41293. }
  41294. declare module "babylonjs/Cameras/XR/webXRInput" {
  41295. import { IDisposable, Scene } from "babylonjs/scene";
  41296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41297. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41298. /**
  41299. * Represents an XR input
  41300. */
  41301. export class WebXRController {
  41302. /**
  41303. * 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
  41304. */
  41305. grip?: AbstractMesh;
  41306. /**
  41307. * Pointer which can be used to select objects or attach a visible laser to
  41308. */
  41309. pointer: AbstractMesh;
  41310. /**
  41311. * Creates the controller
  41312. * @see https://doc.babylonjs.com/how_to/webxr
  41313. * @param scene the scene which the controller should be associated to
  41314. */
  41315. constructor(scene: Scene);
  41316. /**
  41317. * Disposes of the object
  41318. */
  41319. dispose(): void;
  41320. }
  41321. /**
  41322. * XR input used to track XR inputs such as controllers/rays
  41323. */
  41324. export class WebXRInput implements IDisposable {
  41325. private helper;
  41326. /**
  41327. * XR controllers being tracked
  41328. */
  41329. controllers: Array<WebXRController>;
  41330. private _tmpMatrix;
  41331. private _frameObserver;
  41332. /**
  41333. * Initializes the WebXRInput
  41334. * @param helper experience helper which the input should be created for
  41335. */
  41336. constructor(helper: WebXRExperienceHelper);
  41337. /**
  41338. * Disposes of the object
  41339. */
  41340. dispose(): void;
  41341. }
  41342. }
  41343. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41344. import { Nullable } from "babylonjs/types";
  41345. import { IDisposable } from "babylonjs/scene";
  41346. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41347. /**
  41348. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41349. */
  41350. export class WebXRManagedOutputCanvas implements IDisposable {
  41351. private _canvas;
  41352. /**
  41353. * xrpresent context of the canvas which can be used to display/mirror xr content
  41354. */
  41355. canvasContext: Nullable<WebGLRenderingContext>;
  41356. /**
  41357. * Initializes the canvas to be added/removed upon entering/exiting xr
  41358. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41359. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41360. */
  41361. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41362. /**
  41363. * Disposes of the object
  41364. */
  41365. dispose(): void;
  41366. private _setManagedOutputCanvas;
  41367. private _addCanvas;
  41368. private _removeCanvas;
  41369. }
  41370. }
  41371. declare module "babylonjs/Cameras/XR/index" {
  41372. export * from "babylonjs/Cameras/XR/webXRCamera";
  41373. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41374. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41375. export * from "babylonjs/Cameras/XR/webXRInput";
  41376. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41377. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41378. }
  41379. declare module "babylonjs/Cameras/RigModes/index" {
  41380. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41381. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41382. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41383. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41384. }
  41385. declare module "babylonjs/Cameras/index" {
  41386. export * from "babylonjs/Cameras/Inputs/index";
  41387. export * from "babylonjs/Cameras/cameraInputsManager";
  41388. export * from "babylonjs/Cameras/camera";
  41389. export * from "babylonjs/Cameras/targetCamera";
  41390. export * from "babylonjs/Cameras/freeCamera";
  41391. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41392. export * from "babylonjs/Cameras/touchCamera";
  41393. export * from "babylonjs/Cameras/arcRotateCamera";
  41394. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41395. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41396. export * from "babylonjs/Cameras/flyCamera";
  41397. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41398. export * from "babylonjs/Cameras/followCamera";
  41399. export * from "babylonjs/Cameras/gamepadCamera";
  41400. export * from "babylonjs/Cameras/Stereoscopic/index";
  41401. export * from "babylonjs/Cameras/universalCamera";
  41402. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41403. export * from "babylonjs/Cameras/VR/index";
  41404. export * from "babylonjs/Cameras/XR/index";
  41405. export * from "babylonjs/Cameras/RigModes/index";
  41406. }
  41407. declare module "babylonjs/Collisions/index" {
  41408. export * from "babylonjs/Collisions/collider";
  41409. export * from "babylonjs/Collisions/collisionCoordinator";
  41410. export * from "babylonjs/Collisions/pickingInfo";
  41411. export * from "babylonjs/Collisions/intersectionInfo";
  41412. }
  41413. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41414. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41415. import { Vector3, Plane } from "babylonjs/Maths/math";
  41416. import { Ray } from "babylonjs/Culling/ray";
  41417. /**
  41418. * Contains an array of blocks representing the octree
  41419. */
  41420. export interface IOctreeContainer<T> {
  41421. /**
  41422. * Blocks within the octree
  41423. */
  41424. blocks: Array<OctreeBlock<T>>;
  41425. }
  41426. /**
  41427. * Class used to store a cell in an octree
  41428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41429. */
  41430. export class OctreeBlock<T> {
  41431. /**
  41432. * Gets the content of the current block
  41433. */
  41434. entries: T[];
  41435. /**
  41436. * Gets the list of block children
  41437. */
  41438. blocks: Array<OctreeBlock<T>>;
  41439. private _depth;
  41440. private _maxDepth;
  41441. private _capacity;
  41442. private _minPoint;
  41443. private _maxPoint;
  41444. private _boundingVectors;
  41445. private _creationFunc;
  41446. /**
  41447. * Creates a new block
  41448. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41449. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41450. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41451. * @param depth defines the current depth of this block in the octree
  41452. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41453. * @param creationFunc defines a callback to call when an element is added to the block
  41454. */
  41455. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41456. /**
  41457. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41458. */
  41459. readonly capacity: number;
  41460. /**
  41461. * Gets the minimum vector (in world space) of the block's bounding box
  41462. */
  41463. readonly minPoint: Vector3;
  41464. /**
  41465. * Gets the maximum vector (in world space) of the block's bounding box
  41466. */
  41467. readonly maxPoint: Vector3;
  41468. /**
  41469. * Add a new element to this block
  41470. * @param entry defines the element to add
  41471. */
  41472. addEntry(entry: T): void;
  41473. /**
  41474. * Remove an element from this block
  41475. * @param entry defines the element to remove
  41476. */
  41477. removeEntry(entry: T): void;
  41478. /**
  41479. * Add an array of elements to this block
  41480. * @param entries defines the array of elements to add
  41481. */
  41482. addEntries(entries: T[]): void;
  41483. /**
  41484. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41485. * @param frustumPlanes defines the frustum planes to test
  41486. * @param selection defines the array to store current content if selection is positive
  41487. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41488. */
  41489. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41490. /**
  41491. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41492. * @param sphereCenter defines the bounding sphere center
  41493. * @param sphereRadius defines the bounding sphere radius
  41494. * @param selection defines the array to store current content if selection is positive
  41495. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41496. */
  41497. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41498. /**
  41499. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41500. * @param ray defines the ray to test with
  41501. * @param selection defines the array to store current content if selection is positive
  41502. */
  41503. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41504. /**
  41505. * Subdivide the content into child blocks (this block will then be empty)
  41506. */
  41507. createInnerBlocks(): void;
  41508. /**
  41509. * @hidden
  41510. */
  41511. 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;
  41512. }
  41513. }
  41514. declare module "babylonjs/Culling/Octrees/octree" {
  41515. import { SmartArray } from "babylonjs/Misc/smartArray";
  41516. import { Vector3, Plane } from "babylonjs/Maths/math";
  41517. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41519. import { Ray } from "babylonjs/Culling/ray";
  41520. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41521. /**
  41522. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41523. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41524. */
  41525. export class Octree<T> {
  41526. /** 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.) */
  41527. maxDepth: number;
  41528. /**
  41529. * Blocks within the octree containing objects
  41530. */
  41531. blocks: Array<OctreeBlock<T>>;
  41532. /**
  41533. * Content stored in the octree
  41534. */
  41535. dynamicContent: T[];
  41536. private _maxBlockCapacity;
  41537. private _selectionContent;
  41538. private _creationFunc;
  41539. /**
  41540. * Creates a octree
  41541. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41542. * @param creationFunc function to be used to instatiate the octree
  41543. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41544. * @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.)
  41545. */
  41546. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41547. /** 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.) */
  41548. maxDepth?: number);
  41549. /**
  41550. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41551. * @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);
  41552. * @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);
  41553. * @param entries meshes to be added to the octree blocks
  41554. */
  41555. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41556. /**
  41557. * Adds a mesh to the octree
  41558. * @param entry Mesh to add to the octree
  41559. */
  41560. addMesh(entry: T): void;
  41561. /**
  41562. * Remove an element from the octree
  41563. * @param entry defines the element to remove
  41564. */
  41565. removeMesh(entry: T): void;
  41566. /**
  41567. * Selects an array of meshes within the frustum
  41568. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41569. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41570. * @returns array of meshes within the frustum
  41571. */
  41572. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41573. /**
  41574. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41575. * @param sphereCenter defines the bounding sphere center
  41576. * @param sphereRadius defines the bounding sphere radius
  41577. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41578. * @returns an array of objects that intersect the sphere
  41579. */
  41580. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41581. /**
  41582. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41583. * @param ray defines the ray to test with
  41584. * @returns array of intersected objects
  41585. */
  41586. intersectsRay(ray: Ray): SmartArray<T>;
  41587. /**
  41588. * Adds a mesh into the octree block if it intersects the block
  41589. */
  41590. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41591. /**
  41592. * Adds a submesh into the octree block if it intersects the block
  41593. */
  41594. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41595. }
  41596. }
  41597. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41598. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41599. import { Scene } from "babylonjs/scene";
  41600. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41602. import { Ray } from "babylonjs/Culling/ray";
  41603. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41604. import { Collider } from "babylonjs/Collisions/collider";
  41605. module "babylonjs/scene" {
  41606. interface Scene {
  41607. /**
  41608. * @hidden
  41609. * Backing Filed
  41610. */
  41611. _selectionOctree: Octree<AbstractMesh>;
  41612. /**
  41613. * Gets the octree used to boost mesh selection (picking)
  41614. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41615. */
  41616. selectionOctree: Octree<AbstractMesh>;
  41617. /**
  41618. * Creates or updates the octree used to boost selection (picking)
  41619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41620. * @param maxCapacity defines the maximum capacity per leaf
  41621. * @param maxDepth defines the maximum depth of the octree
  41622. * @returns an octree of AbstractMesh
  41623. */
  41624. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41625. }
  41626. }
  41627. module "babylonjs/Meshes/abstractMesh" {
  41628. interface AbstractMesh {
  41629. /**
  41630. * @hidden
  41631. * Backing Field
  41632. */
  41633. _submeshesOctree: Octree<SubMesh>;
  41634. /**
  41635. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41636. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41637. * @param maxCapacity defines the maximum size of each block (64 by default)
  41638. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41639. * @returns the new octree
  41640. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41641. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41642. */
  41643. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41644. }
  41645. }
  41646. /**
  41647. * Defines the octree scene component responsible to manage any octrees
  41648. * in a given scene.
  41649. */
  41650. export class OctreeSceneComponent {
  41651. /**
  41652. * The component name helpfull to identify the component in the list of scene components.
  41653. */
  41654. readonly name: string;
  41655. /**
  41656. * The scene the component belongs to.
  41657. */
  41658. scene: Scene;
  41659. /**
  41660. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41661. */
  41662. readonly checksIsEnabled: boolean;
  41663. /**
  41664. * Creates a new instance of the component for the given scene
  41665. * @param scene Defines the scene to register the component in
  41666. */
  41667. constructor(scene: Scene);
  41668. /**
  41669. * Registers the component in a given scene
  41670. */
  41671. register(): void;
  41672. /**
  41673. * Return the list of active meshes
  41674. * @returns the list of active meshes
  41675. */
  41676. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41677. /**
  41678. * Return the list of active sub meshes
  41679. * @param mesh The mesh to get the candidates sub meshes from
  41680. * @returns the list of active sub meshes
  41681. */
  41682. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41683. private _tempRay;
  41684. /**
  41685. * Return the list of sub meshes intersecting with a given local ray
  41686. * @param mesh defines the mesh to find the submesh for
  41687. * @param localRay defines the ray in local space
  41688. * @returns the list of intersecting sub meshes
  41689. */
  41690. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41691. /**
  41692. * Return the list of sub meshes colliding with a collider
  41693. * @param mesh defines the mesh to find the submesh for
  41694. * @param collider defines the collider to evaluate the collision against
  41695. * @returns the list of colliding sub meshes
  41696. */
  41697. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41698. /**
  41699. * Rebuilds the elements related to this component in case of
  41700. * context lost for instance.
  41701. */
  41702. rebuild(): void;
  41703. /**
  41704. * Disposes the component and the associated ressources.
  41705. */
  41706. dispose(): void;
  41707. }
  41708. }
  41709. declare module "babylonjs/Culling/Octrees/index" {
  41710. export * from "babylonjs/Culling/Octrees/octree";
  41711. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41712. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41713. }
  41714. declare module "babylonjs/Culling/index" {
  41715. export * from "babylonjs/Culling/boundingBox";
  41716. export * from "babylonjs/Culling/boundingInfo";
  41717. export * from "babylonjs/Culling/boundingSphere";
  41718. export * from "babylonjs/Culling/Octrees/index";
  41719. export * from "babylonjs/Culling/ray";
  41720. }
  41721. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41722. import { IDisposable, Scene } from "babylonjs/scene";
  41723. import { Nullable } from "babylonjs/types";
  41724. import { Observable } from "babylonjs/Misc/observable";
  41725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41726. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  41727. /**
  41728. * Renders a layer on top of an existing scene
  41729. */
  41730. export class UtilityLayerRenderer implements IDisposable {
  41731. /** the original scene that will be rendered on top of */
  41732. originalScene: Scene;
  41733. private _pointerCaptures;
  41734. private _lastPointerEvents;
  41735. private static _DefaultUtilityLayer;
  41736. private static _DefaultKeepDepthUtilityLayer;
  41737. private _sharedGizmoLight;
  41738. /**
  41739. * @hidden
  41740. * Light which used by gizmos to get light shading
  41741. */
  41742. _getSharedGizmoLight(): HemisphericLight;
  41743. /**
  41744. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41745. */
  41746. pickUtilitySceneFirst: boolean;
  41747. /**
  41748. * 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)
  41749. */
  41750. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41751. /**
  41752. * 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)
  41753. */
  41754. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41755. /**
  41756. * The scene that is rendered on top of the original scene
  41757. */
  41758. utilityLayerScene: Scene;
  41759. /**
  41760. * If the utility layer should automatically be rendered on top of existing scene
  41761. */
  41762. shouldRender: boolean;
  41763. /**
  41764. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41765. */
  41766. onlyCheckPointerDownEvents: boolean;
  41767. /**
  41768. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41769. */
  41770. processAllEvents: boolean;
  41771. /**
  41772. * Observable raised when the pointer move from the utility layer scene to the main scene
  41773. */
  41774. onPointerOutObservable: Observable<number>;
  41775. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41776. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41777. private _afterRenderObserver;
  41778. private _sceneDisposeObserver;
  41779. private _originalPointerObserver;
  41780. /**
  41781. * Instantiates a UtilityLayerRenderer
  41782. * @param originalScene the original scene that will be rendered on top of
  41783. * @param handleEvents boolean indicating if the utility layer should handle events
  41784. */
  41785. constructor(
  41786. /** the original scene that will be rendered on top of */
  41787. originalScene: Scene, handleEvents?: boolean);
  41788. private _notifyObservers;
  41789. /**
  41790. * Renders the utility layers scene on top of the original scene
  41791. */
  41792. render(): void;
  41793. /**
  41794. * Disposes of the renderer
  41795. */
  41796. dispose(): void;
  41797. private _updateCamera;
  41798. }
  41799. }
  41800. declare module "babylonjs/Gizmos/gizmo" {
  41801. import { Nullable } from "babylonjs/types";
  41802. import { IDisposable } from "babylonjs/scene";
  41803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41804. import { Mesh } from "babylonjs/Meshes/mesh";
  41805. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41806. /**
  41807. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41808. */
  41809. export class Gizmo implements IDisposable {
  41810. /** The utility layer the gizmo will be added to */
  41811. gizmoLayer: UtilityLayerRenderer;
  41812. /**
  41813. * The root mesh of the gizmo
  41814. */
  41815. _rootMesh: Mesh;
  41816. private _attachedMesh;
  41817. /**
  41818. * Ratio for the scale of the gizmo (Default: 1)
  41819. */
  41820. scaleRatio: number;
  41821. private _tmpMatrix;
  41822. /**
  41823. * If a custom mesh has been set (Default: false)
  41824. */
  41825. protected _customMeshSet: boolean;
  41826. /**
  41827. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41828. * * When set, interactions will be enabled
  41829. */
  41830. attachedMesh: Nullable<AbstractMesh>;
  41831. /**
  41832. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41833. * @param mesh The mesh to replace the default mesh of the gizmo
  41834. */
  41835. setCustomMesh(mesh: Mesh): void;
  41836. /**
  41837. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41838. */
  41839. updateGizmoRotationToMatchAttachedMesh: boolean;
  41840. /**
  41841. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41842. */
  41843. updateGizmoPositionToMatchAttachedMesh: boolean;
  41844. /**
  41845. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41846. */
  41847. protected _updateScale: boolean;
  41848. protected _interactionsEnabled: boolean;
  41849. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41850. private _beforeRenderObserver;
  41851. /**
  41852. * Creates a gizmo
  41853. * @param gizmoLayer The utility layer the gizmo will be added to
  41854. */
  41855. constructor(
  41856. /** The utility layer the gizmo will be added to */
  41857. gizmoLayer?: UtilityLayerRenderer);
  41858. private _tempVector;
  41859. /**
  41860. * @hidden
  41861. * Updates the gizmo to match the attached mesh's position/rotation
  41862. */
  41863. protected _update(): void;
  41864. /**
  41865. * Disposes of the gizmo
  41866. */
  41867. dispose(): void;
  41868. }
  41869. }
  41870. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41871. import { Observable } from "babylonjs/Misc/observable";
  41872. import { Nullable } from "babylonjs/types";
  41873. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41874. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41876. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41877. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41878. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41879. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41880. import { Scene } from "babylonjs/scene";
  41881. /**
  41882. * Single axis drag gizmo
  41883. */
  41884. export class AxisDragGizmo extends Gizmo {
  41885. /**
  41886. * Drag behavior responsible for the gizmos dragging interactions
  41887. */
  41888. dragBehavior: PointerDragBehavior;
  41889. private _pointerObserver;
  41890. /**
  41891. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41892. */
  41893. snapDistance: number;
  41894. /**
  41895. * Event that fires each time the gizmo snaps to a new location.
  41896. * * snapDistance is the the change in distance
  41897. */
  41898. onSnapObservable: Observable<{
  41899. snapDistance: number;
  41900. }>;
  41901. /** @hidden */
  41902. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41903. /** @hidden */
  41904. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41905. /**
  41906. * Creates an AxisDragGizmo
  41907. * @param gizmoLayer The utility layer the gizmo will be added to
  41908. * @param dragAxis The axis which the gizmo will be able to drag on
  41909. * @param color The color of the gizmo
  41910. */
  41911. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41912. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41913. /**
  41914. * Disposes of the gizmo
  41915. */
  41916. dispose(): void;
  41917. }
  41918. }
  41919. declare module "babylonjs/Debug/axesViewer" {
  41920. import { Vector3 } from "babylonjs/Maths/math";
  41921. import { Nullable } from "babylonjs/types";
  41922. import { Scene } from "babylonjs/scene";
  41923. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41924. /**
  41925. * The Axes viewer will show 3 axes in a specific point in space
  41926. */
  41927. export class AxesViewer {
  41928. private _xAxis;
  41929. private _yAxis;
  41930. private _zAxis;
  41931. private _scaleLinesFactor;
  41932. private _instanced;
  41933. /**
  41934. * Gets the hosting scene
  41935. */
  41936. scene: Scene;
  41937. /**
  41938. * Gets or sets a number used to scale line length
  41939. */
  41940. scaleLines: number;
  41941. /** Gets the node hierarchy used to render x-axis */
  41942. readonly xAxis: TransformNode;
  41943. /** Gets the node hierarchy used to render y-axis */
  41944. readonly yAxis: TransformNode;
  41945. /** Gets the node hierarchy used to render z-axis */
  41946. readonly zAxis: TransformNode;
  41947. /**
  41948. * Creates a new AxesViewer
  41949. * @param scene defines the hosting scene
  41950. * @param scaleLines defines a number used to scale line length (1 by default)
  41951. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41952. * @param xAxis defines the node hierarchy used to render the x-axis
  41953. * @param yAxis defines the node hierarchy used to render the y-axis
  41954. * @param zAxis defines the node hierarchy used to render the z-axis
  41955. */
  41956. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41957. /**
  41958. * Force the viewer to update
  41959. * @param position defines the position of the viewer
  41960. * @param xaxis defines the x axis of the viewer
  41961. * @param yaxis defines the y axis of the viewer
  41962. * @param zaxis defines the z axis of the viewer
  41963. */
  41964. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41965. /**
  41966. * Creates an instance of this axes viewer.
  41967. * @returns a new axes viewer with instanced meshes
  41968. */
  41969. createInstance(): AxesViewer;
  41970. /** Releases resources */
  41971. dispose(): void;
  41972. private static _SetRenderingGroupId;
  41973. }
  41974. }
  41975. declare module "babylonjs/Debug/boneAxesViewer" {
  41976. import { Nullable } from "babylonjs/types";
  41977. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41978. import { Vector3 } from "babylonjs/Maths/math";
  41979. import { Mesh } from "babylonjs/Meshes/mesh";
  41980. import { Bone } from "babylonjs/Bones/bone";
  41981. import { Scene } from "babylonjs/scene";
  41982. /**
  41983. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41984. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41985. */
  41986. export class BoneAxesViewer extends AxesViewer {
  41987. /**
  41988. * Gets or sets the target mesh where to display the axes viewer
  41989. */
  41990. mesh: Nullable<Mesh>;
  41991. /**
  41992. * Gets or sets the target bone where to display the axes viewer
  41993. */
  41994. bone: Nullable<Bone>;
  41995. /** Gets current position */
  41996. pos: Vector3;
  41997. /** Gets direction of X axis */
  41998. xaxis: Vector3;
  41999. /** Gets direction of Y axis */
  42000. yaxis: Vector3;
  42001. /** Gets direction of Z axis */
  42002. zaxis: Vector3;
  42003. /**
  42004. * Creates a new BoneAxesViewer
  42005. * @param scene defines the hosting scene
  42006. * @param bone defines the target bone
  42007. * @param mesh defines the target mesh
  42008. * @param scaleLines defines a scaling factor for line length (1 by default)
  42009. */
  42010. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42011. /**
  42012. * Force the viewer to update
  42013. */
  42014. update(): void;
  42015. /** Releases resources */
  42016. dispose(): void;
  42017. }
  42018. }
  42019. declare module "babylonjs/Debug/debugLayer" {
  42020. import { Observable } from "babylonjs/Misc/observable";
  42021. import { Scene } from "babylonjs/scene";
  42022. /**
  42023. * Interface used to define scene explorer extensibility option
  42024. */
  42025. export interface IExplorerExtensibilityOption {
  42026. /**
  42027. * Define the option label
  42028. */
  42029. label: string;
  42030. /**
  42031. * Defines the action to execute on click
  42032. */
  42033. action: (entity: any) => void;
  42034. }
  42035. /**
  42036. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42037. */
  42038. export interface IExplorerExtensibilityGroup {
  42039. /**
  42040. * Defines a predicate to test if a given type mut be extended
  42041. */
  42042. predicate: (entity: any) => boolean;
  42043. /**
  42044. * Gets the list of options added to a type
  42045. */
  42046. entries: IExplorerExtensibilityOption[];
  42047. }
  42048. /**
  42049. * Interface used to define the options to use to create the Inspector
  42050. */
  42051. export interface IInspectorOptions {
  42052. /**
  42053. * Display in overlay mode (default: false)
  42054. */
  42055. overlay?: boolean;
  42056. /**
  42057. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42058. */
  42059. globalRoot?: HTMLElement;
  42060. /**
  42061. * Display the Scene explorer
  42062. */
  42063. showExplorer?: boolean;
  42064. /**
  42065. * Display the property inspector
  42066. */
  42067. showInspector?: boolean;
  42068. /**
  42069. * Display in embed mode (both panes on the right)
  42070. */
  42071. embedMode?: boolean;
  42072. /**
  42073. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42074. */
  42075. handleResize?: boolean;
  42076. /**
  42077. * Allow the panes to popup (default: true)
  42078. */
  42079. enablePopup?: boolean;
  42080. /**
  42081. * Allow the panes to be closed by users (default: true)
  42082. */
  42083. enableClose?: boolean;
  42084. /**
  42085. * Optional list of extensibility entries
  42086. */
  42087. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42088. /**
  42089. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42090. */
  42091. inspectorURL?: string;
  42092. }
  42093. module "babylonjs/scene" {
  42094. interface Scene {
  42095. /**
  42096. * @hidden
  42097. * Backing field
  42098. */
  42099. _debugLayer: DebugLayer;
  42100. /**
  42101. * Gets the debug layer (aka Inspector) associated with the scene
  42102. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42103. */
  42104. debugLayer: DebugLayer;
  42105. }
  42106. }
  42107. /**
  42108. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42109. * what is happening in your scene
  42110. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42111. */
  42112. export class DebugLayer {
  42113. /**
  42114. * Define the url to get the inspector script from.
  42115. * By default it uses the babylonjs CDN.
  42116. * @ignoreNaming
  42117. */
  42118. static InspectorURL: string;
  42119. private _scene;
  42120. private BJSINSPECTOR;
  42121. /**
  42122. * Observable triggered when a property is changed through the inspector.
  42123. */
  42124. onPropertyChangedObservable: Observable<{
  42125. object: any;
  42126. property: string;
  42127. value: any;
  42128. initialValue: any;
  42129. }>;
  42130. /**
  42131. * Instantiates a new debug layer.
  42132. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42133. * what is happening in your scene
  42134. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42135. * @param scene Defines the scene to inspect
  42136. */
  42137. constructor(scene: Scene);
  42138. /** Creates the inspector window. */
  42139. private _createInspector;
  42140. /**
  42141. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42142. * @param entity defines the entity to select
  42143. * @param lineContainerTitle defines the specific block to highlight
  42144. */
  42145. select(entity: any, lineContainerTitle?: string): void;
  42146. /** Get the inspector from bundle or global */
  42147. private _getGlobalInspector;
  42148. /**
  42149. * Get if the inspector is visible or not.
  42150. * @returns true if visible otherwise, false
  42151. */
  42152. isVisible(): boolean;
  42153. /**
  42154. * Hide the inspector and close its window.
  42155. */
  42156. hide(): void;
  42157. /**
  42158. * Launch the debugLayer.
  42159. * @param config Define the configuration of the inspector
  42160. * @return a promise fulfilled when the debug layer is visible
  42161. */
  42162. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42163. }
  42164. }
  42165. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42166. import { Nullable } from "babylonjs/types";
  42167. import { Scene } from "babylonjs/scene";
  42168. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42169. import { Mesh } from "babylonjs/Meshes/mesh";
  42170. /**
  42171. * Class containing static functions to help procedurally build meshes
  42172. */
  42173. export class BoxBuilder {
  42174. /**
  42175. * Creates a box mesh
  42176. * * The parameter `size` sets the size (float) of each box side (default 1)
  42177. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42178. * * 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)
  42179. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42183. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42184. * @param name defines the name of the mesh
  42185. * @param options defines the options used to create the mesh
  42186. * @param scene defines the hosting scene
  42187. * @returns the box mesh
  42188. */
  42189. static CreateBox(name: string, options: {
  42190. size?: number;
  42191. width?: number;
  42192. height?: number;
  42193. depth?: number;
  42194. faceUV?: Vector4[];
  42195. faceColors?: Color4[];
  42196. sideOrientation?: number;
  42197. frontUVs?: Vector4;
  42198. backUVs?: Vector4;
  42199. updatable?: boolean;
  42200. }, scene?: Nullable<Scene>): Mesh;
  42201. }
  42202. }
  42203. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42204. import { Vector4 } from "babylonjs/Maths/math";
  42205. import { Mesh } from "babylonjs/Meshes/mesh";
  42206. /**
  42207. * Class containing static functions to help procedurally build meshes
  42208. */
  42209. export class SphereBuilder {
  42210. /**
  42211. * Creates a sphere mesh
  42212. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42213. * * 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`)
  42214. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42215. * * 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
  42216. * * 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)
  42217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42220. * @param name defines the name of the mesh
  42221. * @param options defines the options used to create the mesh
  42222. * @param scene defines the hosting scene
  42223. * @returns the sphere mesh
  42224. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42225. */
  42226. static CreateSphere(name: string, options: {
  42227. segments?: number;
  42228. diameter?: number;
  42229. diameterX?: number;
  42230. diameterY?: number;
  42231. diameterZ?: number;
  42232. arc?: number;
  42233. slice?: number;
  42234. sideOrientation?: number;
  42235. frontUVs?: Vector4;
  42236. backUVs?: Vector4;
  42237. updatable?: boolean;
  42238. }, scene: any): Mesh;
  42239. }
  42240. }
  42241. declare module "babylonjs/Debug/physicsViewer" {
  42242. import { Nullable } from "babylonjs/types";
  42243. import { Scene } from "babylonjs/scene";
  42244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42245. import { Mesh } from "babylonjs/Meshes/mesh";
  42246. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42247. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42248. /**
  42249. * Used to show the physics impostor around the specific mesh
  42250. */
  42251. export class PhysicsViewer {
  42252. /** @hidden */
  42253. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42254. /** @hidden */
  42255. protected _meshes: Array<Nullable<AbstractMesh>>;
  42256. /** @hidden */
  42257. protected _scene: Nullable<Scene>;
  42258. /** @hidden */
  42259. protected _numMeshes: number;
  42260. /** @hidden */
  42261. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42262. private _renderFunction;
  42263. private _utilityLayer;
  42264. private _debugBoxMesh;
  42265. private _debugSphereMesh;
  42266. private _debugMaterial;
  42267. private _debugMeshMeshes;
  42268. /**
  42269. * Creates a new PhysicsViewer
  42270. * @param scene defines the hosting scene
  42271. */
  42272. constructor(scene: Scene);
  42273. /** @hidden */
  42274. protected _updateDebugMeshes(): void;
  42275. /**
  42276. * Renders a specified physic impostor
  42277. * @param impostor defines the impostor to render
  42278. * @param targetMesh defines the mesh represented by the impostor
  42279. * @returns the new debug mesh used to render the impostor
  42280. */
  42281. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42282. /**
  42283. * Hides a specified physic impostor
  42284. * @param impostor defines the impostor to hide
  42285. */
  42286. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42287. private _getDebugMaterial;
  42288. private _getDebugBoxMesh;
  42289. private _getDebugSphereMesh;
  42290. private _getDebugMeshMesh;
  42291. private _getDebugMesh;
  42292. /** Releases all resources */
  42293. dispose(): void;
  42294. }
  42295. }
  42296. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42297. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42298. import { Nullable } from "babylonjs/types";
  42299. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42300. import { Scene } from "babylonjs/scene";
  42301. /**
  42302. * Class containing static functions to help procedurally build meshes
  42303. */
  42304. export class LinesBuilder {
  42305. /**
  42306. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42307. * * 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
  42308. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42309. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42310. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42311. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42312. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42313. * * 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
  42314. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42317. * @param name defines the name of the new line system
  42318. * @param options defines the options used to create the line system
  42319. * @param scene defines the hosting scene
  42320. * @returns a new line system mesh
  42321. */
  42322. static CreateLineSystem(name: string, options: {
  42323. lines: Vector3[][];
  42324. updatable?: boolean;
  42325. instance?: Nullable<LinesMesh>;
  42326. colors?: Nullable<Color4[][]>;
  42327. useVertexAlpha?: boolean;
  42328. }, scene: Nullable<Scene>): LinesMesh;
  42329. /**
  42330. * Creates a line mesh
  42331. * 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
  42332. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42333. * * The parameter `points` is an array successive Vector3
  42334. * * 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
  42335. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42336. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42337. * * When updating an instance, remember that only point positions can change, not the number of points
  42338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42340. * @param name defines the name of the new line system
  42341. * @param options defines the options used to create the line system
  42342. * @param scene defines the hosting scene
  42343. * @returns a new line mesh
  42344. */
  42345. static CreateLines(name: string, options: {
  42346. points: Vector3[];
  42347. updatable?: boolean;
  42348. instance?: Nullable<LinesMesh>;
  42349. colors?: Color4[];
  42350. useVertexAlpha?: boolean;
  42351. }, scene?: Nullable<Scene>): LinesMesh;
  42352. /**
  42353. * Creates a dashed line mesh
  42354. * * 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
  42355. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42356. * * The parameter `points` is an array successive Vector3
  42357. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42358. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42359. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42360. * * 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
  42361. * * When updating an instance, remember that only point positions can change, not the number of points
  42362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42363. * @param name defines the name of the mesh
  42364. * @param options defines the options used to create the mesh
  42365. * @param scene defines the hosting scene
  42366. * @returns the dashed line mesh
  42367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42368. */
  42369. static CreateDashedLines(name: string, options: {
  42370. points: Vector3[];
  42371. dashSize?: number;
  42372. gapSize?: number;
  42373. dashNb?: number;
  42374. updatable?: boolean;
  42375. instance?: LinesMesh;
  42376. }, scene?: Nullable<Scene>): LinesMesh;
  42377. }
  42378. }
  42379. declare module "babylonjs/Debug/rayHelper" {
  42380. import { Nullable } from "babylonjs/types";
  42381. import { Ray } from "babylonjs/Culling/ray";
  42382. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42383. import { Scene } from "babylonjs/scene";
  42384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42385. import "babylonjs/Meshes/Builders/linesBuilder";
  42386. /**
  42387. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42388. * in order to better appreciate the issue one might have.
  42389. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42390. */
  42391. export class RayHelper {
  42392. /**
  42393. * Defines the ray we are currently tryin to visualize.
  42394. */
  42395. ray: Nullable<Ray>;
  42396. private _renderPoints;
  42397. private _renderLine;
  42398. private _renderFunction;
  42399. private _scene;
  42400. private _updateToMeshFunction;
  42401. private _attachedToMesh;
  42402. private _meshSpaceDirection;
  42403. private _meshSpaceOrigin;
  42404. /**
  42405. * Helper function to create a colored helper in a scene in one line.
  42406. * @param ray Defines the ray we are currently tryin to visualize
  42407. * @param scene Defines the scene the ray is used in
  42408. * @param color Defines the color we want to see the ray in
  42409. * @returns The newly created ray helper.
  42410. */
  42411. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42412. /**
  42413. * Instantiate a new ray helper.
  42414. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42415. * in order to better appreciate the issue one might have.
  42416. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42417. * @param ray Defines the ray we are currently tryin to visualize
  42418. */
  42419. constructor(ray: Ray);
  42420. /**
  42421. * Shows the ray we are willing to debug.
  42422. * @param scene Defines the scene the ray needs to be rendered in
  42423. * @param color Defines the color the ray needs to be rendered in
  42424. */
  42425. show(scene: Scene, color?: Color3): void;
  42426. /**
  42427. * Hides the ray we are debugging.
  42428. */
  42429. hide(): void;
  42430. private _render;
  42431. /**
  42432. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42433. * @param mesh Defines the mesh we want the helper attached to
  42434. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42435. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42436. * @param length Defines the length of the ray
  42437. */
  42438. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42439. /**
  42440. * Detach the ray helper from the mesh it has previously been attached to.
  42441. */
  42442. detachFromMesh(): void;
  42443. private _updateToMesh;
  42444. /**
  42445. * Dispose the helper and release its associated resources.
  42446. */
  42447. dispose(): void;
  42448. }
  42449. }
  42450. declare module "babylonjs/Debug/skeletonViewer" {
  42451. import { Color3 } from "babylonjs/Maths/math";
  42452. import { Scene } from "babylonjs/scene";
  42453. import { Nullable } from "babylonjs/types";
  42454. import { Skeleton } from "babylonjs/Bones/skeleton";
  42455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42456. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42457. /**
  42458. * Class used to render a debug view of a given skeleton
  42459. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42460. */
  42461. export class SkeletonViewer {
  42462. /** defines the skeleton to render */
  42463. skeleton: Skeleton;
  42464. /** defines the mesh attached to the skeleton */
  42465. mesh: AbstractMesh;
  42466. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42467. autoUpdateBonesMatrices: boolean;
  42468. /** defines the rendering group id to use with the viewer */
  42469. renderingGroupId: number;
  42470. /** Gets or sets the color used to render the skeleton */
  42471. color: Color3;
  42472. private _scene;
  42473. private _debugLines;
  42474. private _debugMesh;
  42475. private _isEnabled;
  42476. private _renderFunction;
  42477. private _utilityLayer;
  42478. /**
  42479. * Returns the mesh used to render the bones
  42480. */
  42481. readonly debugMesh: Nullable<LinesMesh>;
  42482. /**
  42483. * Creates a new SkeletonViewer
  42484. * @param skeleton defines the skeleton to render
  42485. * @param mesh defines the mesh attached to the skeleton
  42486. * @param scene defines the hosting scene
  42487. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42488. * @param renderingGroupId defines the rendering group id to use with the viewer
  42489. */
  42490. constructor(
  42491. /** defines the skeleton to render */
  42492. skeleton: Skeleton,
  42493. /** defines the mesh attached to the skeleton */
  42494. mesh: AbstractMesh, scene: Scene,
  42495. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42496. autoUpdateBonesMatrices?: boolean,
  42497. /** defines the rendering group id to use with the viewer */
  42498. renderingGroupId?: number);
  42499. /** Gets or sets a boolean indicating if the viewer is enabled */
  42500. isEnabled: boolean;
  42501. private _getBonePosition;
  42502. private _getLinesForBonesWithLength;
  42503. private _getLinesForBonesNoLength;
  42504. /** Update the viewer to sync with current skeleton state */
  42505. update(): void;
  42506. /** Release associated resources */
  42507. dispose(): void;
  42508. }
  42509. }
  42510. declare module "babylonjs/Debug/index" {
  42511. export * from "babylonjs/Debug/axesViewer";
  42512. export * from "babylonjs/Debug/boneAxesViewer";
  42513. export * from "babylonjs/Debug/debugLayer";
  42514. export * from "babylonjs/Debug/physicsViewer";
  42515. export * from "babylonjs/Debug/rayHelper";
  42516. export * from "babylonjs/Debug/skeletonViewer";
  42517. }
  42518. declare module "babylonjs/Engines/nullEngine" {
  42519. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42520. import { Scene } from "babylonjs/scene";
  42521. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42522. import { Engine } from "babylonjs/Engines/engine";
  42523. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42524. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42525. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42526. import { Effect } from "babylonjs/Materials/effect";
  42527. /**
  42528. * Options to create the null engine
  42529. */
  42530. export class NullEngineOptions {
  42531. /**
  42532. * Render width (Default: 512)
  42533. */
  42534. renderWidth: number;
  42535. /**
  42536. * Render height (Default: 256)
  42537. */
  42538. renderHeight: number;
  42539. /**
  42540. * Texture size (Default: 512)
  42541. */
  42542. textureSize: number;
  42543. /**
  42544. * If delta time between frames should be constant
  42545. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42546. */
  42547. deterministicLockstep: boolean;
  42548. /**
  42549. * Maximum about of steps between frames (Default: 4)
  42550. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42551. */
  42552. lockstepMaxSteps: number;
  42553. }
  42554. /**
  42555. * The null engine class provides support for headless version of babylon.js.
  42556. * This can be used in server side scenario or for testing purposes
  42557. */
  42558. export class NullEngine extends Engine {
  42559. private _options;
  42560. /**
  42561. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42562. */
  42563. isDeterministicLockStep(): boolean;
  42564. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42565. getLockstepMaxSteps(): number;
  42566. /**
  42567. * Sets hardware scaling, used to save performance if needed
  42568. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42569. */
  42570. getHardwareScalingLevel(): number;
  42571. constructor(options?: NullEngineOptions);
  42572. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42573. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42574. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42575. getRenderWidth(useScreen?: boolean): number;
  42576. getRenderHeight(useScreen?: boolean): number;
  42577. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42578. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42579. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42580. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42581. bindSamplers(effect: Effect): void;
  42582. enableEffect(effect: Effect): void;
  42583. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42584. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42585. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42586. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42587. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42588. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42589. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42590. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42591. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42592. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42593. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42594. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42595. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42596. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42597. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42598. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42599. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42600. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42601. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42602. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42603. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42604. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42605. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42606. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42607. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42608. bindBuffers(vertexBuffers: {
  42609. [key: string]: VertexBuffer;
  42610. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42611. wipeCaches(bruteForce?: boolean): void;
  42612. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42613. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42614. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42615. /** @hidden */
  42616. _createTexture(): WebGLTexture;
  42617. /** @hidden */
  42618. _releaseTexture(texture: InternalTexture): void;
  42619. 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;
  42620. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42621. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42622. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42623. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42624. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42625. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42626. areAllEffectsReady(): boolean;
  42627. /**
  42628. * @hidden
  42629. * Get the current error code of the webGL context
  42630. * @returns the error code
  42631. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42632. */
  42633. getError(): number;
  42634. /** @hidden */
  42635. _getUnpackAlignement(): number;
  42636. /** @hidden */
  42637. _unpackFlipY(value: boolean): void;
  42638. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42639. /**
  42640. * Updates a dynamic vertex buffer.
  42641. * @param vertexBuffer the vertex buffer to update
  42642. * @param data the data used to update the vertex buffer
  42643. * @param byteOffset the byte offset of the data (optional)
  42644. * @param byteLength the byte length of the data (optional)
  42645. */
  42646. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42647. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42648. /** @hidden */
  42649. _bindTexture(channel: number, texture: InternalTexture): void;
  42650. /** @hidden */
  42651. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42652. releaseEffects(): void;
  42653. displayLoadingUI(): void;
  42654. hideLoadingUI(): void;
  42655. /** @hidden */
  42656. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42657. /** @hidden */
  42658. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42659. /** @hidden */
  42660. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42661. /** @hidden */
  42662. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42663. }
  42664. }
  42665. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42666. import { Nullable, int } from "babylonjs/types";
  42667. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42668. /** @hidden */
  42669. export class _OcclusionDataStorage {
  42670. /** @hidden */
  42671. occlusionInternalRetryCounter: number;
  42672. /** @hidden */
  42673. isOcclusionQueryInProgress: boolean;
  42674. /** @hidden */
  42675. isOccluded: boolean;
  42676. /** @hidden */
  42677. occlusionRetryCount: number;
  42678. /** @hidden */
  42679. occlusionType: number;
  42680. /** @hidden */
  42681. occlusionQueryAlgorithmType: number;
  42682. }
  42683. module "babylonjs/Engines/engine" {
  42684. interface Engine {
  42685. /**
  42686. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42687. * @return the new query
  42688. */
  42689. createQuery(): WebGLQuery;
  42690. /**
  42691. * Delete and release a webGL query
  42692. * @param query defines the query to delete
  42693. * @return the current engine
  42694. */
  42695. deleteQuery(query: WebGLQuery): Engine;
  42696. /**
  42697. * Check if a given query has resolved and got its value
  42698. * @param query defines the query to check
  42699. * @returns true if the query got its value
  42700. */
  42701. isQueryResultAvailable(query: WebGLQuery): boolean;
  42702. /**
  42703. * Gets the value of a given query
  42704. * @param query defines the query to check
  42705. * @returns the value of the query
  42706. */
  42707. getQueryResult(query: WebGLQuery): number;
  42708. /**
  42709. * Initiates an occlusion query
  42710. * @param algorithmType defines the algorithm to use
  42711. * @param query defines the query to use
  42712. * @returns the current engine
  42713. * @see http://doc.babylonjs.com/features/occlusionquery
  42714. */
  42715. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42716. /**
  42717. * Ends an occlusion query
  42718. * @see http://doc.babylonjs.com/features/occlusionquery
  42719. * @param algorithmType defines the algorithm to use
  42720. * @returns the current engine
  42721. */
  42722. endOcclusionQuery(algorithmType: number): Engine;
  42723. /**
  42724. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42725. * Please note that only one query can be issued at a time
  42726. * @returns a time token used to track the time span
  42727. */
  42728. startTimeQuery(): Nullable<_TimeToken>;
  42729. /**
  42730. * Ends a time query
  42731. * @param token defines the token used to measure the time span
  42732. * @returns the time spent (in ns)
  42733. */
  42734. endTimeQuery(token: _TimeToken): int;
  42735. /** @hidden */
  42736. _currentNonTimestampToken: Nullable<_TimeToken>;
  42737. /** @hidden */
  42738. _createTimeQuery(): WebGLQuery;
  42739. /** @hidden */
  42740. _deleteTimeQuery(query: WebGLQuery): void;
  42741. /** @hidden */
  42742. _getGlAlgorithmType(algorithmType: number): number;
  42743. /** @hidden */
  42744. _getTimeQueryResult(query: WebGLQuery): any;
  42745. /** @hidden */
  42746. _getTimeQueryAvailability(query: WebGLQuery): any;
  42747. }
  42748. }
  42749. module "babylonjs/Meshes/abstractMesh" {
  42750. interface AbstractMesh {
  42751. /**
  42752. * Backing filed
  42753. * @hidden
  42754. */
  42755. __occlusionDataStorage: _OcclusionDataStorage;
  42756. /**
  42757. * Access property
  42758. * @hidden
  42759. */
  42760. _occlusionDataStorage: _OcclusionDataStorage;
  42761. /**
  42762. * 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.
  42763. * The default value is -1 which means don't break the query and wait till the result
  42764. * @see http://doc.babylonjs.com/features/occlusionquery
  42765. */
  42766. occlusionRetryCount: number;
  42767. /**
  42768. * 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:
  42769. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42770. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42771. * * 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.
  42772. * @see http://doc.babylonjs.com/features/occlusionquery
  42773. */
  42774. occlusionType: number;
  42775. /**
  42776. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42777. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42778. * * 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.
  42779. * @see http://doc.babylonjs.com/features/occlusionquery
  42780. */
  42781. occlusionQueryAlgorithmType: number;
  42782. /**
  42783. * 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
  42784. * @see http://doc.babylonjs.com/features/occlusionquery
  42785. */
  42786. isOccluded: boolean;
  42787. /**
  42788. * Flag to check the progress status of the query
  42789. * @see http://doc.babylonjs.com/features/occlusionquery
  42790. */
  42791. isOcclusionQueryInProgress: boolean;
  42792. }
  42793. }
  42794. }
  42795. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42796. import { Nullable } from "babylonjs/types";
  42797. /** @hidden */
  42798. export var _forceTransformFeedbackToBundle: boolean;
  42799. module "babylonjs/Engines/engine" {
  42800. interface Engine {
  42801. /**
  42802. * Creates a webGL transform feedback object
  42803. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42804. * @returns the webGL transform feedback object
  42805. */
  42806. createTransformFeedback(): WebGLTransformFeedback;
  42807. /**
  42808. * Delete a webGL transform feedback object
  42809. * @param value defines the webGL transform feedback object to delete
  42810. */
  42811. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42812. /**
  42813. * Bind a webGL transform feedback object to the webgl context
  42814. * @param value defines the webGL transform feedback object to bind
  42815. */
  42816. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42817. /**
  42818. * Begins a transform feedback operation
  42819. * @param usePoints defines if points or triangles must be used
  42820. */
  42821. beginTransformFeedback(usePoints: boolean): void;
  42822. /**
  42823. * Ends a transform feedback operation
  42824. */
  42825. endTransformFeedback(): void;
  42826. /**
  42827. * Specify the varyings to use with transform feedback
  42828. * @param program defines the associated webGL program
  42829. * @param value defines the list of strings representing the varying names
  42830. */
  42831. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42832. /**
  42833. * Bind a webGL buffer for a transform feedback operation
  42834. * @param value defines the webGL buffer to bind
  42835. */
  42836. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42837. }
  42838. }
  42839. }
  42840. declare module "babylonjs/Engines/Extensions/index" {
  42841. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42842. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42843. export * from "babylonjs/Engines/Extensions/engine.multiview";
  42844. }
  42845. declare module "babylonjs/Engines/index" {
  42846. export * from "babylonjs/Engines/constants";
  42847. export * from "babylonjs/Engines/engine";
  42848. export * from "babylonjs/Engines/engineStore";
  42849. export * from "babylonjs/Engines/nullEngine";
  42850. export * from "babylonjs/Engines/Extensions/index";
  42851. }
  42852. declare module "babylonjs/Events/clipboardEvents" {
  42853. /**
  42854. * Gather the list of clipboard event types as constants.
  42855. */
  42856. export class ClipboardEventTypes {
  42857. /**
  42858. * The clipboard event is fired when a copy command is active (pressed).
  42859. */
  42860. static readonly COPY: number;
  42861. /**
  42862. * The clipboard event is fired when a cut command is active (pressed).
  42863. */
  42864. static readonly CUT: number;
  42865. /**
  42866. * The clipboard event is fired when a paste command is active (pressed).
  42867. */
  42868. static readonly PASTE: number;
  42869. }
  42870. /**
  42871. * This class is used to store clipboard related info for the onClipboardObservable event.
  42872. */
  42873. export class ClipboardInfo {
  42874. /**
  42875. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42876. */
  42877. type: number;
  42878. /**
  42879. * Defines the related dom event
  42880. */
  42881. event: ClipboardEvent;
  42882. /**
  42883. *Creates an instance of ClipboardInfo.
  42884. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42885. * @param event Defines the related dom event
  42886. */
  42887. constructor(
  42888. /**
  42889. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42890. */
  42891. type: number,
  42892. /**
  42893. * Defines the related dom event
  42894. */
  42895. event: ClipboardEvent);
  42896. /**
  42897. * Get the clipboard event's type from the keycode.
  42898. * @param keyCode Defines the keyCode for the current keyboard event.
  42899. * @return {number}
  42900. */
  42901. static GetTypeFromCharacter(keyCode: number): number;
  42902. }
  42903. }
  42904. declare module "babylonjs/Events/index" {
  42905. export * from "babylonjs/Events/keyboardEvents";
  42906. export * from "babylonjs/Events/pointerEvents";
  42907. export * from "babylonjs/Events/clipboardEvents";
  42908. }
  42909. declare module "babylonjs/Loading/sceneLoader" {
  42910. import { Observable } from "babylonjs/Misc/observable";
  42911. import { Nullable } from "babylonjs/types";
  42912. import { Scene } from "babylonjs/scene";
  42913. import { Engine } from "babylonjs/Engines/engine";
  42914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42915. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42916. import { AssetContainer } from "babylonjs/assetContainer";
  42917. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42918. import { Skeleton } from "babylonjs/Bones/skeleton";
  42919. /**
  42920. * Class used to represent data loading progression
  42921. */
  42922. export class SceneLoaderProgressEvent {
  42923. /** defines if data length to load can be evaluated */
  42924. readonly lengthComputable: boolean;
  42925. /** defines the loaded data length */
  42926. readonly loaded: number;
  42927. /** defines the data length to load */
  42928. readonly total: number;
  42929. /**
  42930. * Create a new progress event
  42931. * @param lengthComputable defines if data length to load can be evaluated
  42932. * @param loaded defines the loaded data length
  42933. * @param total defines the data length to load
  42934. */
  42935. constructor(
  42936. /** defines if data length to load can be evaluated */
  42937. lengthComputable: boolean,
  42938. /** defines the loaded data length */
  42939. loaded: number,
  42940. /** defines the data length to load */
  42941. total: number);
  42942. /**
  42943. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42944. * @param event defines the source event
  42945. * @returns a new SceneLoaderProgressEvent
  42946. */
  42947. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42948. }
  42949. /**
  42950. * Interface used by SceneLoader plugins to define supported file extensions
  42951. */
  42952. export interface ISceneLoaderPluginExtensions {
  42953. /**
  42954. * Defines the list of supported extensions
  42955. */
  42956. [extension: string]: {
  42957. isBinary: boolean;
  42958. };
  42959. }
  42960. /**
  42961. * Interface used by SceneLoader plugin factory
  42962. */
  42963. export interface ISceneLoaderPluginFactory {
  42964. /**
  42965. * Defines the name of the factory
  42966. */
  42967. name: string;
  42968. /**
  42969. * Function called to create a new plugin
  42970. * @return the new plugin
  42971. */
  42972. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42973. /**
  42974. * Boolean indicating if the plugin can direct load specific data
  42975. */
  42976. canDirectLoad?: (data: string) => boolean;
  42977. }
  42978. /**
  42979. * Interface used to define a SceneLoader plugin
  42980. */
  42981. export interface ISceneLoaderPlugin {
  42982. /**
  42983. * The friendly name of this plugin.
  42984. */
  42985. name: string;
  42986. /**
  42987. * The file extensions supported by this plugin.
  42988. */
  42989. extensions: string | ISceneLoaderPluginExtensions;
  42990. /**
  42991. * Import meshes into a scene.
  42992. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42993. * @param scene The scene to import into
  42994. * @param data The data to import
  42995. * @param rootUrl The root url for scene and resources
  42996. * @param meshes The meshes array to import into
  42997. * @param particleSystems The particle systems array to import into
  42998. * @param skeletons The skeletons array to import into
  42999. * @param onError The callback when import fails
  43000. * @returns True if successful or false otherwise
  43001. */
  43002. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43003. /**
  43004. * Load into a scene.
  43005. * @param scene The scene to load into
  43006. * @param data The data to import
  43007. * @param rootUrl The root url for scene and resources
  43008. * @param onError The callback when import fails
  43009. * @returns true if successful or false otherwise
  43010. */
  43011. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43012. /**
  43013. * The callback that returns true if the data can be directly loaded.
  43014. */
  43015. canDirectLoad?: (data: string) => boolean;
  43016. /**
  43017. * The callback that allows custom handling of the root url based on the response url.
  43018. */
  43019. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43020. /**
  43021. * Load into an asset container.
  43022. * @param scene The scene to load into
  43023. * @param data The data to import
  43024. * @param rootUrl The root url for scene and resources
  43025. * @param onError The callback when import fails
  43026. * @returns The loaded asset container
  43027. */
  43028. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43029. }
  43030. /**
  43031. * Interface used to define an async SceneLoader plugin
  43032. */
  43033. export interface ISceneLoaderPluginAsync {
  43034. /**
  43035. * The friendly name of this plugin.
  43036. */
  43037. name: string;
  43038. /**
  43039. * The file extensions supported by this plugin.
  43040. */
  43041. extensions: string | ISceneLoaderPluginExtensions;
  43042. /**
  43043. * Import meshes into a scene.
  43044. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43045. * @param scene The scene to import into
  43046. * @param data The data to import
  43047. * @param rootUrl The root url for scene and resources
  43048. * @param onProgress The callback when the load progresses
  43049. * @param fileName Defines the name of the file to load
  43050. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43051. */
  43052. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43053. meshes: AbstractMesh[];
  43054. particleSystems: IParticleSystem[];
  43055. skeletons: Skeleton[];
  43056. animationGroups: AnimationGroup[];
  43057. }>;
  43058. /**
  43059. * Load into a scene.
  43060. * @param scene The scene to load into
  43061. * @param data The data to import
  43062. * @param rootUrl The root url for scene and resources
  43063. * @param onProgress The callback when the load progresses
  43064. * @param fileName Defines the name of the file to load
  43065. * @returns Nothing
  43066. */
  43067. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43068. /**
  43069. * The callback that returns true if the data can be directly loaded.
  43070. */
  43071. canDirectLoad?: (data: string) => boolean;
  43072. /**
  43073. * The callback that allows custom handling of the root url based on the response url.
  43074. */
  43075. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43076. /**
  43077. * Load into an asset container.
  43078. * @param scene The scene to load into
  43079. * @param data The data to import
  43080. * @param rootUrl The root url for scene and resources
  43081. * @param onProgress The callback when the load progresses
  43082. * @param fileName Defines the name of the file to load
  43083. * @returns The loaded asset container
  43084. */
  43085. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43086. }
  43087. /**
  43088. * Class used to load scene from various file formats using registered plugins
  43089. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43090. */
  43091. export class SceneLoader {
  43092. /**
  43093. * No logging while loading
  43094. */
  43095. static readonly NO_LOGGING: number;
  43096. /**
  43097. * Minimal logging while loading
  43098. */
  43099. static readonly MINIMAL_LOGGING: number;
  43100. /**
  43101. * Summary logging while loading
  43102. */
  43103. static readonly SUMMARY_LOGGING: number;
  43104. /**
  43105. * Detailled logging while loading
  43106. */
  43107. static readonly DETAILED_LOGGING: number;
  43108. /**
  43109. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43110. */
  43111. static ForceFullSceneLoadingForIncremental: boolean;
  43112. /**
  43113. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43114. */
  43115. static ShowLoadingScreen: boolean;
  43116. /**
  43117. * Defines the current logging level (while loading the scene)
  43118. * @ignorenaming
  43119. */
  43120. static loggingLevel: number;
  43121. /**
  43122. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43123. */
  43124. static CleanBoneMatrixWeights: boolean;
  43125. /**
  43126. * Event raised when a plugin is used to load a scene
  43127. */
  43128. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43129. private static _registeredPlugins;
  43130. private static _getDefaultPlugin;
  43131. private static _getPluginForExtension;
  43132. private static _getPluginForDirectLoad;
  43133. private static _getPluginForFilename;
  43134. private static _getDirectLoad;
  43135. private static _loadData;
  43136. private static _getFileInfo;
  43137. /**
  43138. * Gets a plugin that can load the given extension
  43139. * @param extension defines the extension to load
  43140. * @returns a plugin or null if none works
  43141. */
  43142. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43143. /**
  43144. * Gets a boolean indicating that the given extension can be loaded
  43145. * @param extension defines the extension to load
  43146. * @returns true if the extension is supported
  43147. */
  43148. static IsPluginForExtensionAvailable(extension: string): boolean;
  43149. /**
  43150. * Adds a new plugin to the list of registered plugins
  43151. * @param plugin defines the plugin to add
  43152. */
  43153. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43154. /**
  43155. * Import meshes into a scene
  43156. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43157. * @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)
  43158. * @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)
  43159. * @param scene the instance of BABYLON.Scene to append to
  43160. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43161. * @param onProgress a callback with a progress event for each file being loaded
  43162. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43163. * @param pluginExtension the extension used to determine the plugin
  43164. * @returns The loaded plugin
  43165. */
  43166. 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>;
  43167. /**
  43168. * Import meshes into a scene
  43169. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43170. * @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)
  43171. * @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)
  43172. * @param scene the instance of BABYLON.Scene to append to
  43173. * @param onProgress a callback with a progress event for each file being loaded
  43174. * @param pluginExtension the extension used to determine the plugin
  43175. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43176. */
  43177. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43178. meshes: AbstractMesh[];
  43179. particleSystems: IParticleSystem[];
  43180. skeletons: Skeleton[];
  43181. animationGroups: AnimationGroup[];
  43182. }>;
  43183. /**
  43184. * Load a scene
  43185. * @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)
  43186. * @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)
  43187. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43188. * @param onSuccess a callback with the scene when import succeeds
  43189. * @param onProgress a callback with a progress event for each file being loaded
  43190. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43191. * @param pluginExtension the extension used to determine the plugin
  43192. * @returns The loaded plugin
  43193. */
  43194. 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>;
  43195. /**
  43196. * Load a scene
  43197. * @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)
  43198. * @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)
  43199. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43200. * @param onProgress a callback with a progress event for each file being loaded
  43201. * @param pluginExtension the extension used to determine the plugin
  43202. * @returns The loaded scene
  43203. */
  43204. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43205. /**
  43206. * Append a scene
  43207. * @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)
  43208. * @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)
  43209. * @param scene is the instance of BABYLON.Scene to append to
  43210. * @param onSuccess a callback with the scene when import succeeds
  43211. * @param onProgress a callback with a progress event for each file being loaded
  43212. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43213. * @param pluginExtension the extension used to determine the plugin
  43214. * @returns The loaded plugin
  43215. */
  43216. 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>;
  43217. /**
  43218. * Append a scene
  43219. * @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)
  43220. * @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)
  43221. * @param scene is the instance of BABYLON.Scene to append to
  43222. * @param onProgress a callback with a progress event for each file being loaded
  43223. * @param pluginExtension the extension used to determine the plugin
  43224. * @returns The given scene
  43225. */
  43226. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43227. /**
  43228. * Load a scene into an asset container
  43229. * @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)
  43230. * @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)
  43231. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43232. * @param onSuccess a callback with the scene when import succeeds
  43233. * @param onProgress a callback with a progress event for each file being loaded
  43234. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43235. * @param pluginExtension the extension used to determine the plugin
  43236. * @returns The loaded plugin
  43237. */
  43238. 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>;
  43239. /**
  43240. * Load a scene into an asset container
  43241. * @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)
  43242. * @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)
  43243. * @param scene is the instance of Scene to append to
  43244. * @param onProgress a callback with a progress event for each file being loaded
  43245. * @param pluginExtension the extension used to determine the plugin
  43246. * @returns The loaded asset container
  43247. */
  43248. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43249. }
  43250. }
  43251. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43252. import { Scene } from "babylonjs/scene";
  43253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43254. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43255. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43256. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43257. /**
  43258. * Google Daydream controller
  43259. */
  43260. export class DaydreamController extends WebVRController {
  43261. /**
  43262. * Base Url for the controller model.
  43263. */
  43264. static MODEL_BASE_URL: string;
  43265. /**
  43266. * File name for the controller model.
  43267. */
  43268. static MODEL_FILENAME: string;
  43269. /**
  43270. * Gamepad Id prefix used to identify Daydream Controller.
  43271. */
  43272. static readonly GAMEPAD_ID_PREFIX: string;
  43273. /**
  43274. * Creates a new DaydreamController from a gamepad
  43275. * @param vrGamepad the gamepad that the controller should be created from
  43276. */
  43277. constructor(vrGamepad: any);
  43278. /**
  43279. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43280. * @param scene scene in which to add meshes
  43281. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43282. */
  43283. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43284. /**
  43285. * Called once for each button that changed state since the last frame
  43286. * @param buttonIdx Which button index changed
  43287. * @param state New state of the button
  43288. * @param changes Which properties on the state changed since last frame
  43289. */
  43290. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43291. }
  43292. }
  43293. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43294. import { Scene } from "babylonjs/scene";
  43295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43296. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43297. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43298. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43299. /**
  43300. * Gear VR Controller
  43301. */
  43302. export class GearVRController extends WebVRController {
  43303. /**
  43304. * Base Url for the controller model.
  43305. */
  43306. static MODEL_BASE_URL: string;
  43307. /**
  43308. * File name for the controller model.
  43309. */
  43310. static MODEL_FILENAME: string;
  43311. /**
  43312. * Gamepad Id prefix used to identify this controller.
  43313. */
  43314. static readonly GAMEPAD_ID_PREFIX: string;
  43315. private readonly _buttonIndexToObservableNameMap;
  43316. /**
  43317. * Creates a new GearVRController from a gamepad
  43318. * @param vrGamepad the gamepad that the controller should be created from
  43319. */
  43320. constructor(vrGamepad: any);
  43321. /**
  43322. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43323. * @param scene scene in which to add meshes
  43324. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43325. */
  43326. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43327. /**
  43328. * Called once for each button that changed state since the last frame
  43329. * @param buttonIdx Which button index changed
  43330. * @param state New state of the button
  43331. * @param changes Which properties on the state changed since last frame
  43332. */
  43333. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43334. }
  43335. }
  43336. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43337. import { Scene } from "babylonjs/scene";
  43338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43339. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43340. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43341. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43342. /**
  43343. * Generic Controller
  43344. */
  43345. export class GenericController extends WebVRController {
  43346. /**
  43347. * Base Url for the controller model.
  43348. */
  43349. static readonly MODEL_BASE_URL: string;
  43350. /**
  43351. * File name for the controller model.
  43352. */
  43353. static readonly MODEL_FILENAME: string;
  43354. /**
  43355. * Creates a new GenericController from a gamepad
  43356. * @param vrGamepad the gamepad that the controller should be created from
  43357. */
  43358. constructor(vrGamepad: any);
  43359. /**
  43360. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43361. * @param scene scene in which to add meshes
  43362. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43363. */
  43364. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43365. /**
  43366. * Called once for each button that changed state since the last frame
  43367. * @param buttonIdx Which button index changed
  43368. * @param state New state of the button
  43369. * @param changes Which properties on the state changed since last frame
  43370. */
  43371. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43372. }
  43373. }
  43374. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43375. import { Observable } from "babylonjs/Misc/observable";
  43376. import { Scene } from "babylonjs/scene";
  43377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43378. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43379. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43380. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43381. /**
  43382. * Oculus Touch Controller
  43383. */
  43384. export class OculusTouchController extends WebVRController {
  43385. /**
  43386. * Base Url for the controller model.
  43387. */
  43388. static MODEL_BASE_URL: string;
  43389. /**
  43390. * File name for the left controller model.
  43391. */
  43392. static MODEL_LEFT_FILENAME: string;
  43393. /**
  43394. * File name for the right controller model.
  43395. */
  43396. static MODEL_RIGHT_FILENAME: string;
  43397. /**
  43398. * Fired when the secondary trigger on this controller is modified
  43399. */
  43400. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43401. /**
  43402. * Fired when the thumb rest on this controller is modified
  43403. */
  43404. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43405. /**
  43406. * Creates a new OculusTouchController from a gamepad
  43407. * @param vrGamepad the gamepad that the controller should be created from
  43408. */
  43409. constructor(vrGamepad: any);
  43410. /**
  43411. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43412. * @param scene scene in which to add meshes
  43413. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43414. */
  43415. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43416. /**
  43417. * Fired when the A button on this controller is modified
  43418. */
  43419. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43420. /**
  43421. * Fired when the B button on this controller is modified
  43422. */
  43423. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43424. /**
  43425. * Fired when the X button on this controller is modified
  43426. */
  43427. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43428. /**
  43429. * Fired when the Y button on this controller is modified
  43430. */
  43431. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43432. /**
  43433. * Called once for each button that changed state since the last frame
  43434. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43435. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43436. * 2) secondary trigger (same)
  43437. * 3) A (right) X (left), touch, pressed = value
  43438. * 4) B / Y
  43439. * 5) thumb rest
  43440. * @param buttonIdx Which button index changed
  43441. * @param state New state of the button
  43442. * @param changes Which properties on the state changed since last frame
  43443. */
  43444. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43445. }
  43446. }
  43447. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43448. import { Scene } from "babylonjs/scene";
  43449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43450. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43451. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43452. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43453. import { Observable } from "babylonjs/Misc/observable";
  43454. /**
  43455. * Vive Controller
  43456. */
  43457. export class ViveController extends WebVRController {
  43458. /**
  43459. * Base Url for the controller model.
  43460. */
  43461. static MODEL_BASE_URL: string;
  43462. /**
  43463. * File name for the controller model.
  43464. */
  43465. static MODEL_FILENAME: string;
  43466. /**
  43467. * Creates a new ViveController from a gamepad
  43468. * @param vrGamepad the gamepad that the controller should be created from
  43469. */
  43470. constructor(vrGamepad: any);
  43471. /**
  43472. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43473. * @param scene scene in which to add meshes
  43474. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43475. */
  43476. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43477. /**
  43478. * Fired when the left button on this controller is modified
  43479. */
  43480. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43481. /**
  43482. * Fired when the right button on this controller is modified
  43483. */
  43484. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43485. /**
  43486. * Fired when the menu button on this controller is modified
  43487. */
  43488. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43489. /**
  43490. * Called once for each button that changed state since the last frame
  43491. * Vive mapping:
  43492. * 0: touchpad
  43493. * 1: trigger
  43494. * 2: left AND right buttons
  43495. * 3: menu button
  43496. * @param buttonIdx Which button index changed
  43497. * @param state New state of the button
  43498. * @param changes Which properties on the state changed since last frame
  43499. */
  43500. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43501. }
  43502. }
  43503. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43504. import { Observable } from "babylonjs/Misc/observable";
  43505. import { Scene } from "babylonjs/scene";
  43506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43507. import { Ray } from "babylonjs/Culling/ray";
  43508. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43509. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43510. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43511. /**
  43512. * Defines the WindowsMotionController object that the state of the windows motion controller
  43513. */
  43514. export class WindowsMotionController extends WebVRController {
  43515. /**
  43516. * The base url used to load the left and right controller models
  43517. */
  43518. static MODEL_BASE_URL: string;
  43519. /**
  43520. * The name of the left controller model file
  43521. */
  43522. static MODEL_LEFT_FILENAME: string;
  43523. /**
  43524. * The name of the right controller model file
  43525. */
  43526. static MODEL_RIGHT_FILENAME: string;
  43527. /**
  43528. * The controller name prefix for this controller type
  43529. */
  43530. static readonly GAMEPAD_ID_PREFIX: string;
  43531. /**
  43532. * The controller id pattern for this controller type
  43533. */
  43534. private static readonly GAMEPAD_ID_PATTERN;
  43535. private _loadedMeshInfo;
  43536. private readonly _mapping;
  43537. /**
  43538. * Fired when the trackpad on this controller is clicked
  43539. */
  43540. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43541. /**
  43542. * Fired when the trackpad on this controller is modified
  43543. */
  43544. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43545. /**
  43546. * The current x and y values of this controller's trackpad
  43547. */
  43548. trackpad: StickValues;
  43549. /**
  43550. * Creates a new WindowsMotionController from a gamepad
  43551. * @param vrGamepad the gamepad that the controller should be created from
  43552. */
  43553. constructor(vrGamepad: any);
  43554. /**
  43555. * Fired when the trigger on this controller is modified
  43556. */
  43557. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43558. /**
  43559. * Fired when the menu button on this controller is modified
  43560. */
  43561. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43562. /**
  43563. * Fired when the grip button on this controller is modified
  43564. */
  43565. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43566. /**
  43567. * Fired when the thumbstick button on this controller is modified
  43568. */
  43569. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43570. /**
  43571. * Fired when the touchpad button on this controller is modified
  43572. */
  43573. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43574. /**
  43575. * Fired when the touchpad values on this controller are modified
  43576. */
  43577. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43578. private _updateTrackpad;
  43579. /**
  43580. * Called once per frame by the engine.
  43581. */
  43582. update(): void;
  43583. /**
  43584. * Called once for each button that changed state since the last frame
  43585. * @param buttonIdx Which button index changed
  43586. * @param state New state of the button
  43587. * @param changes Which properties on the state changed since last frame
  43588. */
  43589. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43590. /**
  43591. * Moves the buttons on the controller mesh based on their current state
  43592. * @param buttonName the name of the button to move
  43593. * @param buttonValue the value of the button which determines the buttons new position
  43594. */
  43595. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43596. /**
  43597. * Moves the axis on the controller mesh based on its current state
  43598. * @param axis the index of the axis
  43599. * @param axisValue the value of the axis which determines the meshes new position
  43600. * @hidden
  43601. */
  43602. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43603. /**
  43604. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43605. * @param scene scene in which to add meshes
  43606. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43607. */
  43608. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43609. /**
  43610. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43611. * can be transformed by button presses and axes values, based on this._mapping.
  43612. *
  43613. * @param scene scene in which the meshes exist
  43614. * @param meshes list of meshes that make up the controller model to process
  43615. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43616. */
  43617. private processModel;
  43618. private createMeshInfo;
  43619. /**
  43620. * Gets the ray of the controller in the direction the controller is pointing
  43621. * @param length the length the resulting ray should be
  43622. * @returns a ray in the direction the controller is pointing
  43623. */
  43624. getForwardRay(length?: number): Ray;
  43625. /**
  43626. * Disposes of the controller
  43627. */
  43628. dispose(): void;
  43629. }
  43630. }
  43631. declare module "babylonjs/Gamepads/Controllers/index" {
  43632. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43633. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43634. export * from "babylonjs/Gamepads/Controllers/genericController";
  43635. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43636. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43637. export * from "babylonjs/Gamepads/Controllers/viveController";
  43638. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43639. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43640. }
  43641. declare module "babylonjs/Gamepads/index" {
  43642. export * from "babylonjs/Gamepads/Controllers/index";
  43643. export * from "babylonjs/Gamepads/gamepad";
  43644. export * from "babylonjs/Gamepads/gamepadManager";
  43645. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43646. export * from "babylonjs/Gamepads/xboxGamepad";
  43647. }
  43648. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43649. import { Observable } from "babylonjs/Misc/observable";
  43650. import { Nullable } from "babylonjs/types";
  43651. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43653. import { Mesh } from "babylonjs/Meshes/mesh";
  43654. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43655. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43656. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43657. /**
  43658. * Single axis scale gizmo
  43659. */
  43660. export class AxisScaleGizmo extends Gizmo {
  43661. private _coloredMaterial;
  43662. /**
  43663. * Drag behavior responsible for the gizmos dragging interactions
  43664. */
  43665. dragBehavior: PointerDragBehavior;
  43666. private _pointerObserver;
  43667. /**
  43668. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43669. */
  43670. snapDistance: number;
  43671. /**
  43672. * Event that fires each time the gizmo snaps to a new location.
  43673. * * snapDistance is the the change in distance
  43674. */
  43675. onSnapObservable: Observable<{
  43676. snapDistance: number;
  43677. }>;
  43678. /**
  43679. * If the scaling operation should be done on all axis (default: false)
  43680. */
  43681. uniformScaling: boolean;
  43682. /**
  43683. * Creates an AxisScaleGizmo
  43684. * @param gizmoLayer The utility layer the gizmo will be added to
  43685. * @param dragAxis The axis which the gizmo will be able to scale on
  43686. * @param color The color of the gizmo
  43687. */
  43688. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43689. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43690. /**
  43691. * Disposes of the gizmo
  43692. */
  43693. dispose(): void;
  43694. /**
  43695. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43696. * @param mesh The mesh to replace the default mesh of the gizmo
  43697. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43698. */
  43699. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43700. }
  43701. }
  43702. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43703. import { Observable } from "babylonjs/Misc/observable";
  43704. import { Nullable } from "babylonjs/types";
  43705. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43707. import { Mesh } from "babylonjs/Meshes/mesh";
  43708. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43709. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43710. import "babylonjs/Meshes/Builders/boxBuilder";
  43711. /**
  43712. * Bounding box gizmo
  43713. */
  43714. export class BoundingBoxGizmo extends Gizmo {
  43715. private _lineBoundingBox;
  43716. private _rotateSpheresParent;
  43717. private _scaleBoxesParent;
  43718. private _boundingDimensions;
  43719. private _renderObserver;
  43720. private _pointerObserver;
  43721. private _scaleDragSpeed;
  43722. private _tmpQuaternion;
  43723. private _tmpVector;
  43724. private _tmpRotationMatrix;
  43725. /**
  43726. * 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)
  43727. */
  43728. ignoreChildren: boolean;
  43729. /**
  43730. * 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)
  43731. */
  43732. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43733. /**
  43734. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43735. */
  43736. rotationSphereSize: number;
  43737. /**
  43738. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43739. */
  43740. scaleBoxSize: number;
  43741. /**
  43742. * 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)
  43743. */
  43744. fixedDragMeshScreenSize: boolean;
  43745. /**
  43746. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43747. */
  43748. fixedDragMeshScreenSizeDistanceFactor: number;
  43749. /**
  43750. * Fired when a rotation sphere or scale box is dragged
  43751. */
  43752. onDragStartObservable: Observable<{}>;
  43753. /**
  43754. * Fired when a scale box is dragged
  43755. */
  43756. onScaleBoxDragObservable: Observable<{}>;
  43757. /**
  43758. * Fired when a scale box drag is ended
  43759. */
  43760. onScaleBoxDragEndObservable: Observable<{}>;
  43761. /**
  43762. * Fired when a rotation sphere is dragged
  43763. */
  43764. onRotationSphereDragObservable: Observable<{}>;
  43765. /**
  43766. * Fired when a rotation sphere drag is ended
  43767. */
  43768. onRotationSphereDragEndObservable: Observable<{}>;
  43769. /**
  43770. * 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)
  43771. */
  43772. scalePivot: Nullable<Vector3>;
  43773. private _anchorMesh;
  43774. private _existingMeshScale;
  43775. private _dragMesh;
  43776. private pointerDragBehavior;
  43777. private coloredMaterial;
  43778. private hoverColoredMaterial;
  43779. /**
  43780. * Sets the color of the bounding box gizmo
  43781. * @param color the color to set
  43782. */
  43783. setColor(color: Color3): void;
  43784. /**
  43785. * Creates an BoundingBoxGizmo
  43786. * @param gizmoLayer The utility layer the gizmo will be added to
  43787. * @param color The color of the gizmo
  43788. */
  43789. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43790. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43791. private _selectNode;
  43792. /**
  43793. * Updates the bounding box information for the Gizmo
  43794. */
  43795. updateBoundingBox(): void;
  43796. private _updateRotationSpheres;
  43797. private _updateScaleBoxes;
  43798. /**
  43799. * Enables rotation on the specified axis and disables rotation on the others
  43800. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43801. */
  43802. setEnabledRotationAxis(axis: string): void;
  43803. /**
  43804. * Enables/disables scaling
  43805. * @param enable if scaling should be enabled
  43806. */
  43807. setEnabledScaling(enable: boolean): void;
  43808. private _updateDummy;
  43809. /**
  43810. * Enables a pointer drag behavior on the bounding box of the gizmo
  43811. */
  43812. enableDragBehavior(): void;
  43813. /**
  43814. * Disposes of the gizmo
  43815. */
  43816. dispose(): void;
  43817. /**
  43818. * 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)
  43819. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43820. * @returns the bounding box mesh with the passed in mesh as a child
  43821. */
  43822. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43823. /**
  43824. * CustomMeshes are not supported by this gizmo
  43825. * @param mesh The mesh to replace the default mesh of the gizmo
  43826. */
  43827. setCustomMesh(mesh: Mesh): void;
  43828. }
  43829. }
  43830. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43831. import { Observable } from "babylonjs/Misc/observable";
  43832. import { Nullable } from "babylonjs/types";
  43833. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43835. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43836. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43837. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43838. import "babylonjs/Meshes/Builders/linesBuilder";
  43839. /**
  43840. * Single plane rotation gizmo
  43841. */
  43842. export class PlaneRotationGizmo extends Gizmo {
  43843. /**
  43844. * Drag behavior responsible for the gizmos dragging interactions
  43845. */
  43846. dragBehavior: PointerDragBehavior;
  43847. private _pointerObserver;
  43848. /**
  43849. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43850. */
  43851. snapDistance: number;
  43852. /**
  43853. * Event that fires each time the gizmo snaps to a new location.
  43854. * * snapDistance is the the change in distance
  43855. */
  43856. onSnapObservable: Observable<{
  43857. snapDistance: number;
  43858. }>;
  43859. /**
  43860. * Creates a PlaneRotationGizmo
  43861. * @param gizmoLayer The utility layer the gizmo will be added to
  43862. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43863. * @param color The color of the gizmo
  43864. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43865. */
  43866. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43867. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43868. /**
  43869. * Disposes of the gizmo
  43870. */
  43871. dispose(): void;
  43872. }
  43873. }
  43874. declare module "babylonjs/Gizmos/rotationGizmo" {
  43875. import { Observable } from "babylonjs/Misc/observable";
  43876. import { Nullable } from "babylonjs/types";
  43877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43878. import { Mesh } from "babylonjs/Meshes/mesh";
  43879. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43880. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43881. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43882. /**
  43883. * Gizmo that enables rotating a mesh along 3 axis
  43884. */
  43885. export class RotationGizmo extends Gizmo {
  43886. /**
  43887. * Internal gizmo used for interactions on the x axis
  43888. */
  43889. xGizmo: PlaneRotationGizmo;
  43890. /**
  43891. * Internal gizmo used for interactions on the y axis
  43892. */
  43893. yGizmo: PlaneRotationGizmo;
  43894. /**
  43895. * Internal gizmo used for interactions on the z axis
  43896. */
  43897. zGizmo: PlaneRotationGizmo;
  43898. /** Fires an event when any of it's sub gizmos are dragged */
  43899. onDragStartObservable: Observable<{}>;
  43900. /** Fires an event when any of it's sub gizmos are released from dragging */
  43901. onDragEndObservable: Observable<{}>;
  43902. attachedMesh: Nullable<AbstractMesh>;
  43903. /**
  43904. * Creates a RotationGizmo
  43905. * @param gizmoLayer The utility layer the gizmo will be added to
  43906. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43907. */
  43908. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43909. updateGizmoRotationToMatchAttachedMesh: boolean;
  43910. /**
  43911. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43912. */
  43913. snapDistance: number;
  43914. /**
  43915. * Ratio for the scale of the gizmo (Default: 1)
  43916. */
  43917. scaleRatio: number;
  43918. /**
  43919. * Disposes of the gizmo
  43920. */
  43921. dispose(): void;
  43922. /**
  43923. * CustomMeshes are not supported by this gizmo
  43924. * @param mesh The mesh to replace the default mesh of the gizmo
  43925. */
  43926. setCustomMesh(mesh: Mesh): void;
  43927. }
  43928. }
  43929. declare module "babylonjs/Gizmos/positionGizmo" {
  43930. import { Observable } from "babylonjs/Misc/observable";
  43931. import { Nullable } from "babylonjs/types";
  43932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43933. import { Mesh } from "babylonjs/Meshes/mesh";
  43934. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43935. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43936. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43937. /**
  43938. * Gizmo that enables dragging a mesh along 3 axis
  43939. */
  43940. export class PositionGizmo extends Gizmo {
  43941. /**
  43942. * Internal gizmo used for interactions on the x axis
  43943. */
  43944. xGizmo: AxisDragGizmo;
  43945. /**
  43946. * Internal gizmo used for interactions on the y axis
  43947. */
  43948. yGizmo: AxisDragGizmo;
  43949. /**
  43950. * Internal gizmo used for interactions on the z axis
  43951. */
  43952. zGizmo: AxisDragGizmo;
  43953. /** Fires an event when any of it's sub gizmos are dragged */
  43954. onDragStartObservable: Observable<{}>;
  43955. /** Fires an event when any of it's sub gizmos are released from dragging */
  43956. onDragEndObservable: Observable<{}>;
  43957. attachedMesh: Nullable<AbstractMesh>;
  43958. /**
  43959. * Creates a PositionGizmo
  43960. * @param gizmoLayer The utility layer the gizmo will be added to
  43961. */
  43962. constructor(gizmoLayer?: UtilityLayerRenderer);
  43963. updateGizmoRotationToMatchAttachedMesh: boolean;
  43964. /**
  43965. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43966. */
  43967. snapDistance: number;
  43968. /**
  43969. * Ratio for the scale of the gizmo (Default: 1)
  43970. */
  43971. scaleRatio: number;
  43972. /**
  43973. * Disposes of the gizmo
  43974. */
  43975. dispose(): void;
  43976. /**
  43977. * CustomMeshes are not supported by this gizmo
  43978. * @param mesh The mesh to replace the default mesh of the gizmo
  43979. */
  43980. setCustomMesh(mesh: Mesh): void;
  43981. }
  43982. }
  43983. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43984. import { Scene } from "babylonjs/scene";
  43985. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43986. import { Mesh } from "babylonjs/Meshes/mesh";
  43987. /**
  43988. * Class containing static functions to help procedurally build meshes
  43989. */
  43990. export class PolyhedronBuilder {
  43991. /**
  43992. * Creates a polyhedron mesh
  43993. * * 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
  43994. * * The parameter `size` (positive float, default 1) sets the polygon size
  43995. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43996. * * 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`
  43997. * * 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
  43998. * * 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)`)
  43999. * * 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
  44000. * * 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
  44001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44004. * @param name defines the name of the mesh
  44005. * @param options defines the options used to create the mesh
  44006. * @param scene defines the hosting scene
  44007. * @returns the polyhedron mesh
  44008. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44009. */
  44010. static CreatePolyhedron(name: string, options: {
  44011. type?: number;
  44012. size?: number;
  44013. sizeX?: number;
  44014. sizeY?: number;
  44015. sizeZ?: number;
  44016. custom?: any;
  44017. faceUV?: Vector4[];
  44018. faceColors?: Color4[];
  44019. flat?: boolean;
  44020. updatable?: boolean;
  44021. sideOrientation?: number;
  44022. frontUVs?: Vector4;
  44023. backUVs?: Vector4;
  44024. }, scene: Scene): Mesh;
  44025. }
  44026. }
  44027. declare module "babylonjs/Gizmos/scaleGizmo" {
  44028. import { Observable } from "babylonjs/Misc/observable";
  44029. import { Nullable } from "babylonjs/types";
  44030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44031. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44032. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44033. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44034. /**
  44035. * Gizmo that enables scaling a mesh along 3 axis
  44036. */
  44037. export class ScaleGizmo extends Gizmo {
  44038. /**
  44039. * Internal gizmo used for interactions on the x axis
  44040. */
  44041. xGizmo: AxisScaleGizmo;
  44042. /**
  44043. * Internal gizmo used for interactions on the y axis
  44044. */
  44045. yGizmo: AxisScaleGizmo;
  44046. /**
  44047. * Internal gizmo used for interactions on the z axis
  44048. */
  44049. zGizmo: AxisScaleGizmo;
  44050. /**
  44051. * Internal gizmo used to scale all axis equally
  44052. */
  44053. uniformScaleGizmo: AxisScaleGizmo;
  44054. /** Fires an event when any of it's sub gizmos are dragged */
  44055. onDragStartObservable: Observable<{}>;
  44056. /** Fires an event when any of it's sub gizmos are released from dragging */
  44057. onDragEndObservable: Observable<{}>;
  44058. attachedMesh: Nullable<AbstractMesh>;
  44059. /**
  44060. * Creates a ScaleGizmo
  44061. * @param gizmoLayer The utility layer the gizmo will be added to
  44062. */
  44063. constructor(gizmoLayer?: UtilityLayerRenderer);
  44064. updateGizmoRotationToMatchAttachedMesh: boolean;
  44065. /**
  44066. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44067. */
  44068. snapDistance: number;
  44069. /**
  44070. * Ratio for the scale of the gizmo (Default: 1)
  44071. */
  44072. scaleRatio: number;
  44073. /**
  44074. * Disposes of the gizmo
  44075. */
  44076. dispose(): void;
  44077. }
  44078. }
  44079. declare module "babylonjs/Gizmos/gizmoManager" {
  44080. import { Observable } from "babylonjs/Misc/observable";
  44081. import { Nullable } from "babylonjs/types";
  44082. import { Scene, IDisposable } from "babylonjs/scene";
  44083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44084. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44085. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44086. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44087. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44088. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44089. /**
  44090. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44091. */
  44092. export class GizmoManager implements IDisposable {
  44093. private scene;
  44094. /**
  44095. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44096. */
  44097. gizmos: {
  44098. positionGizmo: Nullable<PositionGizmo>;
  44099. rotationGizmo: Nullable<RotationGizmo>;
  44100. scaleGizmo: Nullable<ScaleGizmo>;
  44101. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44102. };
  44103. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44104. clearGizmoOnEmptyPointerEvent: boolean;
  44105. /** Fires an event when the manager is attached to a mesh */
  44106. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44107. private _gizmosEnabled;
  44108. private _pointerObserver;
  44109. private _attachedMesh;
  44110. private _boundingBoxColor;
  44111. private _defaultUtilityLayer;
  44112. private _defaultKeepDepthUtilityLayer;
  44113. /**
  44114. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44115. */
  44116. boundingBoxDragBehavior: SixDofDragBehavior;
  44117. /**
  44118. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44119. */
  44120. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44121. /**
  44122. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44123. */
  44124. usePointerToAttachGizmos: boolean;
  44125. /**
  44126. * Instatiates a gizmo manager
  44127. * @param scene the scene to overlay the gizmos on top of
  44128. */
  44129. constructor(scene: Scene);
  44130. /**
  44131. * Attaches a set of gizmos to the specified mesh
  44132. * @param mesh The mesh the gizmo's should be attached to
  44133. */
  44134. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44135. /**
  44136. * If the position gizmo is enabled
  44137. */
  44138. positionGizmoEnabled: boolean;
  44139. /**
  44140. * If the rotation gizmo is enabled
  44141. */
  44142. rotationGizmoEnabled: boolean;
  44143. /**
  44144. * If the scale gizmo is enabled
  44145. */
  44146. scaleGizmoEnabled: boolean;
  44147. /**
  44148. * If the boundingBox gizmo is enabled
  44149. */
  44150. boundingBoxGizmoEnabled: boolean;
  44151. /**
  44152. * Disposes of the gizmo manager
  44153. */
  44154. dispose(): void;
  44155. }
  44156. }
  44157. declare module "babylonjs/Lights/directionalLight" {
  44158. import { Camera } from "babylonjs/Cameras/camera";
  44159. import { Scene } from "babylonjs/scene";
  44160. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44162. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44163. import { Effect } from "babylonjs/Materials/effect";
  44164. /**
  44165. * A directional light is defined by a direction (what a surprise!).
  44166. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44167. * 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.
  44168. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44169. */
  44170. export class DirectionalLight extends ShadowLight {
  44171. private _shadowFrustumSize;
  44172. /**
  44173. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44174. */
  44175. /**
  44176. * Specifies a fix frustum size for the shadow generation.
  44177. */
  44178. shadowFrustumSize: number;
  44179. private _shadowOrthoScale;
  44180. /**
  44181. * Gets the shadow projection scale against the optimal computed one.
  44182. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44183. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44184. */
  44185. /**
  44186. * Sets the shadow projection scale against the optimal computed one.
  44187. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44188. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44189. */
  44190. shadowOrthoScale: number;
  44191. /**
  44192. * Automatically compute the projection matrix to best fit (including all the casters)
  44193. * on each frame.
  44194. */
  44195. autoUpdateExtends: boolean;
  44196. private _orthoLeft;
  44197. private _orthoRight;
  44198. private _orthoTop;
  44199. private _orthoBottom;
  44200. /**
  44201. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44202. * The directional light is emitted from everywhere in the given direction.
  44203. * It can cast shadows.
  44204. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44205. * @param name The friendly name of the light
  44206. * @param direction The direction of the light
  44207. * @param scene The scene the light belongs to
  44208. */
  44209. constructor(name: string, direction: Vector3, scene: Scene);
  44210. /**
  44211. * Returns the string "DirectionalLight".
  44212. * @return The class name
  44213. */
  44214. getClassName(): string;
  44215. /**
  44216. * Returns the integer 1.
  44217. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44218. */
  44219. getTypeID(): number;
  44220. /**
  44221. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44222. * Returns the DirectionalLight Shadow projection matrix.
  44223. */
  44224. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44225. /**
  44226. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44227. * Returns the DirectionalLight Shadow projection matrix.
  44228. */
  44229. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44230. /**
  44231. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44232. * Returns the DirectionalLight Shadow projection matrix.
  44233. */
  44234. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44235. protected _buildUniformLayout(): void;
  44236. /**
  44237. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44238. * @param effect The effect to update
  44239. * @param lightIndex The index of the light in the effect to update
  44240. * @returns The directional light
  44241. */
  44242. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44243. /**
  44244. * Gets the minZ used for shadow according to both the scene and the light.
  44245. *
  44246. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44247. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44248. * @param activeCamera The camera we are returning the min for
  44249. * @returns the depth min z
  44250. */
  44251. getDepthMinZ(activeCamera: Camera): number;
  44252. /**
  44253. * Gets the maxZ used for shadow according to both the scene and the light.
  44254. *
  44255. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44256. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44257. * @param activeCamera The camera we are returning the max for
  44258. * @returns the depth max z
  44259. */
  44260. getDepthMaxZ(activeCamera: Camera): number;
  44261. /**
  44262. * Prepares the list of defines specific to the light type.
  44263. * @param defines the list of defines
  44264. * @param lightIndex defines the index of the light for the effect
  44265. */
  44266. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44267. }
  44268. }
  44269. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44270. import { Mesh } from "babylonjs/Meshes/mesh";
  44271. /**
  44272. * Class containing static functions to help procedurally build meshes
  44273. */
  44274. export class HemisphereBuilder {
  44275. /**
  44276. * Creates a hemisphere mesh
  44277. * @param name defines the name of the mesh
  44278. * @param options defines the options used to create the mesh
  44279. * @param scene defines the hosting scene
  44280. * @returns the hemisphere mesh
  44281. */
  44282. static CreateHemisphere(name: string, options: {
  44283. segments?: number;
  44284. diameter?: number;
  44285. sideOrientation?: number;
  44286. }, scene: any): Mesh;
  44287. }
  44288. }
  44289. declare module "babylonjs/Lights/spotLight" {
  44290. import { Nullable } from "babylonjs/types";
  44291. import { Scene } from "babylonjs/scene";
  44292. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44294. import { Effect } from "babylonjs/Materials/effect";
  44295. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44296. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44297. /**
  44298. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44299. * These values define a cone of light starting from the position, emitting toward the direction.
  44300. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44301. * and the exponent defines the speed of the decay of the light with distance (reach).
  44302. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44303. */
  44304. export class SpotLight extends ShadowLight {
  44305. private _angle;
  44306. private _innerAngle;
  44307. private _cosHalfAngle;
  44308. private _lightAngleScale;
  44309. private _lightAngleOffset;
  44310. /**
  44311. * Gets the cone angle of the spot light in Radians.
  44312. */
  44313. /**
  44314. * Sets the cone angle of the spot light in Radians.
  44315. */
  44316. angle: number;
  44317. /**
  44318. * Only used in gltf falloff mode, this defines the angle where
  44319. * the directional falloff will start before cutting at angle which could be seen
  44320. * as outer angle.
  44321. */
  44322. /**
  44323. * Only used in gltf falloff mode, this defines the angle where
  44324. * the directional falloff will start before cutting at angle which could be seen
  44325. * as outer angle.
  44326. */
  44327. innerAngle: number;
  44328. private _shadowAngleScale;
  44329. /**
  44330. * Allows scaling the angle of the light for shadow generation only.
  44331. */
  44332. /**
  44333. * Allows scaling the angle of the light for shadow generation only.
  44334. */
  44335. shadowAngleScale: number;
  44336. /**
  44337. * The light decay speed with the distance from the emission spot.
  44338. */
  44339. exponent: number;
  44340. private _projectionTextureMatrix;
  44341. /**
  44342. * Allows reading the projecton texture
  44343. */
  44344. readonly projectionTextureMatrix: Matrix;
  44345. protected _projectionTextureLightNear: number;
  44346. /**
  44347. * Gets the near clip of the Spotlight for texture projection.
  44348. */
  44349. /**
  44350. * Sets the near clip of the Spotlight for texture projection.
  44351. */
  44352. projectionTextureLightNear: number;
  44353. protected _projectionTextureLightFar: number;
  44354. /**
  44355. * Gets the far clip of the Spotlight for texture projection.
  44356. */
  44357. /**
  44358. * Sets the far clip of the Spotlight for texture projection.
  44359. */
  44360. projectionTextureLightFar: number;
  44361. protected _projectionTextureUpDirection: Vector3;
  44362. /**
  44363. * Gets the Up vector of the Spotlight for texture projection.
  44364. */
  44365. /**
  44366. * Sets the Up vector of the Spotlight for texture projection.
  44367. */
  44368. projectionTextureUpDirection: Vector3;
  44369. private _projectionTexture;
  44370. /**
  44371. * Gets the projection texture of the light.
  44372. */
  44373. /**
  44374. * Sets the projection texture of the light.
  44375. */
  44376. projectionTexture: Nullable<BaseTexture>;
  44377. private _projectionTextureViewLightDirty;
  44378. private _projectionTextureProjectionLightDirty;
  44379. private _projectionTextureDirty;
  44380. private _projectionTextureViewTargetVector;
  44381. private _projectionTextureViewLightMatrix;
  44382. private _projectionTextureProjectionLightMatrix;
  44383. private _projectionTextureScalingMatrix;
  44384. /**
  44385. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44386. * It can cast shadows.
  44387. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44388. * @param name The light friendly name
  44389. * @param position The position of the spot light in the scene
  44390. * @param direction The direction of the light in the scene
  44391. * @param angle The cone angle of the light in Radians
  44392. * @param exponent The light decay speed with the distance from the emission spot
  44393. * @param scene The scene the lights belongs to
  44394. */
  44395. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44396. /**
  44397. * Returns the string "SpotLight".
  44398. * @returns the class name
  44399. */
  44400. getClassName(): string;
  44401. /**
  44402. * Returns the integer 2.
  44403. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44404. */
  44405. getTypeID(): number;
  44406. /**
  44407. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44408. */
  44409. protected _setDirection(value: Vector3): void;
  44410. /**
  44411. * Overrides the position setter to recompute the projection texture view light Matrix.
  44412. */
  44413. protected _setPosition(value: Vector3): void;
  44414. /**
  44415. * 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.
  44416. * Returns the SpotLight.
  44417. */
  44418. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44419. protected _computeProjectionTextureViewLightMatrix(): void;
  44420. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44421. /**
  44422. * Main function for light texture projection matrix computing.
  44423. */
  44424. protected _computeProjectionTextureMatrix(): void;
  44425. protected _buildUniformLayout(): void;
  44426. private _computeAngleValues;
  44427. /**
  44428. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44429. * @param effect The effect to update
  44430. * @param lightIndex The index of the light in the effect to update
  44431. * @returns The spot light
  44432. */
  44433. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44434. /**
  44435. * Disposes the light and the associated resources.
  44436. */
  44437. dispose(): void;
  44438. /**
  44439. * Prepares the list of defines specific to the light type.
  44440. * @param defines the list of defines
  44441. * @param lightIndex defines the index of the light for the effect
  44442. */
  44443. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44444. }
  44445. }
  44446. declare module "babylonjs/Gizmos/lightGizmo" {
  44447. import { Nullable } from "babylonjs/types";
  44448. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44449. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44450. import { Light } from "babylonjs/Lights/light";
  44451. /**
  44452. * Gizmo that enables viewing a light
  44453. */
  44454. export class LightGizmo extends Gizmo {
  44455. private _lightMesh;
  44456. private _material;
  44457. /**
  44458. * Creates a LightGizmo
  44459. * @param gizmoLayer The utility layer the gizmo will be added to
  44460. */
  44461. constructor(gizmoLayer?: UtilityLayerRenderer);
  44462. private _light;
  44463. /**
  44464. * The light that the gizmo is attached to
  44465. */
  44466. light: Nullable<Light>;
  44467. /**
  44468. * @hidden
  44469. * Updates the gizmo to match the attached mesh's position/rotation
  44470. */
  44471. protected _update(): void;
  44472. private static _Scale;
  44473. /**
  44474. * Creates the lines for a light mesh
  44475. */
  44476. private static _createLightLines;
  44477. private static _CreateHemisphericLightMesh;
  44478. private static _CreatePointLightMesh;
  44479. private static _CreateSpotLightMesh;
  44480. private static _CreateDirectionalLightMesh;
  44481. }
  44482. }
  44483. declare module "babylonjs/Gizmos/index" {
  44484. export * from "babylonjs/Gizmos/axisDragGizmo";
  44485. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44486. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44487. export * from "babylonjs/Gizmos/gizmo";
  44488. export * from "babylonjs/Gizmos/gizmoManager";
  44489. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44490. export * from "babylonjs/Gizmos/positionGizmo";
  44491. export * from "babylonjs/Gizmos/rotationGizmo";
  44492. export * from "babylonjs/Gizmos/scaleGizmo";
  44493. export * from "babylonjs/Gizmos/lightGizmo";
  44494. }
  44495. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44496. /** @hidden */
  44497. export var backgroundFragmentDeclaration: {
  44498. name: string;
  44499. shader: string;
  44500. };
  44501. }
  44502. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44503. /** @hidden */
  44504. export var backgroundUboDeclaration: {
  44505. name: string;
  44506. shader: string;
  44507. };
  44508. }
  44509. declare module "babylonjs/Shaders/background.fragment" {
  44510. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44511. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44512. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44513. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44514. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44515. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44516. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44517. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44518. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44519. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44520. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44521. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44522. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44523. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44524. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44525. /** @hidden */
  44526. export var backgroundPixelShader: {
  44527. name: string;
  44528. shader: string;
  44529. };
  44530. }
  44531. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44532. /** @hidden */
  44533. export var backgroundVertexDeclaration: {
  44534. name: string;
  44535. shader: string;
  44536. };
  44537. }
  44538. declare module "babylonjs/Shaders/background.vertex" {
  44539. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44540. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44541. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44542. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44543. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44544. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44545. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44546. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44547. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44548. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44549. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44550. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44551. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44552. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44553. /** @hidden */
  44554. export var backgroundVertexShader: {
  44555. name: string;
  44556. shader: string;
  44557. };
  44558. }
  44559. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44560. import { Nullable, int, float } from "babylonjs/types";
  44561. import { Scene } from "babylonjs/scene";
  44562. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44563. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44565. import { Mesh } from "babylonjs/Meshes/mesh";
  44566. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44567. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44568. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44569. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44570. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44571. import "babylonjs/Shaders/background.fragment";
  44572. import "babylonjs/Shaders/background.vertex";
  44573. /**
  44574. * Background material used to create an efficient environement around your scene.
  44575. */
  44576. export class BackgroundMaterial extends PushMaterial {
  44577. /**
  44578. * Standard reflectance value at parallel view angle.
  44579. */
  44580. static StandardReflectance0: number;
  44581. /**
  44582. * Standard reflectance value at grazing angle.
  44583. */
  44584. static StandardReflectance90: number;
  44585. protected _primaryColor: Color3;
  44586. /**
  44587. * Key light Color (multiply against the environement texture)
  44588. */
  44589. primaryColor: Color3;
  44590. protected __perceptualColor: Nullable<Color3>;
  44591. /**
  44592. * Experimental Internal Use Only.
  44593. *
  44594. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44595. * This acts as a helper to set the primary color to a more "human friendly" value.
  44596. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44597. * output color as close as possible from the chosen value.
  44598. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44599. * part of lighting setup.)
  44600. */
  44601. _perceptualColor: Nullable<Color3>;
  44602. protected _primaryColorShadowLevel: float;
  44603. /**
  44604. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44605. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44606. */
  44607. primaryColorShadowLevel: float;
  44608. protected _primaryColorHighlightLevel: float;
  44609. /**
  44610. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44611. * The primary color is used at the level chosen to define what the white area would look.
  44612. */
  44613. primaryColorHighlightLevel: float;
  44614. protected _reflectionTexture: Nullable<BaseTexture>;
  44615. /**
  44616. * Reflection Texture used in the material.
  44617. * Should be author in a specific way for the best result (refer to the documentation).
  44618. */
  44619. reflectionTexture: Nullable<BaseTexture>;
  44620. protected _reflectionBlur: float;
  44621. /**
  44622. * Reflection Texture level of blur.
  44623. *
  44624. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44625. * texture twice.
  44626. */
  44627. reflectionBlur: float;
  44628. protected _diffuseTexture: Nullable<BaseTexture>;
  44629. /**
  44630. * Diffuse Texture used in the material.
  44631. * Should be author in a specific way for the best result (refer to the documentation).
  44632. */
  44633. diffuseTexture: Nullable<BaseTexture>;
  44634. protected _shadowLights: Nullable<IShadowLight[]>;
  44635. /**
  44636. * Specify the list of lights casting shadow on the material.
  44637. * All scene shadow lights will be included if null.
  44638. */
  44639. shadowLights: Nullable<IShadowLight[]>;
  44640. protected _shadowLevel: float;
  44641. /**
  44642. * Helps adjusting the shadow to a softer level if required.
  44643. * 0 means black shadows and 1 means no shadows.
  44644. */
  44645. shadowLevel: float;
  44646. protected _sceneCenter: Vector3;
  44647. /**
  44648. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44649. * It is usually zero but might be interesting to modify according to your setup.
  44650. */
  44651. sceneCenter: Vector3;
  44652. protected _opacityFresnel: boolean;
  44653. /**
  44654. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44655. * This helps ensuring a nice transition when the camera goes under the ground.
  44656. */
  44657. opacityFresnel: boolean;
  44658. protected _reflectionFresnel: boolean;
  44659. /**
  44660. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44661. * This helps adding a mirror texture on the ground.
  44662. */
  44663. reflectionFresnel: boolean;
  44664. protected _reflectionFalloffDistance: number;
  44665. /**
  44666. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44667. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44668. */
  44669. reflectionFalloffDistance: number;
  44670. protected _reflectionAmount: number;
  44671. /**
  44672. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44673. */
  44674. reflectionAmount: number;
  44675. protected _reflectionReflectance0: number;
  44676. /**
  44677. * This specifies the weight of the reflection at grazing angle.
  44678. */
  44679. reflectionReflectance0: number;
  44680. protected _reflectionReflectance90: number;
  44681. /**
  44682. * This specifies the weight of the reflection at a perpendicular point of view.
  44683. */
  44684. reflectionReflectance90: number;
  44685. /**
  44686. * Sets the reflection reflectance fresnel values according to the default standard
  44687. * empirically know to work well :-)
  44688. */
  44689. reflectionStandardFresnelWeight: number;
  44690. protected _useRGBColor: boolean;
  44691. /**
  44692. * Helps to directly use the maps channels instead of their level.
  44693. */
  44694. useRGBColor: boolean;
  44695. protected _enableNoise: boolean;
  44696. /**
  44697. * This helps reducing the banding effect that could occur on the background.
  44698. */
  44699. enableNoise: boolean;
  44700. /**
  44701. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44702. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44703. * Recommended to be keep at 1.0 except for special cases.
  44704. */
  44705. fovMultiplier: number;
  44706. private _fovMultiplier;
  44707. /**
  44708. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44709. */
  44710. useEquirectangularFOV: boolean;
  44711. private _maxSimultaneousLights;
  44712. /**
  44713. * Number of Simultaneous lights allowed on the material.
  44714. */
  44715. maxSimultaneousLights: int;
  44716. /**
  44717. * Default configuration related to image processing available in the Background Material.
  44718. */
  44719. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44720. /**
  44721. * Keep track of the image processing observer to allow dispose and replace.
  44722. */
  44723. private _imageProcessingObserver;
  44724. /**
  44725. * Attaches a new image processing configuration to the PBR Material.
  44726. * @param configuration (if null the scene configuration will be use)
  44727. */
  44728. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44729. /**
  44730. * Gets the image processing configuration used either in this material.
  44731. */
  44732. /**
  44733. * Sets the Default image processing configuration used either in the this material.
  44734. *
  44735. * If sets to null, the scene one is in use.
  44736. */
  44737. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44738. /**
  44739. * Gets wether the color curves effect is enabled.
  44740. */
  44741. /**
  44742. * Sets wether the color curves effect is enabled.
  44743. */
  44744. cameraColorCurvesEnabled: boolean;
  44745. /**
  44746. * Gets wether the color grading effect is enabled.
  44747. */
  44748. /**
  44749. * Gets wether the color grading effect is enabled.
  44750. */
  44751. cameraColorGradingEnabled: boolean;
  44752. /**
  44753. * Gets wether tonemapping is enabled or not.
  44754. */
  44755. /**
  44756. * Sets wether tonemapping is enabled or not
  44757. */
  44758. cameraToneMappingEnabled: boolean;
  44759. /**
  44760. * The camera exposure used on this material.
  44761. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44762. * This corresponds to a photographic exposure.
  44763. */
  44764. /**
  44765. * The camera exposure used on this material.
  44766. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44767. * This corresponds to a photographic exposure.
  44768. */
  44769. cameraExposure: float;
  44770. /**
  44771. * Gets The camera contrast used on this material.
  44772. */
  44773. /**
  44774. * Sets The camera contrast used on this material.
  44775. */
  44776. cameraContrast: float;
  44777. /**
  44778. * Gets the Color Grading 2D Lookup Texture.
  44779. */
  44780. /**
  44781. * Sets the Color Grading 2D Lookup Texture.
  44782. */
  44783. cameraColorGradingTexture: Nullable<BaseTexture>;
  44784. /**
  44785. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44786. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44787. * 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;
  44788. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44789. */
  44790. /**
  44791. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44792. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44793. * 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;
  44794. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44795. */
  44796. cameraColorCurves: Nullable<ColorCurves>;
  44797. /**
  44798. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44799. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44800. */
  44801. switchToBGR: boolean;
  44802. private _renderTargets;
  44803. private _reflectionControls;
  44804. private _white;
  44805. private _primaryShadowColor;
  44806. private _primaryHighlightColor;
  44807. /**
  44808. * Instantiates a Background Material in the given scene
  44809. * @param name The friendly name of the material
  44810. * @param scene The scene to add the material to
  44811. */
  44812. constructor(name: string, scene: Scene);
  44813. /**
  44814. * Gets a boolean indicating that current material needs to register RTT
  44815. */
  44816. readonly hasRenderTargetTextures: boolean;
  44817. /**
  44818. * The entire material has been created in order to prevent overdraw.
  44819. * @returns false
  44820. */
  44821. needAlphaTesting(): boolean;
  44822. /**
  44823. * The entire material has been created in order to prevent overdraw.
  44824. * @returns true if blending is enable
  44825. */
  44826. needAlphaBlending(): boolean;
  44827. /**
  44828. * Checks wether the material is ready to be rendered for a given mesh.
  44829. * @param mesh The mesh to render
  44830. * @param subMesh The submesh to check against
  44831. * @param useInstances Specify wether or not the material is used with instances
  44832. * @returns true if all the dependencies are ready (Textures, Effects...)
  44833. */
  44834. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44835. /**
  44836. * Compute the primary color according to the chosen perceptual color.
  44837. */
  44838. private _computePrimaryColorFromPerceptualColor;
  44839. /**
  44840. * Compute the highlights and shadow colors according to their chosen levels.
  44841. */
  44842. private _computePrimaryColors;
  44843. /**
  44844. * Build the uniform buffer used in the material.
  44845. */
  44846. buildUniformLayout(): void;
  44847. /**
  44848. * Unbind the material.
  44849. */
  44850. unbind(): void;
  44851. /**
  44852. * Bind only the world matrix to the material.
  44853. * @param world The world matrix to bind.
  44854. */
  44855. bindOnlyWorldMatrix(world: Matrix): void;
  44856. /**
  44857. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44858. * @param world The world matrix to bind.
  44859. * @param subMesh The submesh to bind for.
  44860. */
  44861. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44862. /**
  44863. * Dispose the material.
  44864. * @param forceDisposeEffect Force disposal of the associated effect.
  44865. * @param forceDisposeTextures Force disposal of the associated textures.
  44866. */
  44867. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44868. /**
  44869. * Clones the material.
  44870. * @param name The cloned name.
  44871. * @returns The cloned material.
  44872. */
  44873. clone(name: string): BackgroundMaterial;
  44874. /**
  44875. * Serializes the current material to its JSON representation.
  44876. * @returns The JSON representation.
  44877. */
  44878. serialize(): any;
  44879. /**
  44880. * Gets the class name of the material
  44881. * @returns "BackgroundMaterial"
  44882. */
  44883. getClassName(): string;
  44884. /**
  44885. * Parse a JSON input to create back a background material.
  44886. * @param source The JSON data to parse
  44887. * @param scene The scene to create the parsed material in
  44888. * @param rootUrl The root url of the assets the material depends upon
  44889. * @returns the instantiated BackgroundMaterial.
  44890. */
  44891. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44892. }
  44893. }
  44894. declare module "babylonjs/Helpers/environmentHelper" {
  44895. import { Observable } from "babylonjs/Misc/observable";
  44896. import { Nullable } from "babylonjs/types";
  44897. import { Scene } from "babylonjs/scene";
  44898. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44900. import { Mesh } from "babylonjs/Meshes/mesh";
  44901. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44902. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44903. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44904. import "babylonjs/Meshes/Builders/planeBuilder";
  44905. import "babylonjs/Meshes/Builders/boxBuilder";
  44906. /**
  44907. * Represents the different options available during the creation of
  44908. * a Environment helper.
  44909. *
  44910. * This can control the default ground, skybox and image processing setup of your scene.
  44911. */
  44912. export interface IEnvironmentHelperOptions {
  44913. /**
  44914. * Specifies wether or not to create a ground.
  44915. * True by default.
  44916. */
  44917. createGround: boolean;
  44918. /**
  44919. * Specifies the ground size.
  44920. * 15 by default.
  44921. */
  44922. groundSize: number;
  44923. /**
  44924. * The texture used on the ground for the main color.
  44925. * Comes from the BabylonJS CDN by default.
  44926. *
  44927. * Remarks: Can be either a texture or a url.
  44928. */
  44929. groundTexture: string | BaseTexture;
  44930. /**
  44931. * The color mixed in the ground texture by default.
  44932. * BabylonJS clearColor by default.
  44933. */
  44934. groundColor: Color3;
  44935. /**
  44936. * Specifies the ground opacity.
  44937. * 1 by default.
  44938. */
  44939. groundOpacity: number;
  44940. /**
  44941. * Enables the ground to receive shadows.
  44942. * True by default.
  44943. */
  44944. enableGroundShadow: boolean;
  44945. /**
  44946. * Helps preventing the shadow to be fully black on the ground.
  44947. * 0.5 by default.
  44948. */
  44949. groundShadowLevel: number;
  44950. /**
  44951. * Creates a mirror texture attach to the ground.
  44952. * false by default.
  44953. */
  44954. enableGroundMirror: boolean;
  44955. /**
  44956. * Specifies the ground mirror size ratio.
  44957. * 0.3 by default as the default kernel is 64.
  44958. */
  44959. groundMirrorSizeRatio: number;
  44960. /**
  44961. * Specifies the ground mirror blur kernel size.
  44962. * 64 by default.
  44963. */
  44964. groundMirrorBlurKernel: number;
  44965. /**
  44966. * Specifies the ground mirror visibility amount.
  44967. * 1 by default
  44968. */
  44969. groundMirrorAmount: number;
  44970. /**
  44971. * Specifies the ground mirror reflectance weight.
  44972. * This uses the standard weight of the background material to setup the fresnel effect
  44973. * of the mirror.
  44974. * 1 by default.
  44975. */
  44976. groundMirrorFresnelWeight: number;
  44977. /**
  44978. * Specifies the ground mirror Falloff distance.
  44979. * This can helps reducing the size of the reflection.
  44980. * 0 by Default.
  44981. */
  44982. groundMirrorFallOffDistance: number;
  44983. /**
  44984. * Specifies the ground mirror texture type.
  44985. * Unsigned Int by Default.
  44986. */
  44987. groundMirrorTextureType: number;
  44988. /**
  44989. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44990. * the shown objects.
  44991. */
  44992. groundYBias: number;
  44993. /**
  44994. * Specifies wether or not to create a skybox.
  44995. * True by default.
  44996. */
  44997. createSkybox: boolean;
  44998. /**
  44999. * Specifies the skybox size.
  45000. * 20 by default.
  45001. */
  45002. skyboxSize: number;
  45003. /**
  45004. * The texture used on the skybox for the main color.
  45005. * Comes from the BabylonJS CDN by default.
  45006. *
  45007. * Remarks: Can be either a texture or a url.
  45008. */
  45009. skyboxTexture: string | BaseTexture;
  45010. /**
  45011. * The color mixed in the skybox texture by default.
  45012. * BabylonJS clearColor by default.
  45013. */
  45014. skyboxColor: Color3;
  45015. /**
  45016. * The background rotation around the Y axis of the scene.
  45017. * This helps aligning the key lights of your scene with the background.
  45018. * 0 by default.
  45019. */
  45020. backgroundYRotation: number;
  45021. /**
  45022. * Compute automatically the size of the elements to best fit with the scene.
  45023. */
  45024. sizeAuto: boolean;
  45025. /**
  45026. * Default position of the rootMesh if autoSize is not true.
  45027. */
  45028. rootPosition: Vector3;
  45029. /**
  45030. * Sets up the image processing in the scene.
  45031. * true by default.
  45032. */
  45033. setupImageProcessing: boolean;
  45034. /**
  45035. * The texture used as your environment texture in the scene.
  45036. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45037. *
  45038. * Remarks: Can be either a texture or a url.
  45039. */
  45040. environmentTexture: string | BaseTexture;
  45041. /**
  45042. * The value of the exposure to apply to the scene.
  45043. * 0.6 by default if setupImageProcessing is true.
  45044. */
  45045. cameraExposure: number;
  45046. /**
  45047. * The value of the contrast to apply to the scene.
  45048. * 1.6 by default if setupImageProcessing is true.
  45049. */
  45050. cameraContrast: number;
  45051. /**
  45052. * Specifies wether or not tonemapping should be enabled in the scene.
  45053. * true by default if setupImageProcessing is true.
  45054. */
  45055. toneMappingEnabled: boolean;
  45056. }
  45057. /**
  45058. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45059. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45060. * It also helps with the default setup of your imageProcessing configuration.
  45061. */
  45062. export class EnvironmentHelper {
  45063. /**
  45064. * Default ground texture URL.
  45065. */
  45066. private static _groundTextureCDNUrl;
  45067. /**
  45068. * Default skybox texture URL.
  45069. */
  45070. private static _skyboxTextureCDNUrl;
  45071. /**
  45072. * Default environment texture URL.
  45073. */
  45074. private static _environmentTextureCDNUrl;
  45075. /**
  45076. * Creates the default options for the helper.
  45077. */
  45078. private static _getDefaultOptions;
  45079. private _rootMesh;
  45080. /**
  45081. * Gets the root mesh created by the helper.
  45082. */
  45083. readonly rootMesh: Mesh;
  45084. private _skybox;
  45085. /**
  45086. * Gets the skybox created by the helper.
  45087. */
  45088. readonly skybox: Nullable<Mesh>;
  45089. private _skyboxTexture;
  45090. /**
  45091. * Gets the skybox texture created by the helper.
  45092. */
  45093. readonly skyboxTexture: Nullable<BaseTexture>;
  45094. private _skyboxMaterial;
  45095. /**
  45096. * Gets the skybox material created by the helper.
  45097. */
  45098. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45099. private _ground;
  45100. /**
  45101. * Gets the ground mesh created by the helper.
  45102. */
  45103. readonly ground: Nullable<Mesh>;
  45104. private _groundTexture;
  45105. /**
  45106. * Gets the ground texture created by the helper.
  45107. */
  45108. readonly groundTexture: Nullable<BaseTexture>;
  45109. private _groundMirror;
  45110. /**
  45111. * Gets the ground mirror created by the helper.
  45112. */
  45113. readonly groundMirror: Nullable<MirrorTexture>;
  45114. /**
  45115. * Gets the ground mirror render list to helps pushing the meshes
  45116. * you wish in the ground reflection.
  45117. */
  45118. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45119. private _groundMaterial;
  45120. /**
  45121. * Gets the ground material created by the helper.
  45122. */
  45123. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45124. /**
  45125. * Stores the creation options.
  45126. */
  45127. private readonly _scene;
  45128. private _options;
  45129. /**
  45130. * This observable will be notified with any error during the creation of the environment,
  45131. * mainly texture creation errors.
  45132. */
  45133. onErrorObservable: Observable<{
  45134. message?: string;
  45135. exception?: any;
  45136. }>;
  45137. /**
  45138. * constructor
  45139. * @param options Defines the options we want to customize the helper
  45140. * @param scene The scene to add the material to
  45141. */
  45142. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45143. /**
  45144. * Updates the background according to the new options
  45145. * @param options
  45146. */
  45147. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45148. /**
  45149. * Sets the primary color of all the available elements.
  45150. * @param color the main color to affect to the ground and the background
  45151. */
  45152. setMainColor(color: Color3): void;
  45153. /**
  45154. * Setup the image processing according to the specified options.
  45155. */
  45156. private _setupImageProcessing;
  45157. /**
  45158. * Setup the environment texture according to the specified options.
  45159. */
  45160. private _setupEnvironmentTexture;
  45161. /**
  45162. * Setup the background according to the specified options.
  45163. */
  45164. private _setupBackground;
  45165. /**
  45166. * Get the scene sizes according to the setup.
  45167. */
  45168. private _getSceneSize;
  45169. /**
  45170. * Setup the ground according to the specified options.
  45171. */
  45172. private _setupGround;
  45173. /**
  45174. * Setup the ground material according to the specified options.
  45175. */
  45176. private _setupGroundMaterial;
  45177. /**
  45178. * Setup the ground diffuse texture according to the specified options.
  45179. */
  45180. private _setupGroundDiffuseTexture;
  45181. /**
  45182. * Setup the ground mirror texture according to the specified options.
  45183. */
  45184. private _setupGroundMirrorTexture;
  45185. /**
  45186. * Setup the ground to receive the mirror texture.
  45187. */
  45188. private _setupMirrorInGroundMaterial;
  45189. /**
  45190. * Setup the skybox according to the specified options.
  45191. */
  45192. private _setupSkybox;
  45193. /**
  45194. * Setup the skybox material according to the specified options.
  45195. */
  45196. private _setupSkyboxMaterial;
  45197. /**
  45198. * Setup the skybox reflection texture according to the specified options.
  45199. */
  45200. private _setupSkyboxReflectionTexture;
  45201. private _errorHandler;
  45202. /**
  45203. * Dispose all the elements created by the Helper.
  45204. */
  45205. dispose(): void;
  45206. }
  45207. }
  45208. declare module "babylonjs/Helpers/photoDome" {
  45209. import { Observable } from "babylonjs/Misc/observable";
  45210. import { Nullable } from "babylonjs/types";
  45211. import { Scene } from "babylonjs/scene";
  45212. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45213. import { Mesh } from "babylonjs/Meshes/mesh";
  45214. import { Texture } from "babylonjs/Materials/Textures/texture";
  45215. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45216. import "babylonjs/Meshes/Builders/sphereBuilder";
  45217. /**
  45218. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45219. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45220. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45221. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45222. */
  45223. export class PhotoDome extends TransformNode {
  45224. private _useDirectMapping;
  45225. /**
  45226. * The texture being displayed on the sphere
  45227. */
  45228. protected _photoTexture: Texture;
  45229. /**
  45230. * Gets or sets the texture being displayed on the sphere
  45231. */
  45232. photoTexture: Texture;
  45233. /**
  45234. * Observable raised when an error occured while loading the 360 image
  45235. */
  45236. onLoadErrorObservable: Observable<string>;
  45237. /**
  45238. * The skybox material
  45239. */
  45240. protected _material: BackgroundMaterial;
  45241. /**
  45242. * The surface used for the skybox
  45243. */
  45244. protected _mesh: Mesh;
  45245. /**
  45246. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45247. * Also see the options.resolution property.
  45248. */
  45249. fovMultiplier: number;
  45250. /**
  45251. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45252. * @param name Element's name, child elements will append suffixes for their own names.
  45253. * @param urlsOfPhoto defines the url of the photo to display
  45254. * @param options defines an object containing optional or exposed sub element properties
  45255. * @param onError defines a callback called when an error occured while loading the texture
  45256. */
  45257. constructor(name: string, urlOfPhoto: string, options: {
  45258. resolution?: number;
  45259. size?: number;
  45260. useDirectMapping?: boolean;
  45261. faceForward?: boolean;
  45262. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45263. /**
  45264. * Releases resources associated with this node.
  45265. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45266. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45267. */
  45268. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45269. }
  45270. }
  45271. declare module "babylonjs/Misc/brdfTextureTools" {
  45272. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45273. import { Scene } from "babylonjs/scene";
  45274. /**
  45275. * Class used to host texture specific utilities
  45276. */
  45277. export class BRDFTextureTools {
  45278. /**
  45279. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45280. * @param texture the texture to expand.
  45281. */
  45282. private static _ExpandDefaultBRDFTexture;
  45283. /**
  45284. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45285. * @param scene defines the hosting scene
  45286. * @returns the environment BRDF texture
  45287. */
  45288. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45289. private static _environmentBRDFBase64Texture;
  45290. }
  45291. }
  45292. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45293. import { Nullable } from "babylonjs/types";
  45294. import { IAnimatable } from "babylonjs/Misc/tools";
  45295. import { Color3 } from "babylonjs/Maths/math";
  45296. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45297. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45298. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45299. import { Engine } from "babylonjs/Engines/engine";
  45300. import { Scene } from "babylonjs/scene";
  45301. /**
  45302. * @hidden
  45303. */
  45304. export interface IMaterialClearCoatDefines {
  45305. CLEARCOAT: boolean;
  45306. CLEARCOAT_DEFAULTIOR: boolean;
  45307. CLEARCOAT_TEXTURE: boolean;
  45308. CLEARCOAT_TEXTUREDIRECTUV: number;
  45309. CLEARCOAT_BUMP: boolean;
  45310. CLEARCOAT_BUMPDIRECTUV: number;
  45311. CLEARCOAT_TINT: boolean;
  45312. CLEARCOAT_TINT_TEXTURE: boolean;
  45313. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45314. /** @hidden */
  45315. _areTexturesDirty: boolean;
  45316. }
  45317. /**
  45318. * Define the code related to the clear coat parameters of the pbr material.
  45319. */
  45320. export class PBRClearCoatConfiguration {
  45321. /**
  45322. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45323. * The default fits with a polyurethane material.
  45324. */
  45325. private static readonly _DefaultIndiceOfRefraction;
  45326. private _isEnabled;
  45327. /**
  45328. * Defines if the clear coat is enabled in the material.
  45329. */
  45330. isEnabled: boolean;
  45331. /**
  45332. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45333. */
  45334. intensity: number;
  45335. /**
  45336. * Defines the clear coat layer roughness.
  45337. */
  45338. roughness: number;
  45339. private _indiceOfRefraction;
  45340. /**
  45341. * Defines the indice of refraction of the clear coat.
  45342. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45343. * The default fits with a polyurethane material.
  45344. * Changing the default value is more performance intensive.
  45345. */
  45346. indiceOfRefraction: number;
  45347. private _texture;
  45348. /**
  45349. * Stores the clear coat values in a texture.
  45350. */
  45351. texture: Nullable<BaseTexture>;
  45352. private _bumpTexture;
  45353. /**
  45354. * Define the clear coat specific bump texture.
  45355. */
  45356. bumpTexture: Nullable<BaseTexture>;
  45357. private _isTintEnabled;
  45358. /**
  45359. * Defines if the clear coat tint is enabled in the material.
  45360. */
  45361. isTintEnabled: boolean;
  45362. /**
  45363. * Defines if the clear coat tint is enabled in the material.
  45364. * This is only use if tint is enabled
  45365. */
  45366. tintColor: Color3;
  45367. /**
  45368. * Defines if the distance at which the tint color should be found in the
  45369. * clear coat media.
  45370. * This is only use if tint is enabled
  45371. */
  45372. tintColorAtDistance: number;
  45373. /**
  45374. * Defines the clear coat layer thickness.
  45375. * This is only use if tint is enabled
  45376. */
  45377. tintThickness: number;
  45378. private _tintTexture;
  45379. /**
  45380. * Stores the clear tint values in a texture.
  45381. * rgb is tint
  45382. * a is a thickness factor
  45383. */
  45384. tintTexture: Nullable<BaseTexture>;
  45385. /** @hidden */
  45386. private _internalMarkAllSubMeshesAsTexturesDirty;
  45387. /** @hidden */
  45388. _markAllSubMeshesAsTexturesDirty(): void;
  45389. /**
  45390. * Instantiate a new istance of clear coat configuration.
  45391. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45392. */
  45393. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45394. /**
  45395. * Specifies that the submesh is ready to be used.
  45396. * @param defines the list of "defines" to update.
  45397. * @param scene defines the scene the material belongs to.
  45398. * @param engine defines the engine the material belongs to.
  45399. * @param disableBumpMap defines wether the material disables bump or not.
  45400. * @returns - boolean indicating that the submesh is ready or not.
  45401. */
  45402. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45403. /**
  45404. * Checks to see if a texture is used in the material.
  45405. * @param defines the list of "defines" to update.
  45406. * @param scene defines the scene to the material belongs to.
  45407. */
  45408. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45409. /**
  45410. * Binds the material data.
  45411. * @param uniformBuffer defines the Uniform buffer to fill in.
  45412. * @param scene defines the scene the material belongs to.
  45413. * @param engine defines the engine the material belongs to.
  45414. * @param disableBumpMap defines wether the material disables bump or not.
  45415. * @param isFrozen defines wether the material is frozen or not.
  45416. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45417. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45418. */
  45419. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45420. /**
  45421. * Checks to see if a texture is used in the material.
  45422. * @param texture - Base texture to use.
  45423. * @returns - Boolean specifying if a texture is used in the material.
  45424. */
  45425. hasTexture(texture: BaseTexture): boolean;
  45426. /**
  45427. * Returns an array of the actively used textures.
  45428. * @param activeTextures Array of BaseTextures
  45429. */
  45430. getActiveTextures(activeTextures: BaseTexture[]): void;
  45431. /**
  45432. * Returns the animatable textures.
  45433. * @param animatables Array of animatable textures.
  45434. */
  45435. getAnimatables(animatables: IAnimatable[]): void;
  45436. /**
  45437. * Disposes the resources of the material.
  45438. * @param forceDisposeTextures - Forces the disposal of all textures.
  45439. */
  45440. dispose(forceDisposeTextures?: boolean): void;
  45441. /**
  45442. * Get the current class name of the texture useful for serialization or dynamic coding.
  45443. * @returns "PBRClearCoatConfiguration"
  45444. */
  45445. getClassName(): string;
  45446. /**
  45447. * Add fallbacks to the effect fallbacks list.
  45448. * @param defines defines the Base texture to use.
  45449. * @param fallbacks defines the current fallback list.
  45450. * @param currentRank defines the current fallback rank.
  45451. * @returns the new fallback rank.
  45452. */
  45453. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45454. /**
  45455. * Add the required uniforms to the current list.
  45456. * @param uniforms defines the current uniform list.
  45457. */
  45458. static AddUniforms(uniforms: string[]): void;
  45459. /**
  45460. * Add the required samplers to the current list.
  45461. * @param samplers defines the current sampler list.
  45462. */
  45463. static AddSamplers(samplers: string[]): void;
  45464. /**
  45465. * Add the required uniforms to the current buffer.
  45466. * @param uniformBuffer defines the current uniform buffer.
  45467. */
  45468. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45469. /**
  45470. * Makes a duplicate of the current configuration into another one.
  45471. * @param clearCoatConfiguration define the config where to copy the info
  45472. */
  45473. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45474. /**
  45475. * Serializes this clear coat configuration.
  45476. * @returns - An object with the serialized config.
  45477. */
  45478. serialize(): any;
  45479. /**
  45480. * Parses a Clear Coat Configuration from a serialized object.
  45481. * @param source - Serialized object.
  45482. */
  45483. parse(source: any): void;
  45484. }
  45485. }
  45486. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45487. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45488. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45490. import { Vector2 } from "babylonjs/Maths/math";
  45491. import { Scene } from "babylonjs/scene";
  45492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45493. import { IAnimatable } from "babylonjs/Misc/tools";
  45494. import { Nullable } from "babylonjs/types";
  45495. /**
  45496. * @hidden
  45497. */
  45498. export interface IMaterialAnisotropicDefines {
  45499. ANISOTROPIC: boolean;
  45500. ANISOTROPIC_TEXTURE: boolean;
  45501. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45502. MAINUV1: boolean;
  45503. _areTexturesDirty: boolean;
  45504. _needUVs: boolean;
  45505. }
  45506. /**
  45507. * Define the code related to the anisotropic parameters of the pbr material.
  45508. */
  45509. export class PBRAnisotropicConfiguration {
  45510. private _isEnabled;
  45511. /**
  45512. * Defines if the anisotropy is enabled in the material.
  45513. */
  45514. isEnabled: boolean;
  45515. /**
  45516. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45517. */
  45518. intensity: number;
  45519. /**
  45520. * Defines if the effect is along the tangents, bitangents or in between.
  45521. * By default, the effect is "strectching" the highlights along the tangents.
  45522. */
  45523. direction: Vector2;
  45524. private _texture;
  45525. /**
  45526. * Stores the anisotropy values in a texture.
  45527. * rg is direction (like normal from -1 to 1)
  45528. * b is a intensity
  45529. */
  45530. texture: Nullable<BaseTexture>;
  45531. /** @hidden */
  45532. private _internalMarkAllSubMeshesAsTexturesDirty;
  45533. /** @hidden */
  45534. _markAllSubMeshesAsTexturesDirty(): void;
  45535. /**
  45536. * Instantiate a new istance of anisotropy configuration.
  45537. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45538. */
  45539. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45540. /**
  45541. * Specifies that the submesh is ready to be used.
  45542. * @param defines the list of "defines" to update.
  45543. * @param scene defines the scene the material belongs to.
  45544. * @returns - boolean indicating that the submesh is ready or not.
  45545. */
  45546. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45547. /**
  45548. * Checks to see if a texture is used in the material.
  45549. * @param defines the list of "defines" to update.
  45550. * @param mesh the mesh we are preparing the defines for.
  45551. * @param scene defines the scene the material belongs to.
  45552. */
  45553. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45554. /**
  45555. * Binds the material data.
  45556. * @param uniformBuffer defines the Uniform buffer to fill in.
  45557. * @param scene defines the scene the material belongs to.
  45558. * @param isFrozen defines wether the material is frozen or not.
  45559. */
  45560. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45561. /**
  45562. * Checks to see if a texture is used in the material.
  45563. * @param texture - Base texture to use.
  45564. * @returns - Boolean specifying if a texture is used in the material.
  45565. */
  45566. hasTexture(texture: BaseTexture): boolean;
  45567. /**
  45568. * Returns an array of the actively used textures.
  45569. * @param activeTextures Array of BaseTextures
  45570. */
  45571. getActiveTextures(activeTextures: BaseTexture[]): void;
  45572. /**
  45573. * Returns the animatable textures.
  45574. * @param animatables Array of animatable textures.
  45575. */
  45576. getAnimatables(animatables: IAnimatable[]): void;
  45577. /**
  45578. * Disposes the resources of the material.
  45579. * @param forceDisposeTextures - Forces the disposal of all textures.
  45580. */
  45581. dispose(forceDisposeTextures?: boolean): void;
  45582. /**
  45583. * Get the current class name of the texture useful for serialization or dynamic coding.
  45584. * @returns "PBRAnisotropicConfiguration"
  45585. */
  45586. getClassName(): string;
  45587. /**
  45588. * Add fallbacks to the effect fallbacks list.
  45589. * @param defines defines the Base texture to use.
  45590. * @param fallbacks defines the current fallback list.
  45591. * @param currentRank defines the current fallback rank.
  45592. * @returns the new fallback rank.
  45593. */
  45594. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45595. /**
  45596. * Add the required uniforms to the current list.
  45597. * @param uniforms defines the current uniform list.
  45598. */
  45599. static AddUniforms(uniforms: string[]): void;
  45600. /**
  45601. * Add the required uniforms to the current buffer.
  45602. * @param uniformBuffer defines the current uniform buffer.
  45603. */
  45604. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45605. /**
  45606. * Add the required samplers to the current list.
  45607. * @param samplers defines the current sampler list.
  45608. */
  45609. static AddSamplers(samplers: string[]): void;
  45610. /**
  45611. * Makes a duplicate of the current configuration into another one.
  45612. * @param anisotropicConfiguration define the config where to copy the info
  45613. */
  45614. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45615. /**
  45616. * Serializes this anisotropy configuration.
  45617. * @returns - An object with the serialized config.
  45618. */
  45619. serialize(): any;
  45620. /**
  45621. * Parses a anisotropy Configuration from a serialized object.
  45622. * @param source - Serialized object.
  45623. */
  45624. parse(source: any): void;
  45625. }
  45626. }
  45627. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45628. /**
  45629. * @hidden
  45630. */
  45631. export interface IMaterialBRDFDefines {
  45632. BRDF_V_HEIGHT_CORRELATED: boolean;
  45633. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45634. /** @hidden */
  45635. _areMiscDirty: boolean;
  45636. }
  45637. /**
  45638. * Define the code related to the BRDF parameters of the pbr material.
  45639. */
  45640. export class PBRBRDFConfiguration {
  45641. /**
  45642. * Default value used for the energy conservation.
  45643. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45644. */
  45645. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45646. /**
  45647. * Default value used for the Smith Visibility Height Correlated mode.
  45648. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45649. */
  45650. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45651. private _useEnergyConservation;
  45652. /**
  45653. * Defines if the material uses energy conservation.
  45654. */
  45655. useEnergyConservation: boolean;
  45656. private _useSmithVisibilityHeightCorrelated;
  45657. /**
  45658. * LEGACY Mode set to false
  45659. * Defines if the material uses height smith correlated visibility term.
  45660. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45661. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45662. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45663. * Not relying on height correlated will also disable energy conservation.
  45664. */
  45665. useSmithVisibilityHeightCorrelated: boolean;
  45666. /** @hidden */
  45667. private _internalMarkAllSubMeshesAsMiscDirty;
  45668. /** @hidden */
  45669. _markAllSubMeshesAsMiscDirty(): void;
  45670. /**
  45671. * Instantiate a new istance of clear coat configuration.
  45672. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45673. */
  45674. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45675. /**
  45676. * Checks to see if a texture is used in the material.
  45677. * @param defines the list of "defines" to update.
  45678. */
  45679. prepareDefines(defines: IMaterialBRDFDefines): void;
  45680. /**
  45681. * Get the current class name of the texture useful for serialization or dynamic coding.
  45682. * @returns "PBRClearCoatConfiguration"
  45683. */
  45684. getClassName(): string;
  45685. /**
  45686. * Makes a duplicate of the current configuration into another one.
  45687. * @param brdfConfiguration define the config where to copy the info
  45688. */
  45689. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45690. /**
  45691. * Serializes this BRDF configuration.
  45692. * @returns - An object with the serialized config.
  45693. */
  45694. serialize(): any;
  45695. /**
  45696. * Parses a BRDF Configuration from a serialized object.
  45697. * @param source - Serialized object.
  45698. */
  45699. parse(source: any): void;
  45700. }
  45701. }
  45702. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45703. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45704. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45705. import { Color3 } from "babylonjs/Maths/math";
  45706. import { Scene } from "babylonjs/scene";
  45707. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45708. import { IAnimatable } from "babylonjs/Misc/tools";
  45709. import { Nullable } from "babylonjs/types";
  45710. /**
  45711. * @hidden
  45712. */
  45713. export interface IMaterialSheenDefines {
  45714. SHEEN: boolean;
  45715. SHEEN_TEXTURE: boolean;
  45716. SHEEN_TEXTUREDIRECTUV: number;
  45717. SHEEN_LINKWITHALBEDO: boolean;
  45718. /** @hidden */
  45719. _areTexturesDirty: boolean;
  45720. }
  45721. /**
  45722. * Define the code related to the Sheen parameters of the pbr material.
  45723. */
  45724. export class PBRSheenConfiguration {
  45725. private _isEnabled;
  45726. /**
  45727. * Defines if the material uses sheen.
  45728. */
  45729. isEnabled: boolean;
  45730. private _linkSheenWithAlbedo;
  45731. /**
  45732. * Defines if the sheen is linked to the sheen color.
  45733. */
  45734. linkSheenWithAlbedo: boolean;
  45735. /**
  45736. * Defines the sheen intensity.
  45737. */
  45738. intensity: number;
  45739. /**
  45740. * Defines the sheen color.
  45741. */
  45742. color: Color3;
  45743. private _texture;
  45744. /**
  45745. * Stores the sheen tint values in a texture.
  45746. * rgb is tint
  45747. * a is a intensity
  45748. */
  45749. texture: Nullable<BaseTexture>;
  45750. /** @hidden */
  45751. private _internalMarkAllSubMeshesAsTexturesDirty;
  45752. /** @hidden */
  45753. _markAllSubMeshesAsTexturesDirty(): void;
  45754. /**
  45755. * Instantiate a new istance of clear coat configuration.
  45756. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45757. */
  45758. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45759. /**
  45760. * Specifies that the submesh is ready to be used.
  45761. * @param defines the list of "defines" to update.
  45762. * @param scene defines the scene the material belongs to.
  45763. * @returns - boolean indicating that the submesh is ready or not.
  45764. */
  45765. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45766. /**
  45767. * Checks to see if a texture is used in the material.
  45768. * @param defines the list of "defines" to update.
  45769. * @param scene defines the scene the material belongs to.
  45770. */
  45771. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45772. /**
  45773. * Binds the material data.
  45774. * @param uniformBuffer defines the Uniform buffer to fill in.
  45775. * @param scene defines the scene the material belongs to.
  45776. * @param isFrozen defines wether the material is frozen or not.
  45777. */
  45778. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45779. /**
  45780. * Checks to see if a texture is used in the material.
  45781. * @param texture - Base texture to use.
  45782. * @returns - Boolean specifying if a texture is used in the material.
  45783. */
  45784. hasTexture(texture: BaseTexture): boolean;
  45785. /**
  45786. * Returns an array of the actively used textures.
  45787. * @param activeTextures Array of BaseTextures
  45788. */
  45789. getActiveTextures(activeTextures: BaseTexture[]): void;
  45790. /**
  45791. * Returns the animatable textures.
  45792. * @param animatables Array of animatable textures.
  45793. */
  45794. getAnimatables(animatables: IAnimatable[]): void;
  45795. /**
  45796. * Disposes the resources of the material.
  45797. * @param forceDisposeTextures - Forces the disposal of all textures.
  45798. */
  45799. dispose(forceDisposeTextures?: boolean): void;
  45800. /**
  45801. * Get the current class name of the texture useful for serialization or dynamic coding.
  45802. * @returns "PBRSheenConfiguration"
  45803. */
  45804. getClassName(): string;
  45805. /**
  45806. * Add fallbacks to the effect fallbacks list.
  45807. * @param defines defines the Base texture to use.
  45808. * @param fallbacks defines the current fallback list.
  45809. * @param currentRank defines the current fallback rank.
  45810. * @returns the new fallback rank.
  45811. */
  45812. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45813. /**
  45814. * Add the required uniforms to the current list.
  45815. * @param uniforms defines the current uniform list.
  45816. */
  45817. static AddUniforms(uniforms: string[]): void;
  45818. /**
  45819. * Add the required uniforms to the current buffer.
  45820. * @param uniformBuffer defines the current uniform buffer.
  45821. */
  45822. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45823. /**
  45824. * Add the required samplers to the current list.
  45825. * @param samplers defines the current sampler list.
  45826. */
  45827. static AddSamplers(samplers: string[]): void;
  45828. /**
  45829. * Makes a duplicate of the current configuration into another one.
  45830. * @param sheenConfiguration define the config where to copy the info
  45831. */
  45832. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45833. /**
  45834. * Serializes this BRDF configuration.
  45835. * @returns - An object with the serialized config.
  45836. */
  45837. serialize(): any;
  45838. /**
  45839. * Parses a Sheen Configuration from a serialized object.
  45840. * @param source - Serialized object.
  45841. */
  45842. parse(source: any): void;
  45843. }
  45844. }
  45845. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  45846. /** @hidden */
  45847. export var pbrFragmentDeclaration: {
  45848. name: string;
  45849. shader: string;
  45850. };
  45851. }
  45852. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  45853. /** @hidden */
  45854. export var pbrUboDeclaration: {
  45855. name: string;
  45856. shader: string;
  45857. };
  45858. }
  45859. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  45860. /** @hidden */
  45861. export var pbrFragmentExtraDeclaration: {
  45862. name: string;
  45863. shader: string;
  45864. };
  45865. }
  45866. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  45867. /** @hidden */
  45868. export var pbrFragmentSamplersDeclaration: {
  45869. name: string;
  45870. shader: string;
  45871. };
  45872. }
  45873. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  45874. /** @hidden */
  45875. export var pbrHelperFunctions: {
  45876. name: string;
  45877. shader: string;
  45878. };
  45879. }
  45880. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  45881. /** @hidden */
  45882. export var harmonicsFunctions: {
  45883. name: string;
  45884. shader: string;
  45885. };
  45886. }
  45887. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  45888. /** @hidden */
  45889. export var pbrDirectLightingSetupFunctions: {
  45890. name: string;
  45891. shader: string;
  45892. };
  45893. }
  45894. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  45895. /** @hidden */
  45896. export var pbrDirectLightingFalloffFunctions: {
  45897. name: string;
  45898. shader: string;
  45899. };
  45900. }
  45901. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  45902. /** @hidden */
  45903. export var pbrBRDFFunctions: {
  45904. name: string;
  45905. shader: string;
  45906. };
  45907. }
  45908. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  45909. /** @hidden */
  45910. export var pbrDirectLightingFunctions: {
  45911. name: string;
  45912. shader: string;
  45913. };
  45914. }
  45915. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  45916. /** @hidden */
  45917. export var pbrIBLFunctions: {
  45918. name: string;
  45919. shader: string;
  45920. };
  45921. }
  45922. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  45923. /** @hidden */
  45924. export var pbrDebug: {
  45925. name: string;
  45926. shader: string;
  45927. };
  45928. }
  45929. declare module "babylonjs/Shaders/pbr.fragment" {
  45930. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  45931. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45932. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  45933. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45934. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45935. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  45936. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45937. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45938. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45939. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45940. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45941. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  45942. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45943. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45944. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45945. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  45946. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  45947. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  45948. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  45949. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  45950. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  45951. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45952. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45953. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45954. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45955. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45956. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45957. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45958. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45959. /** @hidden */
  45960. export var pbrPixelShader: {
  45961. name: string;
  45962. shader: string;
  45963. };
  45964. }
  45965. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45966. /** @hidden */
  45967. export var pbrVertexDeclaration: {
  45968. name: string;
  45969. shader: string;
  45970. };
  45971. }
  45972. declare module "babylonjs/Shaders/pbr.vertex" {
  45973. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45974. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45975. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45976. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45977. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45978. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45979. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45980. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45981. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45982. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45983. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45984. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45985. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45986. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45987. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45988. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45989. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45990. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45991. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45992. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45993. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45994. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45995. /** @hidden */
  45996. export var pbrVertexShader: {
  45997. name: string;
  45998. shader: string;
  45999. };
  46000. }
  46001. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46002. import { IAnimatable } from "babylonjs/Misc/tools";
  46003. import { Nullable } from "babylonjs/types";
  46004. import { Scene } from "babylonjs/scene";
  46005. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46006. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46008. import { Mesh } from "babylonjs/Meshes/mesh";
  46009. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46010. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46011. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46012. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46013. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46014. import { Material } from "babylonjs/Materials/material";
  46015. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46016. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46017. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46018. import "babylonjs/Shaders/pbr.fragment";
  46019. import "babylonjs/Shaders/pbr.vertex";
  46020. /**
  46021. * Manages the defines for the PBR Material.
  46022. * @hidden
  46023. */
  46024. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines {
  46025. PBR: boolean;
  46026. MAINUV1: boolean;
  46027. MAINUV2: boolean;
  46028. UV1: boolean;
  46029. UV2: boolean;
  46030. ALBEDO: boolean;
  46031. ALBEDODIRECTUV: number;
  46032. VERTEXCOLOR: boolean;
  46033. AMBIENT: boolean;
  46034. AMBIENTDIRECTUV: number;
  46035. AMBIENTINGRAYSCALE: boolean;
  46036. OPACITY: boolean;
  46037. VERTEXALPHA: boolean;
  46038. OPACITYDIRECTUV: number;
  46039. OPACITYRGB: boolean;
  46040. ALPHATEST: boolean;
  46041. DEPTHPREPASS: boolean;
  46042. ALPHABLEND: boolean;
  46043. ALPHAFROMALBEDO: boolean;
  46044. ALPHATESTVALUE: string;
  46045. SPECULAROVERALPHA: boolean;
  46046. RADIANCEOVERALPHA: boolean;
  46047. ALPHAFRESNEL: boolean;
  46048. LINEARALPHAFRESNEL: boolean;
  46049. PREMULTIPLYALPHA: boolean;
  46050. EMISSIVE: boolean;
  46051. EMISSIVEDIRECTUV: number;
  46052. REFLECTIVITY: boolean;
  46053. REFLECTIVITYDIRECTUV: number;
  46054. SPECULARTERM: boolean;
  46055. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46056. MICROSURFACEAUTOMATIC: boolean;
  46057. LODBASEDMICROSFURACE: boolean;
  46058. MICROSURFACEMAP: boolean;
  46059. MICROSURFACEMAPDIRECTUV: number;
  46060. METALLICWORKFLOW: boolean;
  46061. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46062. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46063. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46064. AOSTOREINMETALMAPRED: boolean;
  46065. ENVIRONMENTBRDF: boolean;
  46066. ENVIRONMENTBRDF_RGBD: boolean;
  46067. NORMAL: boolean;
  46068. TANGENT: boolean;
  46069. BUMP: boolean;
  46070. BUMPDIRECTUV: number;
  46071. OBJECTSPACE_NORMALMAP: boolean;
  46072. PARALLAX: boolean;
  46073. PARALLAXOCCLUSION: boolean;
  46074. NORMALXYSCALE: boolean;
  46075. LIGHTMAP: boolean;
  46076. LIGHTMAPDIRECTUV: number;
  46077. USELIGHTMAPASSHADOWMAP: boolean;
  46078. GAMMALIGHTMAP: boolean;
  46079. REFLECTION: boolean;
  46080. REFLECTIONMAP_3D: boolean;
  46081. REFLECTIONMAP_SPHERICAL: boolean;
  46082. REFLECTIONMAP_PLANAR: boolean;
  46083. REFLECTIONMAP_CUBIC: boolean;
  46084. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46085. REFLECTIONMAP_PROJECTION: boolean;
  46086. REFLECTIONMAP_SKYBOX: boolean;
  46087. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46088. REFLECTIONMAP_EXPLICIT: boolean;
  46089. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46090. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46091. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46092. INVERTCUBICMAP: boolean;
  46093. USESPHERICALFROMREFLECTIONMAP: boolean;
  46094. USESPHERICALINVERTEX: boolean;
  46095. REFLECTIONMAP_OPPOSITEZ: boolean;
  46096. LODINREFLECTIONALPHA: boolean;
  46097. GAMMAREFLECTION: boolean;
  46098. RGBDREFLECTION: boolean;
  46099. RADIANCEOCCLUSION: boolean;
  46100. HORIZONOCCLUSION: boolean;
  46101. REFRACTION: boolean;
  46102. REFRACTIONMAP_3D: boolean;
  46103. REFRACTIONMAP_OPPOSITEZ: boolean;
  46104. LODINREFRACTIONALPHA: boolean;
  46105. GAMMAREFRACTION: boolean;
  46106. RGBDREFRACTION: boolean;
  46107. LINKREFRACTIONTOTRANSPARENCY: boolean;
  46108. INSTANCES: boolean;
  46109. NUM_BONE_INFLUENCERS: number;
  46110. BonesPerMesh: number;
  46111. BONETEXTURE: boolean;
  46112. NONUNIFORMSCALING: boolean;
  46113. MORPHTARGETS: boolean;
  46114. MORPHTARGETS_NORMAL: boolean;
  46115. MORPHTARGETS_TANGENT: boolean;
  46116. NUM_MORPH_INFLUENCERS: number;
  46117. IMAGEPROCESSING: boolean;
  46118. VIGNETTE: boolean;
  46119. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46120. VIGNETTEBLENDMODEOPAQUE: boolean;
  46121. TONEMAPPING: boolean;
  46122. TONEMAPPING_ACES: boolean;
  46123. CONTRAST: boolean;
  46124. COLORCURVES: boolean;
  46125. COLORGRADING: boolean;
  46126. COLORGRADING3D: boolean;
  46127. SAMPLER3DGREENDEPTH: boolean;
  46128. SAMPLER3DBGRMAP: boolean;
  46129. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46130. EXPOSURE: boolean;
  46131. MULTIVIEW: boolean;
  46132. USEPHYSICALLIGHTFALLOFF: boolean;
  46133. USEGLTFLIGHTFALLOFF: boolean;
  46134. TWOSIDEDLIGHTING: boolean;
  46135. SHADOWFLOAT: boolean;
  46136. CLIPPLANE: boolean;
  46137. CLIPPLANE2: boolean;
  46138. CLIPPLANE3: boolean;
  46139. CLIPPLANE4: boolean;
  46140. POINTSIZE: boolean;
  46141. FOG: boolean;
  46142. LOGARITHMICDEPTH: boolean;
  46143. FORCENORMALFORWARD: boolean;
  46144. SPECULARAA: boolean;
  46145. CLEARCOAT: boolean;
  46146. CLEARCOAT_DEFAULTIOR: boolean;
  46147. CLEARCOAT_TEXTURE: boolean;
  46148. CLEARCOAT_TEXTUREDIRECTUV: number;
  46149. CLEARCOAT_BUMP: boolean;
  46150. CLEARCOAT_BUMPDIRECTUV: number;
  46151. CLEARCOAT_TINT: boolean;
  46152. CLEARCOAT_TINT_TEXTURE: boolean;
  46153. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46154. ANISOTROPIC: boolean;
  46155. ANISOTROPIC_TEXTURE: boolean;
  46156. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46157. BRDF_V_HEIGHT_CORRELATED: boolean;
  46158. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46159. SHEEN: boolean;
  46160. SHEEN_TEXTURE: boolean;
  46161. SHEEN_TEXTUREDIRECTUV: number;
  46162. SHEEN_LINKWITHALBEDO: boolean;
  46163. UNLIT: boolean;
  46164. DEBUGMODE: number;
  46165. /**
  46166. * Initializes the PBR Material defines.
  46167. */
  46168. constructor();
  46169. /**
  46170. * Resets the PBR Material defines.
  46171. */
  46172. reset(): void;
  46173. }
  46174. /**
  46175. * The Physically based material base class of BJS.
  46176. *
  46177. * This offers the main features of a standard PBR material.
  46178. * For more information, please refer to the documentation :
  46179. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46180. */
  46181. export abstract class PBRBaseMaterial extends PushMaterial {
  46182. /**
  46183. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46184. */
  46185. static readonly PBRMATERIAL_OPAQUE: number;
  46186. /**
  46187. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46188. */
  46189. static readonly PBRMATERIAL_ALPHATEST: number;
  46190. /**
  46191. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46192. */
  46193. static readonly PBRMATERIAL_ALPHABLEND: number;
  46194. /**
  46195. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46196. * They are also discarded below the alpha cutoff threshold to improve performances.
  46197. */
  46198. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46199. /**
  46200. * Defines the default value of how much AO map is occluding the analytical lights
  46201. * (point spot...).
  46202. */
  46203. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46204. /**
  46205. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46206. */
  46207. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46208. /**
  46209. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46210. * to enhance interoperability with other engines.
  46211. */
  46212. static readonly LIGHTFALLOFF_GLTF: number;
  46213. /**
  46214. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46215. * to enhance interoperability with other materials.
  46216. */
  46217. static readonly LIGHTFALLOFF_STANDARD: number;
  46218. /**
  46219. * Intensity of the direct lights e.g. the four lights available in your scene.
  46220. * This impacts both the direct diffuse and specular highlights.
  46221. */
  46222. protected _directIntensity: number;
  46223. /**
  46224. * Intensity of the emissive part of the material.
  46225. * This helps controlling the emissive effect without modifying the emissive color.
  46226. */
  46227. protected _emissiveIntensity: number;
  46228. /**
  46229. * Intensity of the environment e.g. how much the environment will light the object
  46230. * either through harmonics for rough material or through the refelction for shiny ones.
  46231. */
  46232. protected _environmentIntensity: number;
  46233. /**
  46234. * This is a special control allowing the reduction of the specular highlights coming from the
  46235. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46236. */
  46237. protected _specularIntensity: number;
  46238. /**
  46239. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46240. */
  46241. private _lightingInfos;
  46242. /**
  46243. * Debug Control allowing disabling the bump map on this material.
  46244. */
  46245. protected _disableBumpMap: boolean;
  46246. /**
  46247. * AKA Diffuse Texture in standard nomenclature.
  46248. */
  46249. protected _albedoTexture: BaseTexture;
  46250. /**
  46251. * AKA Occlusion Texture in other nomenclature.
  46252. */
  46253. protected _ambientTexture: BaseTexture;
  46254. /**
  46255. * AKA Occlusion Texture Intensity in other nomenclature.
  46256. */
  46257. protected _ambientTextureStrength: number;
  46258. /**
  46259. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46260. * 1 means it completely occludes it
  46261. * 0 mean it has no impact
  46262. */
  46263. protected _ambientTextureImpactOnAnalyticalLights: number;
  46264. /**
  46265. * Stores the alpha values in a texture.
  46266. */
  46267. protected _opacityTexture: BaseTexture;
  46268. /**
  46269. * Stores the reflection values in a texture.
  46270. */
  46271. protected _reflectionTexture: BaseTexture;
  46272. /**
  46273. * Stores the refraction values in a texture.
  46274. */
  46275. protected _refractionTexture: BaseTexture;
  46276. /**
  46277. * Stores the emissive values in a texture.
  46278. */
  46279. protected _emissiveTexture: BaseTexture;
  46280. /**
  46281. * AKA Specular texture in other nomenclature.
  46282. */
  46283. protected _reflectivityTexture: BaseTexture;
  46284. /**
  46285. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46286. */
  46287. protected _metallicTexture: BaseTexture;
  46288. /**
  46289. * Specifies the metallic scalar of the metallic/roughness workflow.
  46290. * Can also be used to scale the metalness values of the metallic texture.
  46291. */
  46292. protected _metallic: Nullable<number>;
  46293. /**
  46294. * Specifies the roughness scalar of the metallic/roughness workflow.
  46295. * Can also be used to scale the roughness values of the metallic texture.
  46296. */
  46297. protected _roughness: Nullable<number>;
  46298. /**
  46299. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46300. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46301. */
  46302. protected _microSurfaceTexture: BaseTexture;
  46303. /**
  46304. * Stores surface normal data used to displace a mesh in a texture.
  46305. */
  46306. protected _bumpTexture: BaseTexture;
  46307. /**
  46308. * Stores the pre-calculated light information of a mesh in a texture.
  46309. */
  46310. protected _lightmapTexture: BaseTexture;
  46311. /**
  46312. * The color of a material in ambient lighting.
  46313. */
  46314. protected _ambientColor: Color3;
  46315. /**
  46316. * AKA Diffuse Color in other nomenclature.
  46317. */
  46318. protected _albedoColor: Color3;
  46319. /**
  46320. * AKA Specular Color in other nomenclature.
  46321. */
  46322. protected _reflectivityColor: Color3;
  46323. /**
  46324. * The color applied when light is reflected from a material.
  46325. */
  46326. protected _reflectionColor: Color3;
  46327. /**
  46328. * The color applied when light is emitted from a material.
  46329. */
  46330. protected _emissiveColor: Color3;
  46331. /**
  46332. * AKA Glossiness in other nomenclature.
  46333. */
  46334. protected _microSurface: number;
  46335. /**
  46336. * source material index of refraction (IOR)' / 'destination material IOR.
  46337. */
  46338. protected _indexOfRefraction: number;
  46339. /**
  46340. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46341. */
  46342. protected _invertRefractionY: boolean;
  46343. /**
  46344. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46345. * Materials half opaque for instance using refraction could benefit from this control.
  46346. */
  46347. protected _linkRefractionWithTransparency: boolean;
  46348. /**
  46349. * Specifies that the material will use the light map as a show map.
  46350. */
  46351. protected _useLightmapAsShadowmap: boolean;
  46352. /**
  46353. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46354. * makes the reflect vector face the model (under horizon).
  46355. */
  46356. protected _useHorizonOcclusion: boolean;
  46357. /**
  46358. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46359. * too much the area relying on ambient texture to define their ambient occlusion.
  46360. */
  46361. protected _useRadianceOcclusion: boolean;
  46362. /**
  46363. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46364. */
  46365. protected _useAlphaFromAlbedoTexture: boolean;
  46366. /**
  46367. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46368. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46369. */
  46370. protected _useSpecularOverAlpha: boolean;
  46371. /**
  46372. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46373. */
  46374. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46375. /**
  46376. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46377. */
  46378. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46379. /**
  46380. * Specifies if the metallic texture contains the roughness information in its green channel.
  46381. */
  46382. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46383. /**
  46384. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46385. */
  46386. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46387. /**
  46388. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46389. */
  46390. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46391. /**
  46392. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46393. */
  46394. protected _useAmbientInGrayScale: boolean;
  46395. /**
  46396. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46397. * The material will try to infer what glossiness each pixel should be.
  46398. */
  46399. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46400. /**
  46401. * Defines the falloff type used in this material.
  46402. * It by default is Physical.
  46403. */
  46404. protected _lightFalloff: number;
  46405. /**
  46406. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46407. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46408. */
  46409. protected _useRadianceOverAlpha: boolean;
  46410. /**
  46411. * Allows using an object space normal map (instead of tangent space).
  46412. */
  46413. protected _useObjectSpaceNormalMap: boolean;
  46414. /**
  46415. * Allows using the bump map in parallax mode.
  46416. */
  46417. protected _useParallax: boolean;
  46418. /**
  46419. * Allows using the bump map in parallax occlusion mode.
  46420. */
  46421. protected _useParallaxOcclusion: boolean;
  46422. /**
  46423. * Controls the scale bias of the parallax mode.
  46424. */
  46425. protected _parallaxScaleBias: number;
  46426. /**
  46427. * If sets to true, disables all the lights affecting the material.
  46428. */
  46429. protected _disableLighting: boolean;
  46430. /**
  46431. * Number of Simultaneous lights allowed on the material.
  46432. */
  46433. protected _maxSimultaneousLights: number;
  46434. /**
  46435. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46436. */
  46437. protected _invertNormalMapX: boolean;
  46438. /**
  46439. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46440. */
  46441. protected _invertNormalMapY: boolean;
  46442. /**
  46443. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46444. */
  46445. protected _twoSidedLighting: boolean;
  46446. /**
  46447. * Defines the alpha limits in alpha test mode.
  46448. */
  46449. protected _alphaCutOff: number;
  46450. /**
  46451. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46452. */
  46453. protected _forceAlphaTest: boolean;
  46454. /**
  46455. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46456. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46457. */
  46458. protected _useAlphaFresnel: boolean;
  46459. /**
  46460. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46461. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46462. */
  46463. protected _useLinearAlphaFresnel: boolean;
  46464. /**
  46465. * The transparency mode of the material.
  46466. */
  46467. protected _transparencyMode: Nullable<number>;
  46468. /**
  46469. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46470. * from cos thetav and roughness:
  46471. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46472. */
  46473. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46474. /**
  46475. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46476. */
  46477. protected _forceIrradianceInFragment: boolean;
  46478. /**
  46479. * Force normal to face away from face.
  46480. */
  46481. protected _forceNormalForward: boolean;
  46482. /**
  46483. * Enables specular anti aliasing in the PBR shader.
  46484. * It will both interacts on the Geometry for analytical and IBL lighting.
  46485. * It also prefilter the roughness map based on the bump values.
  46486. */
  46487. protected _enableSpecularAntiAliasing: boolean;
  46488. /**
  46489. * Default configuration related to image processing available in the PBR Material.
  46490. */
  46491. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46492. /**
  46493. * Keep track of the image processing observer to allow dispose and replace.
  46494. */
  46495. private _imageProcessingObserver;
  46496. /**
  46497. * Attaches a new image processing configuration to the PBR Material.
  46498. * @param configuration
  46499. */
  46500. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46501. /**
  46502. * Stores the available render targets.
  46503. */
  46504. private _renderTargets;
  46505. /**
  46506. * Sets the global ambient color for the material used in lighting calculations.
  46507. */
  46508. private _globalAmbientColor;
  46509. /**
  46510. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46511. */
  46512. private _useLogarithmicDepth;
  46513. /**
  46514. * If set to true, no lighting calculations will be applied.
  46515. */
  46516. private _unlit;
  46517. private _debugMode;
  46518. /**
  46519. * @hidden
  46520. * This is reserved for the inspector.
  46521. * Defines the material debug mode.
  46522. * It helps seeing only some components of the material while troubleshooting.
  46523. */
  46524. debugMode: number;
  46525. /**
  46526. * @hidden
  46527. * This is reserved for the inspector.
  46528. * Specify from where on screen the debug mode should start.
  46529. * The value goes from -1 (full screen) to 1 (not visible)
  46530. * It helps with side by side comparison against the final render
  46531. * This defaults to -1
  46532. */
  46533. private debugLimit;
  46534. /**
  46535. * @hidden
  46536. * This is reserved for the inspector.
  46537. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46538. * You can use the factor to better multiply the final value.
  46539. */
  46540. private debugFactor;
  46541. /**
  46542. * Defines the clear coat layer parameters for the material.
  46543. */
  46544. readonly clearCoat: PBRClearCoatConfiguration;
  46545. /**
  46546. * Defines the anisotropic parameters for the material.
  46547. */
  46548. readonly anisotropy: PBRAnisotropicConfiguration;
  46549. /**
  46550. * Defines the BRDF parameters for the material.
  46551. */
  46552. readonly brdf: PBRBRDFConfiguration;
  46553. /**
  46554. * Defines the Sheen parameters for the material.
  46555. */
  46556. readonly sheen: PBRSheenConfiguration;
  46557. /**
  46558. * Custom callback helping to override the default shader used in the material.
  46559. */
  46560. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46561. /**
  46562. * Instantiates a new PBRMaterial instance.
  46563. *
  46564. * @param name The material name
  46565. * @param scene The scene the material will be use in.
  46566. */
  46567. constructor(name: string, scene: Scene);
  46568. /**
  46569. * Gets a boolean indicating that current material needs to register RTT
  46570. */
  46571. readonly hasRenderTargetTextures: boolean;
  46572. /**
  46573. * Gets the name of the material class.
  46574. */
  46575. getClassName(): string;
  46576. /**
  46577. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46578. */
  46579. /**
  46580. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46581. */
  46582. useLogarithmicDepth: boolean;
  46583. /**
  46584. * Gets the current transparency mode.
  46585. */
  46586. /**
  46587. * Sets the transparency mode of the material.
  46588. *
  46589. * | Value | Type | Description |
  46590. * | ----- | ----------------------------------- | ----------- |
  46591. * | 0 | OPAQUE | |
  46592. * | 1 | ALPHATEST | |
  46593. * | 2 | ALPHABLEND | |
  46594. * | 3 | ALPHATESTANDBLEND | |
  46595. *
  46596. */
  46597. transparencyMode: Nullable<number>;
  46598. /**
  46599. * Returns true if alpha blending should be disabled.
  46600. */
  46601. private readonly _disableAlphaBlending;
  46602. /**
  46603. * Specifies whether or not this material should be rendered in alpha blend mode.
  46604. */
  46605. needAlphaBlending(): boolean;
  46606. /**
  46607. * Specifies if the mesh will require alpha blending.
  46608. * @param mesh - BJS mesh.
  46609. */
  46610. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46611. /**
  46612. * Specifies whether or not this material should be rendered in alpha test mode.
  46613. */
  46614. needAlphaTesting(): boolean;
  46615. /**
  46616. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46617. */
  46618. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46619. /**
  46620. * Gets the texture used for the alpha test.
  46621. */
  46622. getAlphaTestTexture(): BaseTexture;
  46623. /**
  46624. * Specifies that the submesh is ready to be used.
  46625. * @param mesh - BJS mesh.
  46626. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46627. * @param useInstances - Specifies that instances should be used.
  46628. * @returns - boolean indicating that the submesh is ready or not.
  46629. */
  46630. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46631. /**
  46632. * Specifies if the material uses metallic roughness workflow.
  46633. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46634. */
  46635. isMetallicWorkflow(): boolean;
  46636. private _prepareEffect;
  46637. private _prepareDefines;
  46638. /**
  46639. * Force shader compilation
  46640. */
  46641. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46642. clipPlane: boolean;
  46643. }>): void;
  46644. /**
  46645. * Initializes the uniform buffer layout for the shader.
  46646. */
  46647. buildUniformLayout(): void;
  46648. /**
  46649. * Unbinds the textures.
  46650. */
  46651. unbind(): void;
  46652. /**
  46653. * Binds the submesh data.
  46654. * @param world - The world matrix.
  46655. * @param mesh - The BJS mesh.
  46656. * @param subMesh - A submesh of the BJS mesh.
  46657. */
  46658. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46659. /**
  46660. * Returns the animatable textures.
  46661. * @returns - Array of animatable textures.
  46662. */
  46663. getAnimatables(): IAnimatable[];
  46664. /**
  46665. * Returns the texture used for reflections.
  46666. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46667. */
  46668. private _getReflectionTexture;
  46669. /**
  46670. * Returns the texture used for refraction or null if none is used.
  46671. * @returns - Refection texture if present. If no refraction texture and refraction
  46672. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46673. */
  46674. private _getRefractionTexture;
  46675. /**
  46676. * Returns an array of the actively used textures.
  46677. * @returns - Array of BaseTextures
  46678. */
  46679. getActiveTextures(): BaseTexture[];
  46680. /**
  46681. * Checks to see if a texture is used in the material.
  46682. * @param texture - Base texture to use.
  46683. * @returns - Boolean specifying if a texture is used in the material.
  46684. */
  46685. hasTexture(texture: BaseTexture): boolean;
  46686. /**
  46687. * Disposes the resources of the material.
  46688. * @param forceDisposeEffect - Forces the disposal of effects.
  46689. * @param forceDisposeTextures - Forces the disposal of all textures.
  46690. */
  46691. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46692. }
  46693. }
  46694. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  46695. import { Nullable } from "babylonjs/types";
  46696. import { Scene } from "babylonjs/scene";
  46697. import { Color3 } from "babylonjs/Maths/math";
  46698. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46699. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46700. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46701. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  46702. /**
  46703. * The Physically based material of BJS.
  46704. *
  46705. * This offers the main features of a standard PBR material.
  46706. * For more information, please refer to the documentation :
  46707. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46708. */
  46709. export class PBRMaterial extends PBRBaseMaterial {
  46710. /**
  46711. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46712. */
  46713. static readonly PBRMATERIAL_OPAQUE: number;
  46714. /**
  46715. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46716. */
  46717. static readonly PBRMATERIAL_ALPHATEST: number;
  46718. /**
  46719. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46720. */
  46721. static readonly PBRMATERIAL_ALPHABLEND: number;
  46722. /**
  46723. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46724. * They are also discarded below the alpha cutoff threshold to improve performances.
  46725. */
  46726. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46727. /**
  46728. * Defines the default value of how much AO map is occluding the analytical lights
  46729. * (point spot...).
  46730. */
  46731. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46732. /**
  46733. * Intensity of the direct lights e.g. the four lights available in your scene.
  46734. * This impacts both the direct diffuse and specular highlights.
  46735. */
  46736. directIntensity: number;
  46737. /**
  46738. * Intensity of the emissive part of the material.
  46739. * This helps controlling the emissive effect without modifying the emissive color.
  46740. */
  46741. emissiveIntensity: number;
  46742. /**
  46743. * Intensity of the environment e.g. how much the environment will light the object
  46744. * either through harmonics for rough material or through the refelction for shiny ones.
  46745. */
  46746. environmentIntensity: number;
  46747. /**
  46748. * This is a special control allowing the reduction of the specular highlights coming from the
  46749. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46750. */
  46751. specularIntensity: number;
  46752. /**
  46753. * Debug Control allowing disabling the bump map on this material.
  46754. */
  46755. disableBumpMap: boolean;
  46756. /**
  46757. * AKA Diffuse Texture in standard nomenclature.
  46758. */
  46759. albedoTexture: BaseTexture;
  46760. /**
  46761. * AKA Occlusion Texture in other nomenclature.
  46762. */
  46763. ambientTexture: BaseTexture;
  46764. /**
  46765. * AKA Occlusion Texture Intensity in other nomenclature.
  46766. */
  46767. ambientTextureStrength: number;
  46768. /**
  46769. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46770. * 1 means it completely occludes it
  46771. * 0 mean it has no impact
  46772. */
  46773. ambientTextureImpactOnAnalyticalLights: number;
  46774. /**
  46775. * Stores the alpha values in a texture.
  46776. */
  46777. opacityTexture: BaseTexture;
  46778. /**
  46779. * Stores the reflection values in a texture.
  46780. */
  46781. reflectionTexture: Nullable<BaseTexture>;
  46782. /**
  46783. * Stores the emissive values in a texture.
  46784. */
  46785. emissiveTexture: BaseTexture;
  46786. /**
  46787. * AKA Specular texture in other nomenclature.
  46788. */
  46789. reflectivityTexture: BaseTexture;
  46790. /**
  46791. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46792. */
  46793. metallicTexture: BaseTexture;
  46794. /**
  46795. * Specifies the metallic scalar of the metallic/roughness workflow.
  46796. * Can also be used to scale the metalness values of the metallic texture.
  46797. */
  46798. metallic: Nullable<number>;
  46799. /**
  46800. * Specifies the roughness scalar of the metallic/roughness workflow.
  46801. * Can also be used to scale the roughness values of the metallic texture.
  46802. */
  46803. roughness: Nullable<number>;
  46804. /**
  46805. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46806. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46807. */
  46808. microSurfaceTexture: BaseTexture;
  46809. /**
  46810. * Stores surface normal data used to displace a mesh in a texture.
  46811. */
  46812. bumpTexture: BaseTexture;
  46813. /**
  46814. * Stores the pre-calculated light information of a mesh in a texture.
  46815. */
  46816. lightmapTexture: BaseTexture;
  46817. /**
  46818. * Stores the refracted light information in a texture.
  46819. */
  46820. refractionTexture: BaseTexture;
  46821. /**
  46822. * The color of a material in ambient lighting.
  46823. */
  46824. ambientColor: Color3;
  46825. /**
  46826. * AKA Diffuse Color in other nomenclature.
  46827. */
  46828. albedoColor: Color3;
  46829. /**
  46830. * AKA Specular Color in other nomenclature.
  46831. */
  46832. reflectivityColor: Color3;
  46833. /**
  46834. * The color reflected from the material.
  46835. */
  46836. reflectionColor: Color3;
  46837. /**
  46838. * The color emitted from the material.
  46839. */
  46840. emissiveColor: Color3;
  46841. /**
  46842. * AKA Glossiness in other nomenclature.
  46843. */
  46844. microSurface: number;
  46845. /**
  46846. * source material index of refraction (IOR)' / 'destination material IOR.
  46847. */
  46848. indexOfRefraction: number;
  46849. /**
  46850. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46851. */
  46852. invertRefractionY: boolean;
  46853. /**
  46854. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46855. * Materials half opaque for instance using refraction could benefit from this control.
  46856. */
  46857. linkRefractionWithTransparency: boolean;
  46858. /**
  46859. * If true, the light map contains occlusion information instead of lighting info.
  46860. */
  46861. useLightmapAsShadowmap: boolean;
  46862. /**
  46863. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46864. */
  46865. useAlphaFromAlbedoTexture: boolean;
  46866. /**
  46867. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46868. */
  46869. forceAlphaTest: boolean;
  46870. /**
  46871. * Defines the alpha limits in alpha test mode.
  46872. */
  46873. alphaCutOff: number;
  46874. /**
  46875. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46876. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46877. */
  46878. useSpecularOverAlpha: boolean;
  46879. /**
  46880. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46881. */
  46882. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46883. /**
  46884. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46885. */
  46886. useRoughnessFromMetallicTextureAlpha: boolean;
  46887. /**
  46888. * Specifies if the metallic texture contains the roughness information in its green channel.
  46889. */
  46890. useRoughnessFromMetallicTextureGreen: boolean;
  46891. /**
  46892. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46893. */
  46894. useMetallnessFromMetallicTextureBlue: boolean;
  46895. /**
  46896. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46897. */
  46898. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46899. /**
  46900. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46901. */
  46902. useAmbientInGrayScale: boolean;
  46903. /**
  46904. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46905. * The material will try to infer what glossiness each pixel should be.
  46906. */
  46907. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46908. /**
  46909. * BJS is using an harcoded light falloff based on a manually sets up range.
  46910. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46911. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46912. */
  46913. /**
  46914. * BJS is using an harcoded light falloff based on a manually sets up range.
  46915. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46916. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46917. */
  46918. usePhysicalLightFalloff: boolean;
  46919. /**
  46920. * In order to support the falloff compatibility with gltf, a special mode has been added
  46921. * to reproduce the gltf light falloff.
  46922. */
  46923. /**
  46924. * In order to support the falloff compatibility with gltf, a special mode has been added
  46925. * to reproduce the gltf light falloff.
  46926. */
  46927. useGLTFLightFalloff: boolean;
  46928. /**
  46929. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46930. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46931. */
  46932. useRadianceOverAlpha: boolean;
  46933. /**
  46934. * Allows using an object space normal map (instead of tangent space).
  46935. */
  46936. useObjectSpaceNormalMap: boolean;
  46937. /**
  46938. * Allows using the bump map in parallax mode.
  46939. */
  46940. useParallax: boolean;
  46941. /**
  46942. * Allows using the bump map in parallax occlusion mode.
  46943. */
  46944. useParallaxOcclusion: boolean;
  46945. /**
  46946. * Controls the scale bias of the parallax mode.
  46947. */
  46948. parallaxScaleBias: number;
  46949. /**
  46950. * If sets to true, disables all the lights affecting the material.
  46951. */
  46952. disableLighting: boolean;
  46953. /**
  46954. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46955. */
  46956. forceIrradianceInFragment: boolean;
  46957. /**
  46958. * Number of Simultaneous lights allowed on the material.
  46959. */
  46960. maxSimultaneousLights: number;
  46961. /**
  46962. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46963. */
  46964. invertNormalMapX: boolean;
  46965. /**
  46966. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46967. */
  46968. invertNormalMapY: boolean;
  46969. /**
  46970. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46971. */
  46972. twoSidedLighting: boolean;
  46973. /**
  46974. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46975. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46976. */
  46977. useAlphaFresnel: boolean;
  46978. /**
  46979. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46980. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46981. */
  46982. useLinearAlphaFresnel: boolean;
  46983. /**
  46984. * Let user defines the brdf lookup texture used for IBL.
  46985. * A default 8bit version is embedded but you could point at :
  46986. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46987. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46988. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46989. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46990. */
  46991. environmentBRDFTexture: Nullable<BaseTexture>;
  46992. /**
  46993. * Force normal to face away from face.
  46994. */
  46995. forceNormalForward: boolean;
  46996. /**
  46997. * Enables specular anti aliasing in the PBR shader.
  46998. * It will both interacts on the Geometry for analytical and IBL lighting.
  46999. * It also prefilter the roughness map based on the bump values.
  47000. */
  47001. enableSpecularAntiAliasing: boolean;
  47002. /**
  47003. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47004. * makes the reflect vector face the model (under horizon).
  47005. */
  47006. useHorizonOcclusion: boolean;
  47007. /**
  47008. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47009. * too much the area relying on ambient texture to define their ambient occlusion.
  47010. */
  47011. useRadianceOcclusion: boolean;
  47012. /**
  47013. * If set to true, no lighting calculations will be applied.
  47014. */
  47015. unlit: boolean;
  47016. /**
  47017. * Gets the image processing configuration used either in this material.
  47018. */
  47019. /**
  47020. * Sets the Default image processing configuration used either in the this material.
  47021. *
  47022. * If sets to null, the scene one is in use.
  47023. */
  47024. imageProcessingConfiguration: ImageProcessingConfiguration;
  47025. /**
  47026. * Gets wether the color curves effect is enabled.
  47027. */
  47028. /**
  47029. * Sets wether the color curves effect is enabled.
  47030. */
  47031. cameraColorCurvesEnabled: boolean;
  47032. /**
  47033. * Gets wether the color grading effect is enabled.
  47034. */
  47035. /**
  47036. * Gets wether the color grading effect is enabled.
  47037. */
  47038. cameraColorGradingEnabled: boolean;
  47039. /**
  47040. * Gets wether tonemapping is enabled or not.
  47041. */
  47042. /**
  47043. * Sets wether tonemapping is enabled or not
  47044. */
  47045. cameraToneMappingEnabled: boolean;
  47046. /**
  47047. * The camera exposure used on this material.
  47048. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47049. * This corresponds to a photographic exposure.
  47050. */
  47051. /**
  47052. * The camera exposure used on this material.
  47053. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47054. * This corresponds to a photographic exposure.
  47055. */
  47056. cameraExposure: number;
  47057. /**
  47058. * Gets The camera contrast used on this material.
  47059. */
  47060. /**
  47061. * Sets The camera contrast used on this material.
  47062. */
  47063. cameraContrast: number;
  47064. /**
  47065. * Gets the Color Grading 2D Lookup Texture.
  47066. */
  47067. /**
  47068. * Sets the Color Grading 2D Lookup Texture.
  47069. */
  47070. cameraColorGradingTexture: Nullable<BaseTexture>;
  47071. /**
  47072. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47073. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47074. * 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;
  47075. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47076. */
  47077. /**
  47078. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47079. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47080. * 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;
  47081. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47082. */
  47083. cameraColorCurves: Nullable<ColorCurves>;
  47084. /**
  47085. * Instantiates a new PBRMaterial instance.
  47086. *
  47087. * @param name The material name
  47088. * @param scene The scene the material will be use in.
  47089. */
  47090. constructor(name: string, scene: Scene);
  47091. /**
  47092. * Returns the name of this material class.
  47093. */
  47094. getClassName(): string;
  47095. /**
  47096. * Makes a duplicate of the current material.
  47097. * @param name - name to use for the new material.
  47098. */
  47099. clone(name: string): PBRMaterial;
  47100. /**
  47101. * Serializes this PBR Material.
  47102. * @returns - An object with the serialized material.
  47103. */
  47104. serialize(): any;
  47105. /**
  47106. * Parses a PBR Material from a serialized object.
  47107. * @param source - Serialized object.
  47108. * @param scene - BJS scene instance.
  47109. * @param rootUrl - url for the scene object
  47110. * @returns - PBRMaterial
  47111. */
  47112. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47113. }
  47114. }
  47115. declare module "babylonjs/Misc/dds" {
  47116. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47117. import { Engine } from "babylonjs/Engines/engine";
  47118. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47119. import { Nullable } from "babylonjs/types";
  47120. import { Scene } from "babylonjs/scene";
  47121. /**
  47122. * Direct draw surface info
  47123. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47124. */
  47125. export interface DDSInfo {
  47126. /**
  47127. * Width of the texture
  47128. */
  47129. width: number;
  47130. /**
  47131. * Width of the texture
  47132. */
  47133. height: number;
  47134. /**
  47135. * Number of Mipmaps for the texture
  47136. * @see https://en.wikipedia.org/wiki/Mipmap
  47137. */
  47138. mipmapCount: number;
  47139. /**
  47140. * If the textures format is a known fourCC format
  47141. * @see https://www.fourcc.org/
  47142. */
  47143. isFourCC: boolean;
  47144. /**
  47145. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47146. */
  47147. isRGB: boolean;
  47148. /**
  47149. * If the texture is a lumincance format
  47150. */
  47151. isLuminance: boolean;
  47152. /**
  47153. * If this is a cube texture
  47154. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47155. */
  47156. isCube: boolean;
  47157. /**
  47158. * If the texture is a compressed format eg. FOURCC_DXT1
  47159. */
  47160. isCompressed: boolean;
  47161. /**
  47162. * The dxgiFormat of the texture
  47163. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47164. */
  47165. dxgiFormat: number;
  47166. /**
  47167. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47168. */
  47169. textureType: number;
  47170. /**
  47171. * Sphericle polynomial created for the dds texture
  47172. */
  47173. sphericalPolynomial?: SphericalPolynomial;
  47174. }
  47175. /**
  47176. * Class used to provide DDS decompression tools
  47177. */
  47178. export class DDSTools {
  47179. /**
  47180. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47181. */
  47182. static StoreLODInAlphaChannel: boolean;
  47183. /**
  47184. * Gets DDS information from an array buffer
  47185. * @param arrayBuffer defines the array buffer to read data from
  47186. * @returns the DDS information
  47187. */
  47188. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47189. private static _FloatView;
  47190. private static _Int32View;
  47191. private static _ToHalfFloat;
  47192. private static _FromHalfFloat;
  47193. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47194. private static _GetHalfFloatRGBAArrayBuffer;
  47195. private static _GetFloatRGBAArrayBuffer;
  47196. private static _GetFloatAsUIntRGBAArrayBuffer;
  47197. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47198. private static _GetRGBAArrayBuffer;
  47199. private static _ExtractLongWordOrder;
  47200. private static _GetRGBArrayBuffer;
  47201. private static _GetLuminanceArrayBuffer;
  47202. /**
  47203. * Uploads DDS Levels to a Babylon Texture
  47204. * @hidden
  47205. */
  47206. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47207. }
  47208. module "babylonjs/Engines/engine" {
  47209. interface Engine {
  47210. /**
  47211. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47212. * @param rootUrl defines the url where the file to load is located
  47213. * @param scene defines the current scene
  47214. * @param lodScale defines scale to apply to the mip map selection
  47215. * @param lodOffset defines offset to apply to the mip map selection
  47216. * @param onLoad defines an optional callback raised when the texture is loaded
  47217. * @param onError defines an optional callback raised if there is an issue to load the texture
  47218. * @param format defines the format of the data
  47219. * @param forcedExtension defines the extension to use to pick the right loader
  47220. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47221. * @returns the cube texture as an InternalTexture
  47222. */
  47223. 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;
  47224. }
  47225. }
  47226. }
  47227. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47228. import { Nullable } from "babylonjs/types";
  47229. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47230. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47231. /**
  47232. * Implementation of the DDS Texture Loader.
  47233. * @hidden
  47234. */
  47235. export class _DDSTextureLoader implements IInternalTextureLoader {
  47236. /**
  47237. * Defines wether the loader supports cascade loading the different faces.
  47238. */
  47239. readonly supportCascades: boolean;
  47240. /**
  47241. * This returns if the loader support the current file information.
  47242. * @param extension defines the file extension of the file being loaded
  47243. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47244. * @param fallback defines the fallback internal texture if any
  47245. * @param isBase64 defines whether the texture is encoded as a base64
  47246. * @param isBuffer defines whether the texture data are stored as a buffer
  47247. * @returns true if the loader can load the specified file
  47248. */
  47249. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47250. /**
  47251. * Transform the url before loading if required.
  47252. * @param rootUrl the url of the texture
  47253. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47254. * @returns the transformed texture
  47255. */
  47256. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47257. /**
  47258. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47259. * @param rootUrl the url of the texture
  47260. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47261. * @returns the fallback texture
  47262. */
  47263. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47264. /**
  47265. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47266. * @param data contains the texture data
  47267. * @param texture defines the BabylonJS internal texture
  47268. * @param createPolynomials will be true if polynomials have been requested
  47269. * @param onLoad defines the callback to trigger once the texture is ready
  47270. * @param onError defines the callback to trigger in case of error
  47271. */
  47272. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47273. /**
  47274. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47275. * @param data contains the texture data
  47276. * @param texture defines the BabylonJS internal texture
  47277. * @param callback defines the method to call once ready to upload
  47278. */
  47279. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47280. }
  47281. }
  47282. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47283. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47284. /** @hidden */
  47285. export var rgbdEncodePixelShader: {
  47286. name: string;
  47287. shader: string;
  47288. };
  47289. }
  47290. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47291. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47292. /** @hidden */
  47293. export var rgbdDecodePixelShader: {
  47294. name: string;
  47295. shader: string;
  47296. };
  47297. }
  47298. declare module "babylonjs/Misc/environmentTextureTools" {
  47299. import { Nullable } from "babylonjs/types";
  47300. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47301. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47302. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47303. import "babylonjs/Shaders/rgbdEncode.fragment";
  47304. import "babylonjs/Shaders/rgbdDecode.fragment";
  47305. /**
  47306. * Raw texture data and descriptor sufficient for WebGL texture upload
  47307. */
  47308. export interface EnvironmentTextureInfo {
  47309. /**
  47310. * Version of the environment map
  47311. */
  47312. version: number;
  47313. /**
  47314. * Width of image
  47315. */
  47316. width: number;
  47317. /**
  47318. * Irradiance information stored in the file.
  47319. */
  47320. irradiance: any;
  47321. /**
  47322. * Specular information stored in the file.
  47323. */
  47324. specular: any;
  47325. }
  47326. /**
  47327. * Sets of helpers addressing the serialization and deserialization of environment texture
  47328. * stored in a BabylonJS env file.
  47329. * Those files are usually stored as .env files.
  47330. */
  47331. export class EnvironmentTextureTools {
  47332. /**
  47333. * Magic number identifying the env file.
  47334. */
  47335. private static _MagicBytes;
  47336. /**
  47337. * Gets the environment info from an env file.
  47338. * @param data The array buffer containing the .env bytes.
  47339. * @returns the environment file info (the json header) if successfully parsed.
  47340. */
  47341. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47342. /**
  47343. * Creates an environment texture from a loaded cube texture.
  47344. * @param texture defines the cube texture to convert in env file
  47345. * @return a promise containing the environment data if succesfull.
  47346. */
  47347. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47348. /**
  47349. * Creates a JSON representation of the spherical data.
  47350. * @param texture defines the texture containing the polynomials
  47351. * @return the JSON representation of the spherical info
  47352. */
  47353. private static _CreateEnvTextureIrradiance;
  47354. /**
  47355. * Uploads the texture info contained in the env file to the GPU.
  47356. * @param texture defines the internal texture to upload to
  47357. * @param arrayBuffer defines the buffer cotaining the data to load
  47358. * @param info defines the texture info retrieved through the GetEnvInfo method
  47359. * @returns a promise
  47360. */
  47361. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47362. /**
  47363. * Uploads the levels of image data to the GPU.
  47364. * @param texture defines the internal texture to upload to
  47365. * @param imageData defines the array buffer views of image data [mipmap][face]
  47366. * @returns a promise
  47367. */
  47368. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47369. /**
  47370. * Uploads spherical polynomials information to the texture.
  47371. * @param texture defines the texture we are trying to upload the information to
  47372. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47373. */
  47374. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47375. /** @hidden */
  47376. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47377. }
  47378. }
  47379. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47380. import { Nullable } from "babylonjs/types";
  47381. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47382. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47383. /**
  47384. * Implementation of the ENV Texture Loader.
  47385. * @hidden
  47386. */
  47387. export class _ENVTextureLoader implements IInternalTextureLoader {
  47388. /**
  47389. * Defines wether the loader supports cascade loading the different faces.
  47390. */
  47391. readonly supportCascades: boolean;
  47392. /**
  47393. * This returns if the loader support the current file information.
  47394. * @param extension defines the file extension of the file being loaded
  47395. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47396. * @param fallback defines the fallback internal texture if any
  47397. * @param isBase64 defines whether the texture is encoded as a base64
  47398. * @param isBuffer defines whether the texture data are stored as a buffer
  47399. * @returns true if the loader can load the specified file
  47400. */
  47401. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47402. /**
  47403. * Transform the url before loading if required.
  47404. * @param rootUrl the url of the texture
  47405. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47406. * @returns the transformed texture
  47407. */
  47408. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47409. /**
  47410. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47411. * @param rootUrl the url of the texture
  47412. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47413. * @returns the fallback texture
  47414. */
  47415. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47416. /**
  47417. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47418. * @param data contains the texture data
  47419. * @param texture defines the BabylonJS internal texture
  47420. * @param createPolynomials will be true if polynomials have been requested
  47421. * @param onLoad defines the callback to trigger once the texture is ready
  47422. * @param onError defines the callback to trigger in case of error
  47423. */
  47424. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47425. /**
  47426. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47427. * @param data contains the texture data
  47428. * @param texture defines the BabylonJS internal texture
  47429. * @param callback defines the method to call once ready to upload
  47430. */
  47431. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47432. }
  47433. }
  47434. declare module "babylonjs/Misc/khronosTextureContainer" {
  47435. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47436. /**
  47437. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47438. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47439. */
  47440. export class KhronosTextureContainer {
  47441. /** contents of the KTX container file */
  47442. arrayBuffer: any;
  47443. private static HEADER_LEN;
  47444. private static COMPRESSED_2D;
  47445. private static COMPRESSED_3D;
  47446. private static TEX_2D;
  47447. private static TEX_3D;
  47448. /**
  47449. * Gets the openGL type
  47450. */
  47451. glType: number;
  47452. /**
  47453. * Gets the openGL type size
  47454. */
  47455. glTypeSize: number;
  47456. /**
  47457. * Gets the openGL format
  47458. */
  47459. glFormat: number;
  47460. /**
  47461. * Gets the openGL internal format
  47462. */
  47463. glInternalFormat: number;
  47464. /**
  47465. * Gets the base internal format
  47466. */
  47467. glBaseInternalFormat: number;
  47468. /**
  47469. * Gets image width in pixel
  47470. */
  47471. pixelWidth: number;
  47472. /**
  47473. * Gets image height in pixel
  47474. */
  47475. pixelHeight: number;
  47476. /**
  47477. * Gets image depth in pixels
  47478. */
  47479. pixelDepth: number;
  47480. /**
  47481. * Gets the number of array elements
  47482. */
  47483. numberOfArrayElements: number;
  47484. /**
  47485. * Gets the number of faces
  47486. */
  47487. numberOfFaces: number;
  47488. /**
  47489. * Gets the number of mipmap levels
  47490. */
  47491. numberOfMipmapLevels: number;
  47492. /**
  47493. * Gets the bytes of key value data
  47494. */
  47495. bytesOfKeyValueData: number;
  47496. /**
  47497. * Gets the load type
  47498. */
  47499. loadType: number;
  47500. /**
  47501. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47502. */
  47503. isInvalid: boolean;
  47504. /**
  47505. * Creates a new KhronosTextureContainer
  47506. * @param arrayBuffer contents of the KTX container file
  47507. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47508. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47509. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47510. */
  47511. constructor(
  47512. /** contents of the KTX container file */
  47513. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47514. /**
  47515. * Uploads KTX content to a Babylon Texture.
  47516. * It is assumed that the texture has already been created & is currently bound
  47517. * @hidden
  47518. */
  47519. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47520. private _upload2DCompressedLevels;
  47521. }
  47522. }
  47523. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47524. import { Nullable } from "babylonjs/types";
  47525. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47526. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47527. /**
  47528. * Implementation of the KTX Texture Loader.
  47529. * @hidden
  47530. */
  47531. export class _KTXTextureLoader implements IInternalTextureLoader {
  47532. /**
  47533. * Defines wether the loader supports cascade loading the different faces.
  47534. */
  47535. readonly supportCascades: boolean;
  47536. /**
  47537. * This returns if the loader support the current file information.
  47538. * @param extension defines the file extension of the file being loaded
  47539. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47540. * @param fallback defines the fallback internal texture if any
  47541. * @param isBase64 defines whether the texture is encoded as a base64
  47542. * @param isBuffer defines whether the texture data are stored as a buffer
  47543. * @returns true if the loader can load the specified file
  47544. */
  47545. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47546. /**
  47547. * Transform the url before loading if required.
  47548. * @param rootUrl the url of the texture
  47549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47550. * @returns the transformed texture
  47551. */
  47552. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47553. /**
  47554. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47555. * @param rootUrl the url of the texture
  47556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47557. * @returns the fallback texture
  47558. */
  47559. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47560. /**
  47561. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47562. * @param data contains the texture data
  47563. * @param texture defines the BabylonJS internal texture
  47564. * @param createPolynomials will be true if polynomials have been requested
  47565. * @param onLoad defines the callback to trigger once the texture is ready
  47566. * @param onError defines the callback to trigger in case of error
  47567. */
  47568. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47569. /**
  47570. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47571. * @param data contains the texture data
  47572. * @param texture defines the BabylonJS internal texture
  47573. * @param callback defines the method to call once ready to upload
  47574. */
  47575. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47576. }
  47577. }
  47578. declare module "babylonjs/Helpers/sceneHelpers" {
  47579. import { Nullable } from "babylonjs/types";
  47580. import { Mesh } from "babylonjs/Meshes/mesh";
  47581. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47582. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  47583. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47584. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  47585. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  47586. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  47587. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  47588. import "babylonjs/Meshes/Builders/boxBuilder";
  47589. /** @hidden */
  47590. export var _forceSceneHelpersToBundle: boolean;
  47591. module "babylonjs/scene" {
  47592. interface Scene {
  47593. /**
  47594. * Creates a default light for the scene.
  47595. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47596. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47597. */
  47598. createDefaultLight(replace?: boolean): void;
  47599. /**
  47600. * Creates a default camera for the scene.
  47601. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47602. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47603. * @param replace has default false, when true replaces the active camera in the scene
  47604. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47605. */
  47606. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47607. /**
  47608. * Creates a default camera and a default light.
  47609. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47610. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47611. * @param replace has the default false, when true replaces the active camera/light in the scene
  47612. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47613. */
  47614. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47615. /**
  47616. * Creates a new sky box
  47617. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47618. * @param environmentTexture defines the texture to use as environment texture
  47619. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47620. * @param scale defines the overall scale of the skybox
  47621. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47622. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47623. * @returns a new mesh holding the sky box
  47624. */
  47625. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47626. /**
  47627. * Creates a new environment
  47628. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47629. * @param options defines the options you can use to configure the environment
  47630. * @returns the new EnvironmentHelper
  47631. */
  47632. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47633. /**
  47634. * Creates a new VREXperienceHelper
  47635. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47636. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47637. * @returns a new VREXperienceHelper
  47638. */
  47639. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47640. /**
  47641. * Creates a new XREXperienceHelper
  47642. * @see http://doc.babylonjs.com/how_to/webxr
  47643. * @returns a promise for a new XREXperienceHelper
  47644. */
  47645. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47646. }
  47647. }
  47648. }
  47649. declare module "babylonjs/Helpers/videoDome" {
  47650. import { Scene } from "babylonjs/scene";
  47651. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47652. import { Mesh } from "babylonjs/Meshes/mesh";
  47653. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  47654. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47655. import "babylonjs/Meshes/Builders/sphereBuilder";
  47656. /**
  47657. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47658. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47659. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47660. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47661. */
  47662. export class VideoDome extends TransformNode {
  47663. /**
  47664. * Define the video source as a Monoscopic panoramic 360 video.
  47665. */
  47666. static readonly MODE_MONOSCOPIC: number;
  47667. /**
  47668. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47669. */
  47670. static readonly MODE_TOPBOTTOM: number;
  47671. /**
  47672. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47673. */
  47674. static readonly MODE_SIDEBYSIDE: number;
  47675. private _useDirectMapping;
  47676. /**
  47677. * The video texture being displayed on the sphere
  47678. */
  47679. protected _videoTexture: VideoTexture;
  47680. /**
  47681. * Gets the video texture being displayed on the sphere
  47682. */
  47683. readonly videoTexture: VideoTexture;
  47684. /**
  47685. * The skybox material
  47686. */
  47687. protected _material: BackgroundMaterial;
  47688. /**
  47689. * The surface used for the skybox
  47690. */
  47691. protected _mesh: Mesh;
  47692. /**
  47693. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47694. * Also see the options.resolution property.
  47695. */
  47696. fovMultiplier: number;
  47697. private _videoMode;
  47698. /**
  47699. * Gets or set the current video mode for the video. It can be:
  47700. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47701. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47702. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47703. */
  47704. videoMode: number;
  47705. /**
  47706. * Oberserver used in Stereoscopic VR Mode.
  47707. */
  47708. private _onBeforeCameraRenderObserver;
  47709. /**
  47710. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47711. * @param name Element's name, child elements will append suffixes for their own names.
  47712. * @param urlsOrVideo defines the url(s) or the video element to use
  47713. * @param options An object containing optional or exposed sub element properties
  47714. */
  47715. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47716. resolution?: number;
  47717. clickToPlay?: boolean;
  47718. autoPlay?: boolean;
  47719. loop?: boolean;
  47720. size?: number;
  47721. poster?: string;
  47722. faceForward?: boolean;
  47723. useDirectMapping?: boolean;
  47724. }, scene: Scene);
  47725. private _changeVideoMode;
  47726. /**
  47727. * Releases resources associated with this node.
  47728. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47729. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47730. */
  47731. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47732. }
  47733. }
  47734. declare module "babylonjs/Helpers/index" {
  47735. export * from "babylonjs/Helpers/environmentHelper";
  47736. export * from "babylonjs/Helpers/photoDome";
  47737. export * from "babylonjs/Helpers/sceneHelpers";
  47738. export * from "babylonjs/Helpers/videoDome";
  47739. }
  47740. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  47741. import { PerfCounter } from "babylonjs/Misc/tools";
  47742. import { IDisposable } from "babylonjs/scene";
  47743. import { Engine } from "babylonjs/Engines/engine";
  47744. /**
  47745. * This class can be used to get instrumentation data from a Babylon engine
  47746. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47747. */
  47748. export class EngineInstrumentation implements IDisposable {
  47749. /**
  47750. * Define the instrumented engine.
  47751. */
  47752. engine: Engine;
  47753. private _captureGPUFrameTime;
  47754. private _gpuFrameTimeToken;
  47755. private _gpuFrameTime;
  47756. private _captureShaderCompilationTime;
  47757. private _shaderCompilationTime;
  47758. private _onBeginFrameObserver;
  47759. private _onEndFrameObserver;
  47760. private _onBeforeShaderCompilationObserver;
  47761. private _onAfterShaderCompilationObserver;
  47762. /**
  47763. * Gets the perf counter used for GPU frame time
  47764. */
  47765. readonly gpuFrameTimeCounter: PerfCounter;
  47766. /**
  47767. * Gets the GPU frame time capture status
  47768. */
  47769. /**
  47770. * Enable or disable the GPU frame time capture
  47771. */
  47772. captureGPUFrameTime: boolean;
  47773. /**
  47774. * Gets the perf counter used for shader compilation time
  47775. */
  47776. readonly shaderCompilationTimeCounter: PerfCounter;
  47777. /**
  47778. * Gets the shader compilation time capture status
  47779. */
  47780. /**
  47781. * Enable or disable the shader compilation time capture
  47782. */
  47783. captureShaderCompilationTime: boolean;
  47784. /**
  47785. * Instantiates a new engine instrumentation.
  47786. * This class can be used to get instrumentation data from a Babylon engine
  47787. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47788. * @param engine Defines the engine to instrument
  47789. */
  47790. constructor(
  47791. /**
  47792. * Define the instrumented engine.
  47793. */
  47794. engine: Engine);
  47795. /**
  47796. * Dispose and release associated resources.
  47797. */
  47798. dispose(): void;
  47799. }
  47800. }
  47801. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  47802. import { PerfCounter } from "babylonjs/Misc/tools";
  47803. import { Scene, IDisposable } from "babylonjs/scene";
  47804. /**
  47805. * This class can be used to get instrumentation data from a Babylon engine
  47806. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47807. */
  47808. export class SceneInstrumentation implements IDisposable {
  47809. /**
  47810. * Defines the scene to instrument
  47811. */
  47812. scene: Scene;
  47813. private _captureActiveMeshesEvaluationTime;
  47814. private _activeMeshesEvaluationTime;
  47815. private _captureRenderTargetsRenderTime;
  47816. private _renderTargetsRenderTime;
  47817. private _captureFrameTime;
  47818. private _frameTime;
  47819. private _captureRenderTime;
  47820. private _renderTime;
  47821. private _captureInterFrameTime;
  47822. private _interFrameTime;
  47823. private _captureParticlesRenderTime;
  47824. private _particlesRenderTime;
  47825. private _captureSpritesRenderTime;
  47826. private _spritesRenderTime;
  47827. private _capturePhysicsTime;
  47828. private _physicsTime;
  47829. private _captureAnimationsTime;
  47830. private _animationsTime;
  47831. private _captureCameraRenderTime;
  47832. private _cameraRenderTime;
  47833. private _onBeforeActiveMeshesEvaluationObserver;
  47834. private _onAfterActiveMeshesEvaluationObserver;
  47835. private _onBeforeRenderTargetsRenderObserver;
  47836. private _onAfterRenderTargetsRenderObserver;
  47837. private _onAfterRenderObserver;
  47838. private _onBeforeDrawPhaseObserver;
  47839. private _onAfterDrawPhaseObserver;
  47840. private _onBeforeAnimationsObserver;
  47841. private _onBeforeParticlesRenderingObserver;
  47842. private _onAfterParticlesRenderingObserver;
  47843. private _onBeforeSpritesRenderingObserver;
  47844. private _onAfterSpritesRenderingObserver;
  47845. private _onBeforePhysicsObserver;
  47846. private _onAfterPhysicsObserver;
  47847. private _onAfterAnimationsObserver;
  47848. private _onBeforeCameraRenderObserver;
  47849. private _onAfterCameraRenderObserver;
  47850. /**
  47851. * Gets the perf counter used for active meshes evaluation time
  47852. */
  47853. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47854. /**
  47855. * Gets the active meshes evaluation time capture status
  47856. */
  47857. /**
  47858. * Enable or disable the active meshes evaluation time capture
  47859. */
  47860. captureActiveMeshesEvaluationTime: boolean;
  47861. /**
  47862. * Gets the perf counter used for render targets render time
  47863. */
  47864. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47865. /**
  47866. * Gets the render targets render time capture status
  47867. */
  47868. /**
  47869. * Enable or disable the render targets render time capture
  47870. */
  47871. captureRenderTargetsRenderTime: boolean;
  47872. /**
  47873. * Gets the perf counter used for particles render time
  47874. */
  47875. readonly particlesRenderTimeCounter: PerfCounter;
  47876. /**
  47877. * Gets the particles render time capture status
  47878. */
  47879. /**
  47880. * Enable or disable the particles render time capture
  47881. */
  47882. captureParticlesRenderTime: boolean;
  47883. /**
  47884. * Gets the perf counter used for sprites render time
  47885. */
  47886. readonly spritesRenderTimeCounter: PerfCounter;
  47887. /**
  47888. * Gets the sprites render time capture status
  47889. */
  47890. /**
  47891. * Enable or disable the sprites render time capture
  47892. */
  47893. captureSpritesRenderTime: boolean;
  47894. /**
  47895. * Gets the perf counter used for physics time
  47896. */
  47897. readonly physicsTimeCounter: PerfCounter;
  47898. /**
  47899. * Gets the physics time capture status
  47900. */
  47901. /**
  47902. * Enable or disable the physics time capture
  47903. */
  47904. capturePhysicsTime: boolean;
  47905. /**
  47906. * Gets the perf counter used for animations time
  47907. */
  47908. readonly animationsTimeCounter: PerfCounter;
  47909. /**
  47910. * Gets the animations time capture status
  47911. */
  47912. /**
  47913. * Enable or disable the animations time capture
  47914. */
  47915. captureAnimationsTime: boolean;
  47916. /**
  47917. * Gets the perf counter used for frame time capture
  47918. */
  47919. readonly frameTimeCounter: PerfCounter;
  47920. /**
  47921. * Gets the frame time capture status
  47922. */
  47923. /**
  47924. * Enable or disable the frame time capture
  47925. */
  47926. captureFrameTime: boolean;
  47927. /**
  47928. * Gets the perf counter used for inter-frames time capture
  47929. */
  47930. readonly interFrameTimeCounter: PerfCounter;
  47931. /**
  47932. * Gets the inter-frames time capture status
  47933. */
  47934. /**
  47935. * Enable or disable the inter-frames time capture
  47936. */
  47937. captureInterFrameTime: boolean;
  47938. /**
  47939. * Gets the perf counter used for render time capture
  47940. */
  47941. readonly renderTimeCounter: PerfCounter;
  47942. /**
  47943. * Gets the render time capture status
  47944. */
  47945. /**
  47946. * Enable or disable the render time capture
  47947. */
  47948. captureRenderTime: boolean;
  47949. /**
  47950. * Gets the perf counter used for camera render time capture
  47951. */
  47952. readonly cameraRenderTimeCounter: PerfCounter;
  47953. /**
  47954. * Gets the camera render time capture status
  47955. */
  47956. /**
  47957. * Enable or disable the camera render time capture
  47958. */
  47959. captureCameraRenderTime: boolean;
  47960. /**
  47961. * Gets the perf counter used for draw calls
  47962. */
  47963. readonly drawCallsCounter: PerfCounter;
  47964. /**
  47965. * Gets the perf counter used for texture collisions
  47966. */
  47967. readonly textureCollisionsCounter: PerfCounter;
  47968. /**
  47969. * Instantiates a new scene instrumentation.
  47970. * This class can be used to get instrumentation data from a Babylon engine
  47971. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47972. * @param scene Defines the scene to instrument
  47973. */
  47974. constructor(
  47975. /**
  47976. * Defines the scene to instrument
  47977. */
  47978. scene: Scene);
  47979. /**
  47980. * Dispose and release associated resources.
  47981. */
  47982. dispose(): void;
  47983. }
  47984. }
  47985. declare module "babylonjs/Instrumentation/index" {
  47986. export * from "babylonjs/Instrumentation/engineInstrumentation";
  47987. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  47988. export * from "babylonjs/Instrumentation/timeToken";
  47989. }
  47990. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  47991. /** @hidden */
  47992. export var glowMapGenerationPixelShader: {
  47993. name: string;
  47994. shader: string;
  47995. };
  47996. }
  47997. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  47998. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47999. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48000. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48001. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48002. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48003. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48004. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48005. /** @hidden */
  48006. export var glowMapGenerationVertexShader: {
  48007. name: string;
  48008. shader: string;
  48009. };
  48010. }
  48011. declare module "babylonjs/Layers/effectLayer" {
  48012. import { Observable } from "babylonjs/Misc/observable";
  48013. import { Nullable } from "babylonjs/types";
  48014. import { Camera } from "babylonjs/Cameras/camera";
  48015. import { Scene } from "babylonjs/scene";
  48016. import { Color4, ISize } from "babylonjs/Maths/math";
  48017. import { Engine } from "babylonjs/Engines/engine";
  48018. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48020. import { Mesh } from "babylonjs/Meshes/mesh";
  48021. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48022. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48023. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48024. import { Effect } from "babylonjs/Materials/effect";
  48025. import { Material } from "babylonjs/Materials/material";
  48026. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48027. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48028. /**
  48029. * Effect layer options. This helps customizing the behaviour
  48030. * of the effect layer.
  48031. */
  48032. export interface IEffectLayerOptions {
  48033. /**
  48034. * Multiplication factor apply to the canvas size to compute the render target size
  48035. * used to generated the objects (the smaller the faster).
  48036. */
  48037. mainTextureRatio: number;
  48038. /**
  48039. * Enforces a fixed size texture to ensure effect stability across devices.
  48040. */
  48041. mainTextureFixedSize?: number;
  48042. /**
  48043. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48044. */
  48045. alphaBlendingMode: number;
  48046. /**
  48047. * The camera attached to the layer.
  48048. */
  48049. camera: Nullable<Camera>;
  48050. /**
  48051. * The rendering group to draw the layer in.
  48052. */
  48053. renderingGroupId: number;
  48054. }
  48055. /**
  48056. * The effect layer Helps adding post process effect blended with the main pass.
  48057. *
  48058. * This can be for instance use to generate glow or higlight effects on the scene.
  48059. *
  48060. * The effect layer class can not be used directly and is intented to inherited from to be
  48061. * customized per effects.
  48062. */
  48063. export abstract class EffectLayer {
  48064. private _vertexBuffers;
  48065. private _indexBuffer;
  48066. private _cachedDefines;
  48067. private _effectLayerMapGenerationEffect;
  48068. private _effectLayerOptions;
  48069. private _mergeEffect;
  48070. protected _scene: Scene;
  48071. protected _engine: Engine;
  48072. protected _maxSize: number;
  48073. protected _mainTextureDesiredSize: ISize;
  48074. protected _mainTexture: RenderTargetTexture;
  48075. protected _shouldRender: boolean;
  48076. protected _postProcesses: PostProcess[];
  48077. protected _textures: BaseTexture[];
  48078. protected _emissiveTextureAndColor: {
  48079. texture: Nullable<BaseTexture>;
  48080. color: Color4;
  48081. };
  48082. /**
  48083. * The name of the layer
  48084. */
  48085. name: string;
  48086. /**
  48087. * The clear color of the texture used to generate the glow map.
  48088. */
  48089. neutralColor: Color4;
  48090. /**
  48091. * Specifies wether the highlight layer is enabled or not.
  48092. */
  48093. isEnabled: boolean;
  48094. /**
  48095. * Gets the camera attached to the layer.
  48096. */
  48097. readonly camera: Nullable<Camera>;
  48098. /**
  48099. * Gets the rendering group id the layer should render in.
  48100. */
  48101. readonly renderingGroupId: number;
  48102. /**
  48103. * An event triggered when the effect layer has been disposed.
  48104. */
  48105. onDisposeObservable: Observable<EffectLayer>;
  48106. /**
  48107. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48108. */
  48109. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48110. /**
  48111. * An event triggered when the generated texture is being merged in the scene.
  48112. */
  48113. onBeforeComposeObservable: Observable<EffectLayer>;
  48114. /**
  48115. * An event triggered when the generated texture has been merged in the scene.
  48116. */
  48117. onAfterComposeObservable: Observable<EffectLayer>;
  48118. /**
  48119. * An event triggered when the efffect layer changes its size.
  48120. */
  48121. onSizeChangedObservable: Observable<EffectLayer>;
  48122. /** @hidden */
  48123. static _SceneComponentInitialization: (scene: Scene) => void;
  48124. /**
  48125. * Instantiates a new effect Layer and references it in the scene.
  48126. * @param name The name of the layer
  48127. * @param scene The scene to use the layer in
  48128. */
  48129. constructor(
  48130. /** The Friendly of the effect in the scene */
  48131. name: string, scene: Scene);
  48132. /**
  48133. * Get the effect name of the layer.
  48134. * @return The effect name
  48135. */
  48136. abstract getEffectName(): string;
  48137. /**
  48138. * Checks for the readiness of the element composing the layer.
  48139. * @param subMesh the mesh to check for
  48140. * @param useInstances specify wether or not to use instances to render the mesh
  48141. * @return true if ready otherwise, false
  48142. */
  48143. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48144. /**
  48145. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48146. * @returns true if the effect requires stencil during the main canvas render pass.
  48147. */
  48148. abstract needStencil(): boolean;
  48149. /**
  48150. * Create the merge effect. This is the shader use to blit the information back
  48151. * to the main canvas at the end of the scene rendering.
  48152. * @returns The effect containing the shader used to merge the effect on the main canvas
  48153. */
  48154. protected abstract _createMergeEffect(): Effect;
  48155. /**
  48156. * Creates the render target textures and post processes used in the effect layer.
  48157. */
  48158. protected abstract _createTextureAndPostProcesses(): void;
  48159. /**
  48160. * Implementation specific of rendering the generating effect on the main canvas.
  48161. * @param effect The effect used to render through
  48162. */
  48163. protected abstract _internalRender(effect: Effect): void;
  48164. /**
  48165. * Sets the required values for both the emissive texture and and the main color.
  48166. */
  48167. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48168. /**
  48169. * Free any resources and references associated to a mesh.
  48170. * Internal use
  48171. * @param mesh The mesh to free.
  48172. */
  48173. abstract _disposeMesh(mesh: Mesh): void;
  48174. /**
  48175. * Serializes this layer (Glow or Highlight for example)
  48176. * @returns a serialized layer object
  48177. */
  48178. abstract serialize?(): any;
  48179. /**
  48180. * Initializes the effect layer with the required options.
  48181. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48182. */
  48183. protected _init(options: Partial<IEffectLayerOptions>): void;
  48184. /**
  48185. * Generates the index buffer of the full screen quad blending to the main canvas.
  48186. */
  48187. private _generateIndexBuffer;
  48188. /**
  48189. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48190. */
  48191. private _genrateVertexBuffer;
  48192. /**
  48193. * Sets the main texture desired size which is the closest power of two
  48194. * of the engine canvas size.
  48195. */
  48196. private _setMainTextureSize;
  48197. /**
  48198. * Creates the main texture for the effect layer.
  48199. */
  48200. protected _createMainTexture(): void;
  48201. /**
  48202. * Adds specific effects defines.
  48203. * @param defines The defines to add specifics to.
  48204. */
  48205. protected _addCustomEffectDefines(defines: string[]): void;
  48206. /**
  48207. * Checks for the readiness of the element composing the layer.
  48208. * @param subMesh the mesh to check for
  48209. * @param useInstances specify wether or not to use instances to render the mesh
  48210. * @param emissiveTexture the associated emissive texture used to generate the glow
  48211. * @return true if ready otherwise, false
  48212. */
  48213. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48214. /**
  48215. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48216. */
  48217. render(): void;
  48218. /**
  48219. * Determine if a given mesh will be used in the current effect.
  48220. * @param mesh mesh to test
  48221. * @returns true if the mesh will be used
  48222. */
  48223. hasMesh(mesh: AbstractMesh): boolean;
  48224. /**
  48225. * Returns true if the layer contains information to display, otherwise false.
  48226. * @returns true if the glow layer should be rendered
  48227. */
  48228. shouldRender(): boolean;
  48229. /**
  48230. * Returns true if the mesh should render, otherwise false.
  48231. * @param mesh The mesh to render
  48232. * @returns true if it should render otherwise false
  48233. */
  48234. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48235. /**
  48236. * Returns true if the mesh can be rendered, otherwise false.
  48237. * @param mesh The mesh to render
  48238. * @param material The material used on the mesh
  48239. * @returns true if it can be rendered otherwise false
  48240. */
  48241. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48242. /**
  48243. * Returns true if the mesh should render, otherwise false.
  48244. * @param mesh The mesh to render
  48245. * @returns true if it should render otherwise false
  48246. */
  48247. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48248. /**
  48249. * Renders the submesh passed in parameter to the generation map.
  48250. */
  48251. protected _renderSubMesh(subMesh: SubMesh): void;
  48252. /**
  48253. * Rebuild the required buffers.
  48254. * @hidden Internal use only.
  48255. */
  48256. _rebuild(): void;
  48257. /**
  48258. * Dispose only the render target textures and post process.
  48259. */
  48260. private _disposeTextureAndPostProcesses;
  48261. /**
  48262. * Dispose the highlight layer and free resources.
  48263. */
  48264. dispose(): void;
  48265. /**
  48266. * Gets the class name of the effect layer
  48267. * @returns the string with the class name of the effect layer
  48268. */
  48269. getClassName(): string;
  48270. /**
  48271. * Creates an effect layer from parsed effect layer data
  48272. * @param parsedEffectLayer defines effect layer data
  48273. * @param scene defines the current scene
  48274. * @param rootUrl defines the root URL containing the effect layer information
  48275. * @returns a parsed effect Layer
  48276. */
  48277. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48278. }
  48279. }
  48280. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48281. import { Scene } from "babylonjs/scene";
  48282. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48283. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48284. import { AbstractScene } from "babylonjs/abstractScene";
  48285. module "babylonjs/abstractScene" {
  48286. interface AbstractScene {
  48287. /**
  48288. * The list of effect layers (highlights/glow) added to the scene
  48289. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48290. * @see http://doc.babylonjs.com/how_to/glow_layer
  48291. */
  48292. effectLayers: Array<EffectLayer>;
  48293. /**
  48294. * Removes the given effect layer from this scene.
  48295. * @param toRemove defines the effect layer to remove
  48296. * @returns the index of the removed effect layer
  48297. */
  48298. removeEffectLayer(toRemove: EffectLayer): number;
  48299. /**
  48300. * Adds the given effect layer to this scene
  48301. * @param newEffectLayer defines the effect layer to add
  48302. */
  48303. addEffectLayer(newEffectLayer: EffectLayer): void;
  48304. }
  48305. }
  48306. /**
  48307. * Defines the layer scene component responsible to manage any effect layers
  48308. * in a given scene.
  48309. */
  48310. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48311. /**
  48312. * The component name helpfull to identify the component in the list of scene components.
  48313. */
  48314. readonly name: string;
  48315. /**
  48316. * The scene the component belongs to.
  48317. */
  48318. scene: Scene;
  48319. private _engine;
  48320. private _renderEffects;
  48321. private _needStencil;
  48322. private _previousStencilState;
  48323. /**
  48324. * Creates a new instance of the component for the given scene
  48325. * @param scene Defines the scene to register the component in
  48326. */
  48327. constructor(scene: Scene);
  48328. /**
  48329. * Registers the component in a given scene
  48330. */
  48331. register(): void;
  48332. /**
  48333. * Rebuilds the elements related to this component in case of
  48334. * context lost for instance.
  48335. */
  48336. rebuild(): void;
  48337. /**
  48338. * Serializes the component data to the specified json object
  48339. * @param serializationObject The object to serialize to
  48340. */
  48341. serialize(serializationObject: any): void;
  48342. /**
  48343. * Adds all the element from the container to the scene
  48344. * @param container the container holding the elements
  48345. */
  48346. addFromContainer(container: AbstractScene): void;
  48347. /**
  48348. * Removes all the elements in the container from the scene
  48349. * @param container contains the elements to remove
  48350. * @param dispose if the removed element should be disposed (default: false)
  48351. */
  48352. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48353. /**
  48354. * Disposes the component and the associated ressources.
  48355. */
  48356. dispose(): void;
  48357. private _isReadyForMesh;
  48358. private _renderMainTexture;
  48359. private _setStencil;
  48360. private _setStencilBack;
  48361. private _draw;
  48362. private _drawCamera;
  48363. private _drawRenderingGroup;
  48364. }
  48365. }
  48366. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  48367. /** @hidden */
  48368. export var glowMapMergePixelShader: {
  48369. name: string;
  48370. shader: string;
  48371. };
  48372. }
  48373. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  48374. /** @hidden */
  48375. export var glowMapMergeVertexShader: {
  48376. name: string;
  48377. shader: string;
  48378. };
  48379. }
  48380. declare module "babylonjs/Layers/glowLayer" {
  48381. import { Nullable } from "babylonjs/types";
  48382. import { Camera } from "babylonjs/Cameras/camera";
  48383. import { Scene } from "babylonjs/scene";
  48384. import { Color4 } from "babylonjs/Maths/math";
  48385. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48387. import { Mesh } from "babylonjs/Meshes/mesh";
  48388. import { Texture } from "babylonjs/Materials/Textures/texture";
  48389. import { Effect } from "babylonjs/Materials/effect";
  48390. import { Material } from "babylonjs/Materials/material";
  48391. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48392. import "babylonjs/Shaders/glowMapMerge.fragment";
  48393. import "babylonjs/Shaders/glowMapMerge.vertex";
  48394. import "babylonjs/Layers/effectLayerSceneComponent";
  48395. module "babylonjs/abstractScene" {
  48396. interface AbstractScene {
  48397. /**
  48398. * Return a the first highlight layer of the scene with a given name.
  48399. * @param name The name of the highlight layer to look for.
  48400. * @return The highlight layer if found otherwise null.
  48401. */
  48402. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48403. }
  48404. }
  48405. /**
  48406. * Glow layer options. This helps customizing the behaviour
  48407. * of the glow layer.
  48408. */
  48409. export interface IGlowLayerOptions {
  48410. /**
  48411. * Multiplication factor apply to the canvas size to compute the render target size
  48412. * used to generated the glowing objects (the smaller the faster).
  48413. */
  48414. mainTextureRatio: number;
  48415. /**
  48416. * Enforces a fixed size texture to ensure resize independant blur.
  48417. */
  48418. mainTextureFixedSize?: number;
  48419. /**
  48420. * How big is the kernel of the blur texture.
  48421. */
  48422. blurKernelSize: number;
  48423. /**
  48424. * The camera attached to the layer.
  48425. */
  48426. camera: Nullable<Camera>;
  48427. /**
  48428. * Enable MSAA by chosing the number of samples.
  48429. */
  48430. mainTextureSamples?: number;
  48431. /**
  48432. * The rendering group to draw the layer in.
  48433. */
  48434. renderingGroupId: number;
  48435. }
  48436. /**
  48437. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48438. *
  48439. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48440. * glowy meshes to your scene.
  48441. *
  48442. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48443. */
  48444. export class GlowLayer extends EffectLayer {
  48445. /**
  48446. * Effect Name of the layer.
  48447. */
  48448. static readonly EffectName: string;
  48449. /**
  48450. * The default blur kernel size used for the glow.
  48451. */
  48452. static DefaultBlurKernelSize: number;
  48453. /**
  48454. * The default texture size ratio used for the glow.
  48455. */
  48456. static DefaultTextureRatio: number;
  48457. /**
  48458. * Sets the kernel size of the blur.
  48459. */
  48460. /**
  48461. * Gets the kernel size of the blur.
  48462. */
  48463. blurKernelSize: number;
  48464. /**
  48465. * Sets the glow intensity.
  48466. */
  48467. /**
  48468. * Gets the glow intensity.
  48469. */
  48470. intensity: number;
  48471. private _options;
  48472. private _intensity;
  48473. private _horizontalBlurPostprocess1;
  48474. private _verticalBlurPostprocess1;
  48475. private _horizontalBlurPostprocess2;
  48476. private _verticalBlurPostprocess2;
  48477. private _blurTexture1;
  48478. private _blurTexture2;
  48479. private _postProcesses1;
  48480. private _postProcesses2;
  48481. private _includedOnlyMeshes;
  48482. private _excludedMeshes;
  48483. /**
  48484. * Callback used to let the user override the color selection on a per mesh basis
  48485. */
  48486. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48487. /**
  48488. * Callback used to let the user override the texture selection on a per mesh basis
  48489. */
  48490. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48491. /**
  48492. * Instantiates a new glow Layer and references it to the scene.
  48493. * @param name The name of the layer
  48494. * @param scene The scene to use the layer in
  48495. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48496. */
  48497. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48498. /**
  48499. * Get the effect name of the layer.
  48500. * @return The effect name
  48501. */
  48502. getEffectName(): string;
  48503. /**
  48504. * Create the merge effect. This is the shader use to blit the information back
  48505. * to the main canvas at the end of the scene rendering.
  48506. */
  48507. protected _createMergeEffect(): Effect;
  48508. /**
  48509. * Creates the render target textures and post processes used in the glow layer.
  48510. */
  48511. protected _createTextureAndPostProcesses(): void;
  48512. /**
  48513. * Checks for the readiness of the element composing the layer.
  48514. * @param subMesh the mesh to check for
  48515. * @param useInstances specify wether or not to use instances to render the mesh
  48516. * @param emissiveTexture the associated emissive texture used to generate the glow
  48517. * @return true if ready otherwise, false
  48518. */
  48519. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48520. /**
  48521. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48522. */
  48523. needStencil(): boolean;
  48524. /**
  48525. * Returns true if the mesh can be rendered, otherwise false.
  48526. * @param mesh The mesh to render
  48527. * @param material The material used on the mesh
  48528. * @returns true if it can be rendered otherwise false
  48529. */
  48530. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48531. /**
  48532. * Implementation specific of rendering the generating effect on the main canvas.
  48533. * @param effect The effect used to render through
  48534. */
  48535. protected _internalRender(effect: Effect): void;
  48536. /**
  48537. * Sets the required values for both the emissive texture and and the main color.
  48538. */
  48539. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48540. /**
  48541. * Returns true if the mesh should render, otherwise false.
  48542. * @param mesh The mesh to render
  48543. * @returns true if it should render otherwise false
  48544. */
  48545. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48546. /**
  48547. * Adds specific effects defines.
  48548. * @param defines The defines to add specifics to.
  48549. */
  48550. protected _addCustomEffectDefines(defines: string[]): void;
  48551. /**
  48552. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48553. * @param mesh The mesh to exclude from the glow layer
  48554. */
  48555. addExcludedMesh(mesh: Mesh): void;
  48556. /**
  48557. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48558. * @param mesh The mesh to remove
  48559. */
  48560. removeExcludedMesh(mesh: Mesh): void;
  48561. /**
  48562. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48563. * @param mesh The mesh to include in the glow layer
  48564. */
  48565. addIncludedOnlyMesh(mesh: Mesh): void;
  48566. /**
  48567. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48568. * @param mesh The mesh to remove
  48569. */
  48570. removeIncludedOnlyMesh(mesh: Mesh): void;
  48571. /**
  48572. * Determine if a given mesh will be used in the glow layer
  48573. * @param mesh The mesh to test
  48574. * @returns true if the mesh will be highlighted by the current glow layer
  48575. */
  48576. hasMesh(mesh: AbstractMesh): boolean;
  48577. /**
  48578. * Free any resources and references associated to a mesh.
  48579. * Internal use
  48580. * @param mesh The mesh to free.
  48581. * @hidden
  48582. */
  48583. _disposeMesh(mesh: Mesh): void;
  48584. /**
  48585. * Gets the class name of the effect layer
  48586. * @returns the string with the class name of the effect layer
  48587. */
  48588. getClassName(): string;
  48589. /**
  48590. * Serializes this glow layer
  48591. * @returns a serialized glow layer object
  48592. */
  48593. serialize(): any;
  48594. /**
  48595. * Creates a Glow Layer from parsed glow layer data
  48596. * @param parsedGlowLayer defines glow layer data
  48597. * @param scene defines the current scene
  48598. * @param rootUrl defines the root URL containing the glow layer information
  48599. * @returns a parsed Glow Layer
  48600. */
  48601. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48602. }
  48603. }
  48604. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  48605. /** @hidden */
  48606. export var glowBlurPostProcessPixelShader: {
  48607. name: string;
  48608. shader: string;
  48609. };
  48610. }
  48611. declare module "babylonjs/Layers/highlightLayer" {
  48612. import { Observable } from "babylonjs/Misc/observable";
  48613. import { Nullable } from "babylonjs/types";
  48614. import { Camera } from "babylonjs/Cameras/camera";
  48615. import { Scene } from "babylonjs/scene";
  48616. import { Color3, Color4 } from "babylonjs/Maths/math";
  48617. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48619. import { Mesh } from "babylonjs/Meshes/mesh";
  48620. import { Effect } from "babylonjs/Materials/effect";
  48621. import { Material } from "babylonjs/Materials/material";
  48622. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48623. import "babylonjs/Shaders/glowMapMerge.fragment";
  48624. import "babylonjs/Shaders/glowMapMerge.vertex";
  48625. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  48626. module "babylonjs/abstractScene" {
  48627. interface AbstractScene {
  48628. /**
  48629. * Return a the first highlight layer of the scene with a given name.
  48630. * @param name The name of the highlight layer to look for.
  48631. * @return The highlight layer if found otherwise null.
  48632. */
  48633. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48634. }
  48635. }
  48636. /**
  48637. * Highlight layer options. This helps customizing the behaviour
  48638. * of the highlight layer.
  48639. */
  48640. export interface IHighlightLayerOptions {
  48641. /**
  48642. * Multiplication factor apply to the canvas size to compute the render target size
  48643. * used to generated the glowing objects (the smaller the faster).
  48644. */
  48645. mainTextureRatio: number;
  48646. /**
  48647. * Enforces a fixed size texture to ensure resize independant blur.
  48648. */
  48649. mainTextureFixedSize?: number;
  48650. /**
  48651. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48652. * of the picture to blur (the smaller the faster).
  48653. */
  48654. blurTextureSizeRatio: number;
  48655. /**
  48656. * How big in texel of the blur texture is the vertical blur.
  48657. */
  48658. blurVerticalSize: number;
  48659. /**
  48660. * How big in texel of the blur texture is the horizontal blur.
  48661. */
  48662. blurHorizontalSize: number;
  48663. /**
  48664. * Alpha blending mode used to apply the blur. Default is combine.
  48665. */
  48666. alphaBlendingMode: number;
  48667. /**
  48668. * The camera attached to the layer.
  48669. */
  48670. camera: Nullable<Camera>;
  48671. /**
  48672. * Should we display highlight as a solid stroke?
  48673. */
  48674. isStroke?: boolean;
  48675. /**
  48676. * The rendering group to draw the layer in.
  48677. */
  48678. renderingGroupId: number;
  48679. }
  48680. /**
  48681. * The highlight layer Helps adding a glow effect around a mesh.
  48682. *
  48683. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48684. * glowy meshes to your scene.
  48685. *
  48686. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48687. */
  48688. export class HighlightLayer extends EffectLayer {
  48689. name: string;
  48690. /**
  48691. * Effect Name of the highlight layer.
  48692. */
  48693. static readonly EffectName: string;
  48694. /**
  48695. * The neutral color used during the preparation of the glow effect.
  48696. * This is black by default as the blend operation is a blend operation.
  48697. */
  48698. static NeutralColor: Color4;
  48699. /**
  48700. * Stencil value used for glowing meshes.
  48701. */
  48702. static GlowingMeshStencilReference: number;
  48703. /**
  48704. * Stencil value used for the other meshes in the scene.
  48705. */
  48706. static NormalMeshStencilReference: number;
  48707. /**
  48708. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48709. */
  48710. innerGlow: boolean;
  48711. /**
  48712. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48713. */
  48714. outerGlow: boolean;
  48715. /**
  48716. * Specifies the horizontal size of the blur.
  48717. */
  48718. /**
  48719. * Gets the horizontal size of the blur.
  48720. */
  48721. blurHorizontalSize: number;
  48722. /**
  48723. * Specifies the vertical size of the blur.
  48724. */
  48725. /**
  48726. * Gets the vertical size of the blur.
  48727. */
  48728. blurVerticalSize: number;
  48729. /**
  48730. * An event triggered when the highlight layer is being blurred.
  48731. */
  48732. onBeforeBlurObservable: Observable<HighlightLayer>;
  48733. /**
  48734. * An event triggered when the highlight layer has been blurred.
  48735. */
  48736. onAfterBlurObservable: Observable<HighlightLayer>;
  48737. private _instanceGlowingMeshStencilReference;
  48738. private _options;
  48739. private _downSamplePostprocess;
  48740. private _horizontalBlurPostprocess;
  48741. private _verticalBlurPostprocess;
  48742. private _blurTexture;
  48743. private _meshes;
  48744. private _excludedMeshes;
  48745. /**
  48746. * Instantiates a new highlight Layer and references it to the scene..
  48747. * @param name The name of the layer
  48748. * @param scene The scene to use the layer in
  48749. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48750. */
  48751. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48752. /**
  48753. * Get the effect name of the layer.
  48754. * @return The effect name
  48755. */
  48756. getEffectName(): string;
  48757. /**
  48758. * Create the merge effect. This is the shader use to blit the information back
  48759. * to the main canvas at the end of the scene rendering.
  48760. */
  48761. protected _createMergeEffect(): Effect;
  48762. /**
  48763. * Creates the render target textures and post processes used in the highlight layer.
  48764. */
  48765. protected _createTextureAndPostProcesses(): void;
  48766. /**
  48767. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48768. */
  48769. needStencil(): boolean;
  48770. /**
  48771. * Checks for the readiness of the element composing the layer.
  48772. * @param subMesh the mesh to check for
  48773. * @param useInstances specify wether or not to use instances to render the mesh
  48774. * @param emissiveTexture the associated emissive texture used to generate the glow
  48775. * @return true if ready otherwise, false
  48776. */
  48777. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48778. /**
  48779. * Implementation specific of rendering the generating effect on the main canvas.
  48780. * @param effect The effect used to render through
  48781. */
  48782. protected _internalRender(effect: Effect): void;
  48783. /**
  48784. * Returns true if the layer contains information to display, otherwise false.
  48785. */
  48786. shouldRender(): boolean;
  48787. /**
  48788. * Returns true if the mesh should render, otherwise false.
  48789. * @param mesh The mesh to render
  48790. * @returns true if it should render otherwise false
  48791. */
  48792. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48793. /**
  48794. * Sets the required values for both the emissive texture and and the main color.
  48795. */
  48796. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48797. /**
  48798. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48799. * @param mesh The mesh to exclude from the highlight layer
  48800. */
  48801. addExcludedMesh(mesh: Mesh): void;
  48802. /**
  48803. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48804. * @param mesh The mesh to highlight
  48805. */
  48806. removeExcludedMesh(mesh: Mesh): void;
  48807. /**
  48808. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48809. * @param mesh mesh to test
  48810. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48811. */
  48812. hasMesh(mesh: AbstractMesh): boolean;
  48813. /**
  48814. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48815. * @param mesh The mesh to highlight
  48816. * @param color The color of the highlight
  48817. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48818. */
  48819. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48820. /**
  48821. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48822. * @param mesh The mesh to highlight
  48823. */
  48824. removeMesh(mesh: Mesh): void;
  48825. /**
  48826. * Force the stencil to the normal expected value for none glowing parts
  48827. */
  48828. private _defaultStencilReference;
  48829. /**
  48830. * Free any resources and references associated to a mesh.
  48831. * Internal use
  48832. * @param mesh The mesh to free.
  48833. * @hidden
  48834. */
  48835. _disposeMesh(mesh: Mesh): void;
  48836. /**
  48837. * Dispose the highlight layer and free resources.
  48838. */
  48839. dispose(): void;
  48840. /**
  48841. * Gets the class name of the effect layer
  48842. * @returns the string with the class name of the effect layer
  48843. */
  48844. getClassName(): string;
  48845. /**
  48846. * Serializes this Highlight layer
  48847. * @returns a serialized Highlight layer object
  48848. */
  48849. serialize(): any;
  48850. /**
  48851. * Creates a Highlight layer from parsed Highlight layer data
  48852. * @param parsedHightlightLayer defines the Highlight layer data
  48853. * @param scene defines the current scene
  48854. * @param rootUrl defines the root URL containing the Highlight layer information
  48855. * @returns a parsed Highlight layer
  48856. */
  48857. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48858. }
  48859. }
  48860. declare module "babylonjs/Layers/index" {
  48861. export * from "babylonjs/Layers/effectLayer";
  48862. export * from "babylonjs/Layers/effectLayerSceneComponent";
  48863. export * from "babylonjs/Layers/glowLayer";
  48864. export * from "babylonjs/Layers/highlightLayer";
  48865. export * from "babylonjs/Layers/layer";
  48866. export * from "babylonjs/Layers/layerSceneComponent";
  48867. }
  48868. declare module "babylonjs/Shaders/lensFlare.fragment" {
  48869. /** @hidden */
  48870. export var lensFlarePixelShader: {
  48871. name: string;
  48872. shader: string;
  48873. };
  48874. }
  48875. declare module "babylonjs/Shaders/lensFlare.vertex" {
  48876. /** @hidden */
  48877. export var lensFlareVertexShader: {
  48878. name: string;
  48879. shader: string;
  48880. };
  48881. }
  48882. declare module "babylonjs/LensFlares/lensFlareSystem" {
  48883. import { Scene } from "babylonjs/scene";
  48884. import { Vector3, Viewport } from "babylonjs/Maths/math";
  48885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48886. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  48887. import "babylonjs/Shaders/lensFlare.fragment";
  48888. import "babylonjs/Shaders/lensFlare.vertex";
  48889. /**
  48890. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48891. * It is usually composed of several `lensFlare`.
  48892. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48893. */
  48894. export class LensFlareSystem {
  48895. /**
  48896. * Define the name of the lens flare system
  48897. */
  48898. name: string;
  48899. /**
  48900. * List of lens flares used in this system.
  48901. */
  48902. lensFlares: LensFlare[];
  48903. /**
  48904. * Define a limit from the border the lens flare can be visible.
  48905. */
  48906. borderLimit: number;
  48907. /**
  48908. * Define a viewport border we do not want to see the lens flare in.
  48909. */
  48910. viewportBorder: number;
  48911. /**
  48912. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48913. */
  48914. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48915. /**
  48916. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48917. */
  48918. layerMask: number;
  48919. /**
  48920. * Define the id of the lens flare system in the scene.
  48921. * (equal to name by default)
  48922. */
  48923. id: string;
  48924. private _scene;
  48925. private _emitter;
  48926. private _vertexBuffers;
  48927. private _indexBuffer;
  48928. private _effect;
  48929. private _positionX;
  48930. private _positionY;
  48931. private _isEnabled;
  48932. /** @hidden */
  48933. static _SceneComponentInitialization: (scene: Scene) => void;
  48934. /**
  48935. * Instantiates a lens flare system.
  48936. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48937. * It is usually composed of several `lensFlare`.
  48938. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48939. * @param name Define the name of the lens flare system in the scene
  48940. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48941. * @param scene Define the scene the lens flare system belongs to
  48942. */
  48943. constructor(
  48944. /**
  48945. * Define the name of the lens flare system
  48946. */
  48947. name: string, emitter: any, scene: Scene);
  48948. /**
  48949. * Define if the lens flare system is enabled.
  48950. */
  48951. isEnabled: boolean;
  48952. /**
  48953. * Get the scene the effects belongs to.
  48954. * @returns the scene holding the lens flare system
  48955. */
  48956. getScene(): Scene;
  48957. /**
  48958. * Get the emitter of the lens flare system.
  48959. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48960. * @returns the emitter of the lens flare system
  48961. */
  48962. getEmitter(): any;
  48963. /**
  48964. * Set the emitter of the lens flare system.
  48965. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48966. * @param newEmitter Define the new emitter of the system
  48967. */
  48968. setEmitter(newEmitter: any): void;
  48969. /**
  48970. * Get the lens flare system emitter position.
  48971. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48972. * @returns the position
  48973. */
  48974. getEmitterPosition(): Vector3;
  48975. /**
  48976. * @hidden
  48977. */
  48978. computeEffectivePosition(globalViewport: Viewport): boolean;
  48979. /** @hidden */
  48980. _isVisible(): boolean;
  48981. /**
  48982. * @hidden
  48983. */
  48984. render(): boolean;
  48985. /**
  48986. * Dispose and release the lens flare with its associated resources.
  48987. */
  48988. dispose(): void;
  48989. /**
  48990. * Parse a lens flare system from a JSON repressentation
  48991. * @param parsedLensFlareSystem Define the JSON to parse
  48992. * @param scene Define the scene the parsed system should be instantiated in
  48993. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48994. * @returns the parsed system
  48995. */
  48996. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48997. /**
  48998. * Serialize the current Lens Flare System into a JSON representation.
  48999. * @returns the serialized JSON
  49000. */
  49001. serialize(): any;
  49002. }
  49003. }
  49004. declare module "babylonjs/LensFlares/lensFlare" {
  49005. import { Nullable } from "babylonjs/types";
  49006. import { Color3 } from "babylonjs/Maths/math";
  49007. import { Texture } from "babylonjs/Materials/Textures/texture";
  49008. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49009. /**
  49010. * This represents one of the lens effect in a `lensFlareSystem`.
  49011. * It controls one of the indiviual texture used in the effect.
  49012. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49013. */
  49014. export class LensFlare {
  49015. /**
  49016. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49017. */
  49018. size: number;
  49019. /**
  49020. * 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.
  49021. */
  49022. position: number;
  49023. /**
  49024. * Define the lens color.
  49025. */
  49026. color: Color3;
  49027. /**
  49028. * Define the lens texture.
  49029. */
  49030. texture: Nullable<Texture>;
  49031. /**
  49032. * Define the alpha mode to render this particular lens.
  49033. */
  49034. alphaMode: number;
  49035. private _system;
  49036. /**
  49037. * Creates a new Lens Flare.
  49038. * This represents one of the lens effect in a `lensFlareSystem`.
  49039. * It controls one of the indiviual texture used in the effect.
  49040. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49041. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49042. * @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.
  49043. * @param color Define the lens color
  49044. * @param imgUrl Define the lens texture url
  49045. * @param system Define the `lensFlareSystem` this flare is part of
  49046. * @returns The newly created Lens Flare
  49047. */
  49048. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49049. /**
  49050. * Instantiates a new Lens Flare.
  49051. * This represents one of the lens effect in a `lensFlareSystem`.
  49052. * It controls one of the indiviual texture used in the effect.
  49053. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49054. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49055. * @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.
  49056. * @param color Define the lens color
  49057. * @param imgUrl Define the lens texture url
  49058. * @param system Define the `lensFlareSystem` this flare is part of
  49059. */
  49060. constructor(
  49061. /**
  49062. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49063. */
  49064. size: number,
  49065. /**
  49066. * 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.
  49067. */
  49068. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49069. /**
  49070. * Dispose and release the lens flare with its associated resources.
  49071. */
  49072. dispose(): void;
  49073. }
  49074. }
  49075. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49076. import { Nullable } from "babylonjs/types";
  49077. import { Scene } from "babylonjs/scene";
  49078. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49079. import { AbstractScene } from "babylonjs/abstractScene";
  49080. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49081. module "babylonjs/abstractScene" {
  49082. interface AbstractScene {
  49083. /**
  49084. * The list of lens flare system added to the scene
  49085. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49086. */
  49087. lensFlareSystems: Array<LensFlareSystem>;
  49088. /**
  49089. * Removes the given lens flare system from this scene.
  49090. * @param toRemove The lens flare system to remove
  49091. * @returns The index of the removed lens flare system
  49092. */
  49093. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49094. /**
  49095. * Adds the given lens flare system to this scene
  49096. * @param newLensFlareSystem The lens flare system to add
  49097. */
  49098. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49099. /**
  49100. * Gets a lens flare system using its name
  49101. * @param name defines the name to look for
  49102. * @returns the lens flare system or null if not found
  49103. */
  49104. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49105. /**
  49106. * Gets a lens flare system using its id
  49107. * @param id defines the id to look for
  49108. * @returns the lens flare system or null if not found
  49109. */
  49110. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49111. }
  49112. }
  49113. /**
  49114. * Defines the lens flare scene component responsible to manage any lens flares
  49115. * in a given scene.
  49116. */
  49117. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49118. /**
  49119. * The component name helpfull to identify the component in the list of scene components.
  49120. */
  49121. readonly name: string;
  49122. /**
  49123. * The scene the component belongs to.
  49124. */
  49125. scene: Scene;
  49126. /**
  49127. * Creates a new instance of the component for the given scene
  49128. * @param scene Defines the scene to register the component in
  49129. */
  49130. constructor(scene: Scene);
  49131. /**
  49132. * Registers the component in a given scene
  49133. */
  49134. register(): void;
  49135. /**
  49136. * Rebuilds the elements related to this component in case of
  49137. * context lost for instance.
  49138. */
  49139. rebuild(): void;
  49140. /**
  49141. * Adds all the element from the container to the scene
  49142. * @param container the container holding the elements
  49143. */
  49144. addFromContainer(container: AbstractScene): void;
  49145. /**
  49146. * Removes all the elements in the container from the scene
  49147. * @param container contains the elements to remove
  49148. * @param dispose if the removed element should be disposed (default: false)
  49149. */
  49150. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49151. /**
  49152. * Serializes the component data to the specified json object
  49153. * @param serializationObject The object to serialize to
  49154. */
  49155. serialize(serializationObject: any): void;
  49156. /**
  49157. * Disposes the component and the associated ressources.
  49158. */
  49159. dispose(): void;
  49160. private _draw;
  49161. }
  49162. }
  49163. declare module "babylonjs/LensFlares/index" {
  49164. export * from "babylonjs/LensFlares/lensFlare";
  49165. export * from "babylonjs/LensFlares/lensFlareSystem";
  49166. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49167. }
  49168. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49169. import { Scene } from "babylonjs/scene";
  49170. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49171. import { AbstractScene } from "babylonjs/abstractScene";
  49172. /**
  49173. * Defines the shadow generator component responsible to manage any shadow generators
  49174. * in a given scene.
  49175. */
  49176. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49177. /**
  49178. * The component name helpfull to identify the component in the list of scene components.
  49179. */
  49180. readonly name: string;
  49181. /**
  49182. * The scene the component belongs to.
  49183. */
  49184. scene: Scene;
  49185. /**
  49186. * Creates a new instance of the component for the given scene
  49187. * @param scene Defines the scene to register the component in
  49188. */
  49189. constructor(scene: Scene);
  49190. /**
  49191. * Registers the component in a given scene
  49192. */
  49193. register(): void;
  49194. /**
  49195. * Rebuilds the elements related to this component in case of
  49196. * context lost for instance.
  49197. */
  49198. rebuild(): void;
  49199. /**
  49200. * Serializes the component data to the specified json object
  49201. * @param serializationObject The object to serialize to
  49202. */
  49203. serialize(serializationObject: any): void;
  49204. /**
  49205. * Adds all the element from the container to the scene
  49206. * @param container the container holding the elements
  49207. */
  49208. addFromContainer(container: AbstractScene): void;
  49209. /**
  49210. * Removes all the elements in the container from the scene
  49211. * @param container contains the elements to remove
  49212. * @param dispose if the removed element should be disposed (default: false)
  49213. */
  49214. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49215. /**
  49216. * Rebuilds the elements related to this component in case of
  49217. * context lost for instance.
  49218. */
  49219. dispose(): void;
  49220. private _gatherRenderTargets;
  49221. }
  49222. }
  49223. declare module "babylonjs/Lights/Shadows/index" {
  49224. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49225. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49226. }
  49227. declare module "babylonjs/Lights/pointLight" {
  49228. import { Scene } from "babylonjs/scene";
  49229. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49231. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49232. import { Effect } from "babylonjs/Materials/effect";
  49233. /**
  49234. * A point light is a light defined by an unique point in world space.
  49235. * The light is emitted in every direction from this point.
  49236. * A good example of a point light is a standard light bulb.
  49237. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49238. */
  49239. export class PointLight extends ShadowLight {
  49240. private _shadowAngle;
  49241. /**
  49242. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49243. * This specifies what angle the shadow will use to be created.
  49244. *
  49245. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49246. */
  49247. /**
  49248. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49249. * This specifies what angle the shadow will use to be created.
  49250. *
  49251. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49252. */
  49253. shadowAngle: number;
  49254. /**
  49255. * Gets the direction if it has been set.
  49256. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49257. */
  49258. /**
  49259. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49260. */
  49261. direction: Vector3;
  49262. /**
  49263. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49264. * A PointLight emits the light in every direction.
  49265. * It can cast shadows.
  49266. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49267. * ```javascript
  49268. * var pointLight = new PointLight("pl", camera.position, scene);
  49269. * ```
  49270. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49271. * @param name The light friendly name
  49272. * @param position The position of the point light in the scene
  49273. * @param scene The scene the lights belongs to
  49274. */
  49275. constructor(name: string, position: Vector3, scene: Scene);
  49276. /**
  49277. * Returns the string "PointLight"
  49278. * @returns the class name
  49279. */
  49280. getClassName(): string;
  49281. /**
  49282. * Returns the integer 0.
  49283. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49284. */
  49285. getTypeID(): number;
  49286. /**
  49287. * Specifies wether or not the shadowmap should be a cube texture.
  49288. * @returns true if the shadowmap needs to be a cube texture.
  49289. */
  49290. needCube(): boolean;
  49291. /**
  49292. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49293. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49294. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49295. */
  49296. getShadowDirection(faceIndex?: number): Vector3;
  49297. /**
  49298. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49299. * - fov = PI / 2
  49300. * - aspect ratio : 1.0
  49301. * - z-near and far equal to the active camera minZ and maxZ.
  49302. * Returns the PointLight.
  49303. */
  49304. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49305. protected _buildUniformLayout(): void;
  49306. /**
  49307. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49308. * @param effect The effect to update
  49309. * @param lightIndex The index of the light in the effect to update
  49310. * @returns The point light
  49311. */
  49312. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49313. /**
  49314. * Prepares the list of defines specific to the light type.
  49315. * @param defines the list of defines
  49316. * @param lightIndex defines the index of the light for the effect
  49317. */
  49318. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49319. }
  49320. }
  49321. declare module "babylonjs/Lights/index" {
  49322. export * from "babylonjs/Lights/light";
  49323. export * from "babylonjs/Lights/shadowLight";
  49324. export * from "babylonjs/Lights/Shadows/index";
  49325. export * from "babylonjs/Lights/directionalLight";
  49326. export * from "babylonjs/Lights/hemisphericLight";
  49327. export * from "babylonjs/Lights/pointLight";
  49328. export * from "babylonjs/Lights/spotLight";
  49329. }
  49330. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49331. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49332. /**
  49333. * Header information of HDR texture files.
  49334. */
  49335. export interface HDRInfo {
  49336. /**
  49337. * The height of the texture in pixels.
  49338. */
  49339. height: number;
  49340. /**
  49341. * The width of the texture in pixels.
  49342. */
  49343. width: number;
  49344. /**
  49345. * The index of the beginning of the data in the binary file.
  49346. */
  49347. dataPosition: number;
  49348. }
  49349. /**
  49350. * This groups tools to convert HDR texture to native colors array.
  49351. */
  49352. export class HDRTools {
  49353. private static Ldexp;
  49354. private static Rgbe2float;
  49355. private static readStringLine;
  49356. /**
  49357. * Reads header information from an RGBE texture stored in a native array.
  49358. * More information on this format are available here:
  49359. * https://en.wikipedia.org/wiki/RGBE_image_format
  49360. *
  49361. * @param uint8array The binary file stored in native array.
  49362. * @return The header information.
  49363. */
  49364. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49365. /**
  49366. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49367. * This RGBE texture needs to store the information as a panorama.
  49368. *
  49369. * More information on this format are available here:
  49370. * https://en.wikipedia.org/wiki/RGBE_image_format
  49371. *
  49372. * @param buffer The binary file stored in an array buffer.
  49373. * @param size The expected size of the extracted cubemap.
  49374. * @return The Cube Map information.
  49375. */
  49376. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49377. /**
  49378. * Returns the pixels data extracted from an RGBE texture.
  49379. * This pixels will be stored left to right up to down in the R G B order in one array.
  49380. *
  49381. * More information on this format are available here:
  49382. * https://en.wikipedia.org/wiki/RGBE_image_format
  49383. *
  49384. * @param uint8array The binary file stored in an array buffer.
  49385. * @param hdrInfo The header information of the file.
  49386. * @return The pixels data in RGB right to left up to down order.
  49387. */
  49388. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49389. private static RGBE_ReadPixels_RLE;
  49390. }
  49391. }
  49392. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49393. import { Nullable } from "babylonjs/types";
  49394. import { Scene } from "babylonjs/scene";
  49395. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49396. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49397. /**
  49398. * This represents a texture coming from an HDR input.
  49399. *
  49400. * The only supported format is currently panorama picture stored in RGBE format.
  49401. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49402. */
  49403. export class HDRCubeTexture extends BaseTexture {
  49404. private static _facesMapping;
  49405. private _generateHarmonics;
  49406. private _noMipmap;
  49407. private _textureMatrix;
  49408. private _size;
  49409. private _onLoad;
  49410. private _onError;
  49411. /**
  49412. * The texture URL.
  49413. */
  49414. url: string;
  49415. /**
  49416. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49417. */
  49418. coordinatesMode: number;
  49419. protected _isBlocking: boolean;
  49420. /**
  49421. * Sets wether or not the texture is blocking during loading.
  49422. */
  49423. /**
  49424. * Gets wether or not the texture is blocking during loading.
  49425. */
  49426. isBlocking: boolean;
  49427. protected _rotationY: number;
  49428. /**
  49429. * Sets texture matrix rotation angle around Y axis in radians.
  49430. */
  49431. /**
  49432. * Gets texture matrix rotation angle around Y axis radians.
  49433. */
  49434. rotationY: number;
  49435. /**
  49436. * Gets or sets the center of the bounding box associated with the cube texture
  49437. * It must define where the camera used to render the texture was set
  49438. */
  49439. boundingBoxPosition: Vector3;
  49440. private _boundingBoxSize;
  49441. /**
  49442. * Gets or sets the size of the bounding box associated with the cube texture
  49443. * When defined, the cubemap will switch to local mode
  49444. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49445. * @example https://www.babylonjs-playground.com/#RNASML
  49446. */
  49447. boundingBoxSize: Vector3;
  49448. /**
  49449. * Instantiates an HDRTexture from the following parameters.
  49450. *
  49451. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49452. * @param scene The scene the texture will be used in
  49453. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49454. * @param noMipmap Forces to not generate the mipmap if true
  49455. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49456. * @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)
  49457. * @param reserved Reserved flag for internal use.
  49458. */
  49459. 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>);
  49460. /**
  49461. * Get the current class name of the texture useful for serialization or dynamic coding.
  49462. * @returns "HDRCubeTexture"
  49463. */
  49464. getClassName(): string;
  49465. /**
  49466. * Occurs when the file is raw .hdr file.
  49467. */
  49468. private loadTexture;
  49469. clone(): HDRCubeTexture;
  49470. delayLoad(): void;
  49471. /**
  49472. * Get the texture reflection matrix used to rotate/transform the reflection.
  49473. * @returns the reflection matrix
  49474. */
  49475. getReflectionTextureMatrix(): Matrix;
  49476. /**
  49477. * Set the texture reflection matrix used to rotate/transform the reflection.
  49478. * @param value Define the reflection matrix to set
  49479. */
  49480. setReflectionTextureMatrix(value: Matrix): void;
  49481. /**
  49482. * Parses a JSON representation of an HDR Texture in order to create the texture
  49483. * @param parsedTexture Define the JSON representation
  49484. * @param scene Define the scene the texture should be created in
  49485. * @param rootUrl Define the root url in case we need to load relative dependencies
  49486. * @returns the newly created texture after parsing
  49487. */
  49488. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49489. serialize(): any;
  49490. }
  49491. }
  49492. declare module "babylonjs/Physics/physicsEngine" {
  49493. import { Nullable } from "babylonjs/types";
  49494. import { Vector3 } from "babylonjs/Maths/math";
  49495. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49496. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49497. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49498. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49499. /**
  49500. * Class used to control physics engine
  49501. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49502. */
  49503. export class PhysicsEngine implements IPhysicsEngine {
  49504. private _physicsPlugin;
  49505. /**
  49506. * Global value used to control the smallest number supported by the simulation
  49507. */
  49508. static Epsilon: number;
  49509. private _impostors;
  49510. private _joints;
  49511. /**
  49512. * Gets the gravity vector used by the simulation
  49513. */
  49514. gravity: Vector3;
  49515. /**
  49516. * Factory used to create the default physics plugin.
  49517. * @returns The default physics plugin
  49518. */
  49519. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49520. /**
  49521. * Creates a new Physics Engine
  49522. * @param gravity defines the gravity vector used by the simulation
  49523. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49524. */
  49525. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49526. /**
  49527. * Sets the gravity vector used by the simulation
  49528. * @param gravity defines the gravity vector to use
  49529. */
  49530. setGravity(gravity: Vector3): void;
  49531. /**
  49532. * Set the time step of the physics engine.
  49533. * Default is 1/60.
  49534. * To slow it down, enter 1/600 for example.
  49535. * To speed it up, 1/30
  49536. * @param newTimeStep defines the new timestep to apply to this world.
  49537. */
  49538. setTimeStep(newTimeStep?: number): void;
  49539. /**
  49540. * Get the time step of the physics engine.
  49541. * @returns the current time step
  49542. */
  49543. getTimeStep(): number;
  49544. /**
  49545. * Release all resources
  49546. */
  49547. dispose(): void;
  49548. /**
  49549. * Gets the name of the current physics plugin
  49550. * @returns the name of the plugin
  49551. */
  49552. getPhysicsPluginName(): string;
  49553. /**
  49554. * Adding a new impostor for the impostor tracking.
  49555. * This will be done by the impostor itself.
  49556. * @param impostor the impostor to add
  49557. */
  49558. addImpostor(impostor: PhysicsImpostor): void;
  49559. /**
  49560. * Remove an impostor from the engine.
  49561. * This impostor and its mesh will not longer be updated by the physics engine.
  49562. * @param impostor the impostor to remove
  49563. */
  49564. removeImpostor(impostor: PhysicsImpostor): void;
  49565. /**
  49566. * Add a joint to the physics engine
  49567. * @param mainImpostor defines the main impostor to which the joint is added.
  49568. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49569. * @param joint defines the joint that will connect both impostors.
  49570. */
  49571. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49572. /**
  49573. * Removes a joint from the simulation
  49574. * @param mainImpostor defines the impostor used with the joint
  49575. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49576. * @param joint defines the joint to remove
  49577. */
  49578. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49579. /**
  49580. * Called by the scene. No need to call it.
  49581. * @param delta defines the timespam between frames
  49582. */
  49583. _step(delta: number): void;
  49584. /**
  49585. * Gets the current plugin used to run the simulation
  49586. * @returns current plugin
  49587. */
  49588. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49589. /**
  49590. * Gets the list of physic impostors
  49591. * @returns an array of PhysicsImpostor
  49592. */
  49593. getImpostors(): Array<PhysicsImpostor>;
  49594. /**
  49595. * Gets the impostor for a physics enabled object
  49596. * @param object defines the object impersonated by the impostor
  49597. * @returns the PhysicsImpostor or null if not found
  49598. */
  49599. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49600. /**
  49601. * Gets the impostor for a physics body object
  49602. * @param body defines physics body used by the impostor
  49603. * @returns the PhysicsImpostor or null if not found
  49604. */
  49605. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49606. /**
  49607. * Does a raycast in the physics world
  49608. * @param from when should the ray start?
  49609. * @param to when should the ray end?
  49610. * @returns PhysicsRaycastResult
  49611. */
  49612. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49613. }
  49614. }
  49615. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49616. import { Nullable } from "babylonjs/types";
  49617. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49619. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49620. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49621. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49622. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49623. /** @hidden */
  49624. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49625. private _useDeltaForWorldStep;
  49626. world: any;
  49627. name: string;
  49628. private _physicsMaterials;
  49629. private _fixedTimeStep;
  49630. private _cannonRaycastResult;
  49631. private _raycastResult;
  49632. BJSCANNON: any;
  49633. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49634. setGravity(gravity: Vector3): void;
  49635. setTimeStep(timeStep: number): void;
  49636. getTimeStep(): number;
  49637. executeStep(delta: number): void;
  49638. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49639. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49640. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49641. private _processChildMeshes;
  49642. removePhysicsBody(impostor: PhysicsImpostor): void;
  49643. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49644. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49645. private _addMaterial;
  49646. private _checkWithEpsilon;
  49647. private _createShape;
  49648. private _createHeightmap;
  49649. private _minus90X;
  49650. private _plus90X;
  49651. private _tmpPosition;
  49652. private _tmpDeltaPosition;
  49653. private _tmpUnityRotation;
  49654. private _updatePhysicsBodyTransformation;
  49655. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49656. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49657. isSupported(): boolean;
  49658. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49659. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49660. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49661. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49662. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49663. getBodyMass(impostor: PhysicsImpostor): number;
  49664. getBodyFriction(impostor: PhysicsImpostor): number;
  49665. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49666. getBodyRestitution(impostor: PhysicsImpostor): number;
  49667. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49668. sleepBody(impostor: PhysicsImpostor): void;
  49669. wakeUpBody(impostor: PhysicsImpostor): void;
  49670. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49671. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49672. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49673. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49674. getRadius(impostor: PhysicsImpostor): number;
  49675. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49676. dispose(): void;
  49677. private _extendNamespace;
  49678. /**
  49679. * Does a raycast in the physics world
  49680. * @param from when should the ray start?
  49681. * @param to when should the ray end?
  49682. * @returns PhysicsRaycastResult
  49683. */
  49684. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49685. }
  49686. }
  49687. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49688. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49689. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49690. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49692. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49693. import { Nullable } from "babylonjs/types";
  49694. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49695. /** @hidden */
  49696. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49697. world: any;
  49698. name: string;
  49699. BJSOIMO: any;
  49700. private _raycastResult;
  49701. constructor(iterations?: number, oimoInjection?: any);
  49702. setGravity(gravity: Vector3): void;
  49703. setTimeStep(timeStep: number): void;
  49704. getTimeStep(): number;
  49705. private _tmpImpostorsArray;
  49706. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49707. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49708. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49709. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49710. private _tmpPositionVector;
  49711. removePhysicsBody(impostor: PhysicsImpostor): void;
  49712. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49713. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49714. isSupported(): boolean;
  49715. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49716. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49717. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49718. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49719. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49720. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49721. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49722. getBodyMass(impostor: PhysicsImpostor): number;
  49723. getBodyFriction(impostor: PhysicsImpostor): number;
  49724. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49725. getBodyRestitution(impostor: PhysicsImpostor): number;
  49726. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49727. sleepBody(impostor: PhysicsImpostor): void;
  49728. wakeUpBody(impostor: PhysicsImpostor): void;
  49729. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49730. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49731. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49732. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49733. getRadius(impostor: PhysicsImpostor): number;
  49734. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49735. dispose(): void;
  49736. /**
  49737. * Does a raycast in the physics world
  49738. * @param from when should the ray start?
  49739. * @param to when should the ray end?
  49740. * @returns PhysicsRaycastResult
  49741. */
  49742. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49743. }
  49744. }
  49745. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49746. import { Nullable } from "babylonjs/types";
  49747. import { Scene } from "babylonjs/scene";
  49748. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49749. import { Mesh } from "babylonjs/Meshes/mesh";
  49750. /**
  49751. * Class containing static functions to help procedurally build meshes
  49752. */
  49753. export class RibbonBuilder {
  49754. /**
  49755. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49756. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49757. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49758. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49759. * * 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
  49760. * * 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
  49761. * * 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
  49762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49764. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49765. * * 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
  49766. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49767. * * 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
  49768. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49770. * @param name defines the name of the mesh
  49771. * @param options defines the options used to create the mesh
  49772. * @param scene defines the hosting scene
  49773. * @returns the ribbon mesh
  49774. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49775. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49776. */
  49777. static CreateRibbon(name: string, options: {
  49778. pathArray: Vector3[][];
  49779. closeArray?: boolean;
  49780. closePath?: boolean;
  49781. offset?: number;
  49782. updatable?: boolean;
  49783. sideOrientation?: number;
  49784. frontUVs?: Vector4;
  49785. backUVs?: Vector4;
  49786. instance?: Mesh;
  49787. invertUV?: boolean;
  49788. uvs?: Vector2[];
  49789. colors?: Color4[];
  49790. }, scene?: Nullable<Scene>): Mesh;
  49791. }
  49792. }
  49793. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  49794. import { Nullable } from "babylonjs/types";
  49795. import { Scene } from "babylonjs/scene";
  49796. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49797. import { Mesh } from "babylonjs/Meshes/mesh";
  49798. /**
  49799. * Class containing static functions to help procedurally build meshes
  49800. */
  49801. export class ShapeBuilder {
  49802. /**
  49803. * 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.
  49804. * * 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.
  49805. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49806. * * 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.
  49807. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49808. * * 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
  49809. * * 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
  49810. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49813. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49815. * @param name defines the name of the mesh
  49816. * @param options defines the options used to create the mesh
  49817. * @param scene defines the hosting scene
  49818. * @returns the extruded shape mesh
  49819. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49821. */
  49822. static ExtrudeShape(name: string, options: {
  49823. shape: Vector3[];
  49824. path: Vector3[];
  49825. scale?: number;
  49826. rotation?: number;
  49827. cap?: number;
  49828. updatable?: boolean;
  49829. sideOrientation?: number;
  49830. frontUVs?: Vector4;
  49831. backUVs?: Vector4;
  49832. instance?: Mesh;
  49833. invertUV?: boolean;
  49834. }, scene?: Nullable<Scene>): Mesh;
  49835. /**
  49836. * Creates an custom extruded shape mesh.
  49837. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49838. * * 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.
  49839. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49840. * * 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
  49841. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49842. * * 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
  49843. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49844. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49845. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49846. * * 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
  49847. * * 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
  49848. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49851. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49853. * @param name defines the name of the mesh
  49854. * @param options defines the options used to create the mesh
  49855. * @param scene defines the hosting scene
  49856. * @returns the custom extruded shape mesh
  49857. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49858. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49860. */
  49861. static ExtrudeShapeCustom(name: string, options: {
  49862. shape: Vector3[];
  49863. path: Vector3[];
  49864. scaleFunction?: any;
  49865. rotationFunction?: any;
  49866. ribbonCloseArray?: boolean;
  49867. ribbonClosePath?: boolean;
  49868. cap?: number;
  49869. updatable?: boolean;
  49870. sideOrientation?: number;
  49871. frontUVs?: Vector4;
  49872. backUVs?: Vector4;
  49873. instance?: Mesh;
  49874. invertUV?: boolean;
  49875. }, scene: Scene): Mesh;
  49876. private static _ExtrudeShapeGeneric;
  49877. }
  49878. }
  49879. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  49880. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  49881. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49882. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49883. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49884. import { Nullable } from "babylonjs/types";
  49885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49886. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49887. /**
  49888. * AmmoJS Physics plugin
  49889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49890. * @see https://github.com/kripken/ammo.js/
  49891. */
  49892. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49893. private _useDeltaForWorldStep;
  49894. /**
  49895. * Reference to the Ammo library
  49896. */
  49897. bjsAMMO: any;
  49898. /**
  49899. * Created ammoJS world which physics bodies are added to
  49900. */
  49901. world: any;
  49902. /**
  49903. * Name of the plugin
  49904. */
  49905. name: string;
  49906. private _timeStep;
  49907. private _fixedTimeStep;
  49908. private _maxSteps;
  49909. private _tmpQuaternion;
  49910. private _tmpAmmoTransform;
  49911. private _tmpAmmoQuaternion;
  49912. private _tmpAmmoConcreteContactResultCallback;
  49913. private _collisionConfiguration;
  49914. private _dispatcher;
  49915. private _overlappingPairCache;
  49916. private _solver;
  49917. private _softBodySolver;
  49918. private _tmpAmmoVectorA;
  49919. private _tmpAmmoVectorB;
  49920. private _tmpAmmoVectorC;
  49921. private _tmpAmmoVectorD;
  49922. private _tmpContactCallbackResult;
  49923. private _tmpAmmoVectorRCA;
  49924. private _tmpAmmoVectorRCB;
  49925. private _raycastResult;
  49926. private static readonly DISABLE_COLLISION_FLAG;
  49927. private static readonly KINEMATIC_FLAG;
  49928. private static readonly DISABLE_DEACTIVATION_FLAG;
  49929. /**
  49930. * Initializes the ammoJS plugin
  49931. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49932. * @param ammoInjection can be used to inject your own ammo reference
  49933. */
  49934. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  49935. /**
  49936. * Sets the gravity of the physics world (m/(s^2))
  49937. * @param gravity Gravity to set
  49938. */
  49939. setGravity(gravity: Vector3): void;
  49940. /**
  49941. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49942. * @param timeStep timestep to use in seconds
  49943. */
  49944. setTimeStep(timeStep: number): void;
  49945. /**
  49946. * 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)
  49947. * @param fixedTimeStep fixedTimeStep to use in seconds
  49948. */
  49949. setFixedTimeStep(fixedTimeStep: number): void;
  49950. /**
  49951. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49952. * @param maxSteps the maximum number of steps by the physics engine per frame
  49953. */
  49954. setMaxSteps(maxSteps: number): void;
  49955. /**
  49956. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49957. * @returns the current timestep in seconds
  49958. */
  49959. getTimeStep(): number;
  49960. private _isImpostorInContact;
  49961. private _isImpostorPairInContact;
  49962. private _stepSimulation;
  49963. /**
  49964. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49965. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49966. * After the step the babylon meshes are set to the position of the physics imposters
  49967. * @param delta amount of time to step forward
  49968. * @param impostors array of imposters to update before/after the step
  49969. */
  49970. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49971. /**
  49972. * Update babylon mesh to match physics world object
  49973. * @param impostor imposter to match
  49974. */
  49975. private _afterSoftStep;
  49976. /**
  49977. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49978. * @param impostor imposter to match
  49979. */
  49980. private _ropeStep;
  49981. /**
  49982. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49983. * @param impostor imposter to match
  49984. */
  49985. private _softbodyOrClothStep;
  49986. private _tmpVector;
  49987. private _tmpMatrix;
  49988. /**
  49989. * Applies an impulse on the imposter
  49990. * @param impostor imposter to apply impulse to
  49991. * @param force amount of force to be applied to the imposter
  49992. * @param contactPoint the location to apply the impulse on the imposter
  49993. */
  49994. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49995. /**
  49996. * Applies a force on the imposter
  49997. * @param impostor imposter to apply force
  49998. * @param force amount of force to be applied to the imposter
  49999. * @param contactPoint the location to apply the force on the imposter
  50000. */
  50001. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50002. /**
  50003. * Creates a physics body using the plugin
  50004. * @param impostor the imposter to create the physics body on
  50005. */
  50006. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50007. /**
  50008. * Removes the physics body from the imposter and disposes of the body's memory
  50009. * @param impostor imposter to remove the physics body from
  50010. */
  50011. removePhysicsBody(impostor: PhysicsImpostor): void;
  50012. /**
  50013. * Generates a joint
  50014. * @param impostorJoint the imposter joint to create the joint with
  50015. */
  50016. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50017. /**
  50018. * Removes a joint
  50019. * @param impostorJoint the imposter joint to remove the joint from
  50020. */
  50021. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50022. private _addMeshVerts;
  50023. /**
  50024. * Initialise the soft body vertices to match its object's (mesh) vertices
  50025. * Softbody vertices (nodes) are in world space and to match this
  50026. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50027. * @param impostor to create the softbody for
  50028. */
  50029. private _softVertexData;
  50030. /**
  50031. * Create an impostor's soft body
  50032. * @param impostor to create the softbody for
  50033. */
  50034. private _createSoftbody;
  50035. /**
  50036. * Create cloth for an impostor
  50037. * @param impostor to create the softbody for
  50038. */
  50039. private _createCloth;
  50040. /**
  50041. * Create rope for an impostor
  50042. * @param impostor to create the softbody for
  50043. */
  50044. private _createRope;
  50045. private _addHullVerts;
  50046. private _createShape;
  50047. /**
  50048. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50049. * @param impostor imposter containing the physics body and babylon object
  50050. */
  50051. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50052. /**
  50053. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50054. * @param impostor imposter containing the physics body and babylon object
  50055. * @param newPosition new position
  50056. * @param newRotation new rotation
  50057. */
  50058. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50059. /**
  50060. * If this plugin is supported
  50061. * @returns true if its supported
  50062. */
  50063. isSupported(): boolean;
  50064. /**
  50065. * Sets the linear velocity of the physics body
  50066. * @param impostor imposter to set the velocity on
  50067. * @param velocity velocity to set
  50068. */
  50069. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50070. /**
  50071. * Sets the angular velocity of the physics body
  50072. * @param impostor imposter to set the velocity on
  50073. * @param velocity velocity to set
  50074. */
  50075. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50076. /**
  50077. * gets the linear velocity
  50078. * @param impostor imposter to get linear velocity from
  50079. * @returns linear velocity
  50080. */
  50081. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50082. /**
  50083. * gets the angular velocity
  50084. * @param impostor imposter to get angular velocity from
  50085. * @returns angular velocity
  50086. */
  50087. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50088. /**
  50089. * Sets the mass of physics body
  50090. * @param impostor imposter to set the mass on
  50091. * @param mass mass to set
  50092. */
  50093. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50094. /**
  50095. * Gets the mass of the physics body
  50096. * @param impostor imposter to get the mass from
  50097. * @returns mass
  50098. */
  50099. getBodyMass(impostor: PhysicsImpostor): number;
  50100. /**
  50101. * Gets friction of the impostor
  50102. * @param impostor impostor to get friction from
  50103. * @returns friction value
  50104. */
  50105. getBodyFriction(impostor: PhysicsImpostor): number;
  50106. /**
  50107. * Sets friction of the impostor
  50108. * @param impostor impostor to set friction on
  50109. * @param friction friction value
  50110. */
  50111. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50112. /**
  50113. * Gets restitution of the impostor
  50114. * @param impostor impostor to get restitution from
  50115. * @returns restitution value
  50116. */
  50117. getBodyRestitution(impostor: PhysicsImpostor): number;
  50118. /**
  50119. * Sets resitution of the impostor
  50120. * @param impostor impostor to set resitution on
  50121. * @param restitution resitution value
  50122. */
  50123. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50124. /**
  50125. * Gets pressure inside the impostor
  50126. * @param impostor impostor to get pressure from
  50127. * @returns pressure value
  50128. */
  50129. getBodyPressure(impostor: PhysicsImpostor): number;
  50130. /**
  50131. * Sets pressure inside a soft body impostor
  50132. * Cloth and rope must remain 0 pressure
  50133. * @param impostor impostor to set pressure on
  50134. * @param pressure pressure value
  50135. */
  50136. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50137. /**
  50138. * Gets stiffness of the impostor
  50139. * @param impostor impostor to get stiffness from
  50140. * @returns pressure value
  50141. */
  50142. getBodyStiffness(impostor: PhysicsImpostor): number;
  50143. /**
  50144. * Sets stiffness of the impostor
  50145. * @param impostor impostor to set stiffness on
  50146. * @param stiffness stiffness value from 0 to 1
  50147. */
  50148. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50149. /**
  50150. * Gets velocityIterations of the impostor
  50151. * @param impostor impostor to get velocity iterations from
  50152. * @returns velocityIterations value
  50153. */
  50154. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50155. /**
  50156. * Sets velocityIterations of the impostor
  50157. * @param impostor impostor to set velocity iterations on
  50158. * @param velocityIterations velocityIterations value
  50159. */
  50160. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50161. /**
  50162. * Gets positionIterations of the impostor
  50163. * @param impostor impostor to get position iterations from
  50164. * @returns positionIterations value
  50165. */
  50166. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50167. /**
  50168. * Sets positionIterations of the impostor
  50169. * @param impostor impostor to set position on
  50170. * @param positionIterations positionIterations value
  50171. */
  50172. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50173. /**
  50174. * Append an anchor to a cloth object
  50175. * @param impostor is the cloth impostor to add anchor to
  50176. * @param otherImpostor is the rigid impostor to anchor to
  50177. * @param width ratio across width from 0 to 1
  50178. * @param height ratio up height from 0 to 1
  50179. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50180. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50181. */
  50182. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50183. /**
  50184. * Append an hook to a rope object
  50185. * @param impostor is the rope impostor to add hook to
  50186. * @param otherImpostor is the rigid impostor to hook to
  50187. * @param length ratio along the rope from 0 to 1
  50188. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50189. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50190. */
  50191. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50192. /**
  50193. * Sleeps the physics body and stops it from being active
  50194. * @param impostor impostor to sleep
  50195. */
  50196. sleepBody(impostor: PhysicsImpostor): void;
  50197. /**
  50198. * Activates the physics body
  50199. * @param impostor impostor to activate
  50200. */
  50201. wakeUpBody(impostor: PhysicsImpostor): void;
  50202. /**
  50203. * Updates the distance parameters of the joint
  50204. * @param joint joint to update
  50205. * @param maxDistance maximum distance of the joint
  50206. * @param minDistance minimum distance of the joint
  50207. */
  50208. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50209. /**
  50210. * Sets a motor on the joint
  50211. * @param joint joint to set motor on
  50212. * @param speed speed of the motor
  50213. * @param maxForce maximum force of the motor
  50214. * @param motorIndex index of the motor
  50215. */
  50216. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50217. /**
  50218. * Sets the motors limit
  50219. * @param joint joint to set limit on
  50220. * @param upperLimit upper limit
  50221. * @param lowerLimit lower limit
  50222. */
  50223. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50224. /**
  50225. * Syncs the position and rotation of a mesh with the impostor
  50226. * @param mesh mesh to sync
  50227. * @param impostor impostor to update the mesh with
  50228. */
  50229. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50230. /**
  50231. * Gets the radius of the impostor
  50232. * @param impostor impostor to get radius from
  50233. * @returns the radius
  50234. */
  50235. getRadius(impostor: PhysicsImpostor): number;
  50236. /**
  50237. * Gets the box size of the impostor
  50238. * @param impostor impostor to get box size from
  50239. * @param result the resulting box size
  50240. */
  50241. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50242. /**
  50243. * Disposes of the impostor
  50244. */
  50245. dispose(): void;
  50246. /**
  50247. * Does a raycast in the physics world
  50248. * @param from when should the ray start?
  50249. * @param to when should the ray end?
  50250. * @returns PhysicsRaycastResult
  50251. */
  50252. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50253. }
  50254. }
  50255. declare module "babylonjs/Probes/reflectionProbe" {
  50256. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50257. import { Vector3 } from "babylonjs/Maths/math";
  50258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50259. import { Nullable } from "babylonjs/types";
  50260. import { Scene } from "babylonjs/scene";
  50261. module "babylonjs/abstractScene" {
  50262. interface AbstractScene {
  50263. /**
  50264. * The list of reflection probes added to the scene
  50265. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50266. */
  50267. reflectionProbes: Array<ReflectionProbe>;
  50268. /**
  50269. * Removes the given reflection probe from this scene.
  50270. * @param toRemove The reflection probe to remove
  50271. * @returns The index of the removed reflection probe
  50272. */
  50273. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50274. /**
  50275. * Adds the given reflection probe to this scene.
  50276. * @param newReflectionProbe The reflection probe to add
  50277. */
  50278. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50279. }
  50280. }
  50281. /**
  50282. * Class used to generate realtime reflection / refraction cube textures
  50283. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50284. */
  50285. export class ReflectionProbe {
  50286. /** defines the name of the probe */
  50287. name: string;
  50288. private _scene;
  50289. private _renderTargetTexture;
  50290. private _projectionMatrix;
  50291. private _viewMatrix;
  50292. private _target;
  50293. private _add;
  50294. private _attachedMesh;
  50295. private _invertYAxis;
  50296. /** Gets or sets probe position (center of the cube map) */
  50297. position: Vector3;
  50298. /**
  50299. * Creates a new reflection probe
  50300. * @param name defines the name of the probe
  50301. * @param size defines the texture resolution (for each face)
  50302. * @param scene defines the hosting scene
  50303. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50304. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50305. */
  50306. constructor(
  50307. /** defines the name of the probe */
  50308. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50309. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50310. samples: number;
  50311. /** Gets or sets the refresh rate to use (on every frame by default) */
  50312. refreshRate: number;
  50313. /**
  50314. * Gets the hosting scene
  50315. * @returns a Scene
  50316. */
  50317. getScene(): Scene;
  50318. /** Gets the internal CubeTexture used to render to */
  50319. readonly cubeTexture: RenderTargetTexture;
  50320. /** Gets the list of meshes to render */
  50321. readonly renderList: Nullable<AbstractMesh[]>;
  50322. /**
  50323. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50324. * @param mesh defines the mesh to attach to
  50325. */
  50326. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50327. /**
  50328. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50329. * @param renderingGroupId The rendering group id corresponding to its index
  50330. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50331. */
  50332. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50333. /**
  50334. * Clean all associated resources
  50335. */
  50336. dispose(): void;
  50337. /**
  50338. * Converts the reflection probe information to a readable string for debug purpose.
  50339. * @param fullDetails Supports for multiple levels of logging within scene loading
  50340. * @returns the human readable reflection probe info
  50341. */
  50342. toString(fullDetails?: boolean): string;
  50343. /**
  50344. * Get the class name of the relfection probe.
  50345. * @returns "ReflectionProbe"
  50346. */
  50347. getClassName(): string;
  50348. /**
  50349. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50350. * @returns The JSON representation of the texture
  50351. */
  50352. serialize(): any;
  50353. /**
  50354. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50355. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50356. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50357. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50358. * @returns The parsed reflection probe if successful
  50359. */
  50360. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50361. }
  50362. }
  50363. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  50364. /** @hidden */
  50365. export var _BabylonLoaderRegistered: boolean;
  50366. }
  50367. declare module "babylonjs/Loading/Plugins/index" {
  50368. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  50369. }
  50370. declare module "babylonjs/Loading/index" {
  50371. export * from "babylonjs/Loading/loadingScreen";
  50372. export * from "babylonjs/Loading/Plugins/index";
  50373. export * from "babylonjs/Loading/sceneLoader";
  50374. export * from "babylonjs/Loading/sceneLoaderFlags";
  50375. }
  50376. declare module "babylonjs/Materials/Background/index" {
  50377. export * from "babylonjs/Materials/Background/backgroundMaterial";
  50378. }
  50379. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  50380. import { Scene } from "babylonjs/scene";
  50381. import { Color3 } from "babylonjs/Maths/math";
  50382. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50383. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50384. /**
  50385. * The Physically based simple base material of BJS.
  50386. *
  50387. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50388. * It is used as the base class for both the specGloss and metalRough conventions.
  50389. */
  50390. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50391. /**
  50392. * Number of Simultaneous lights allowed on the material.
  50393. */
  50394. maxSimultaneousLights: number;
  50395. /**
  50396. * If sets to true, disables all the lights affecting the material.
  50397. */
  50398. disableLighting: boolean;
  50399. /**
  50400. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50401. */
  50402. environmentTexture: BaseTexture;
  50403. /**
  50404. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50405. */
  50406. invertNormalMapX: boolean;
  50407. /**
  50408. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50409. */
  50410. invertNormalMapY: boolean;
  50411. /**
  50412. * Normal map used in the model.
  50413. */
  50414. normalTexture: BaseTexture;
  50415. /**
  50416. * Emissivie color used to self-illuminate the model.
  50417. */
  50418. emissiveColor: Color3;
  50419. /**
  50420. * Emissivie texture used to self-illuminate the model.
  50421. */
  50422. emissiveTexture: BaseTexture;
  50423. /**
  50424. * Occlusion Channel Strenght.
  50425. */
  50426. occlusionStrength: number;
  50427. /**
  50428. * Occlusion Texture of the material (adding extra occlusion effects).
  50429. */
  50430. occlusionTexture: BaseTexture;
  50431. /**
  50432. * Defines the alpha limits in alpha test mode.
  50433. */
  50434. alphaCutOff: number;
  50435. /**
  50436. * Gets the current double sided mode.
  50437. */
  50438. /**
  50439. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50440. */
  50441. doubleSided: boolean;
  50442. /**
  50443. * Stores the pre-calculated light information of a mesh in a texture.
  50444. */
  50445. lightmapTexture: BaseTexture;
  50446. /**
  50447. * If true, the light map contains occlusion information instead of lighting info.
  50448. */
  50449. useLightmapAsShadowmap: boolean;
  50450. /**
  50451. * Instantiates a new PBRMaterial instance.
  50452. *
  50453. * @param name The material name
  50454. * @param scene The scene the material will be use in.
  50455. */
  50456. constructor(name: string, scene: Scene);
  50457. getClassName(): string;
  50458. }
  50459. }
  50460. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  50461. import { Scene } from "babylonjs/scene";
  50462. import { Color3 } from "babylonjs/Maths/math";
  50463. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50464. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50465. /**
  50466. * The PBR material of BJS following the metal roughness convention.
  50467. *
  50468. * This fits to the PBR convention in the GLTF definition:
  50469. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50470. */
  50471. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50472. /**
  50473. * The base color has two different interpretations depending on the value of metalness.
  50474. * When the material is a metal, the base color is the specific measured reflectance value
  50475. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50476. * of the material.
  50477. */
  50478. baseColor: Color3;
  50479. /**
  50480. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50481. * well as opacity information in the alpha channel.
  50482. */
  50483. baseTexture: BaseTexture;
  50484. /**
  50485. * Specifies the metallic scalar value of the material.
  50486. * Can also be used to scale the metalness values of the metallic texture.
  50487. */
  50488. metallic: number;
  50489. /**
  50490. * Specifies the roughness scalar value of the material.
  50491. * Can also be used to scale the roughness values of the metallic texture.
  50492. */
  50493. roughness: number;
  50494. /**
  50495. * Texture containing both the metallic value in the B channel and the
  50496. * roughness value in the G channel to keep better precision.
  50497. */
  50498. metallicRoughnessTexture: BaseTexture;
  50499. /**
  50500. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50501. *
  50502. * @param name The material name
  50503. * @param scene The scene the material will be use in.
  50504. */
  50505. constructor(name: string, scene: Scene);
  50506. /**
  50507. * Return the currrent class name of the material.
  50508. */
  50509. getClassName(): string;
  50510. /**
  50511. * Makes a duplicate of the current material.
  50512. * @param name - name to use for the new material.
  50513. */
  50514. clone(name: string): PBRMetallicRoughnessMaterial;
  50515. /**
  50516. * Serialize the material to a parsable JSON object.
  50517. */
  50518. serialize(): any;
  50519. /**
  50520. * Parses a JSON object correponding to the serialize function.
  50521. */
  50522. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50523. }
  50524. }
  50525. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  50526. import { Scene } from "babylonjs/scene";
  50527. import { Color3 } from "babylonjs/Maths/math";
  50528. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50529. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50530. /**
  50531. * The PBR material of BJS following the specular glossiness convention.
  50532. *
  50533. * This fits to the PBR convention in the GLTF definition:
  50534. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50535. */
  50536. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50537. /**
  50538. * Specifies the diffuse color of the material.
  50539. */
  50540. diffuseColor: Color3;
  50541. /**
  50542. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50543. * channel.
  50544. */
  50545. diffuseTexture: BaseTexture;
  50546. /**
  50547. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50548. */
  50549. specularColor: Color3;
  50550. /**
  50551. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50552. */
  50553. glossiness: number;
  50554. /**
  50555. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50556. */
  50557. specularGlossinessTexture: BaseTexture;
  50558. /**
  50559. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50560. *
  50561. * @param name The material name
  50562. * @param scene The scene the material will be use in.
  50563. */
  50564. constructor(name: string, scene: Scene);
  50565. /**
  50566. * Return the currrent class name of the material.
  50567. */
  50568. getClassName(): string;
  50569. /**
  50570. * Makes a duplicate of the current material.
  50571. * @param name - name to use for the new material.
  50572. */
  50573. clone(name: string): PBRSpecularGlossinessMaterial;
  50574. /**
  50575. * Serialize the material to a parsable JSON object.
  50576. */
  50577. serialize(): any;
  50578. /**
  50579. * Parses a JSON object correponding to the serialize function.
  50580. */
  50581. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50582. }
  50583. }
  50584. declare module "babylonjs/Materials/PBR/index" {
  50585. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50586. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50587. export * from "babylonjs/Materials/PBR/pbrMaterial";
  50588. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  50589. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  50590. }
  50591. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  50592. import { Nullable } from "babylonjs/types";
  50593. import { Scene } from "babylonjs/scene";
  50594. import { Matrix } from "babylonjs/Maths/math";
  50595. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50596. /**
  50597. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50598. * It can help converting any input color in a desired output one. This can then be used to create effects
  50599. * from sepia, black and white to sixties or futuristic rendering...
  50600. *
  50601. * The only supported format is currently 3dl.
  50602. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50603. */
  50604. export class ColorGradingTexture extends BaseTexture {
  50605. /**
  50606. * The current texture matrix. (will always be identity in color grading texture)
  50607. */
  50608. private _textureMatrix;
  50609. /**
  50610. * The texture URL.
  50611. */
  50612. url: string;
  50613. /**
  50614. * Empty line regex stored for GC.
  50615. */
  50616. private static _noneEmptyLineRegex;
  50617. private _engine;
  50618. /**
  50619. * Instantiates a ColorGradingTexture from the following parameters.
  50620. *
  50621. * @param url The location of the color gradind data (currently only supporting 3dl)
  50622. * @param scene The scene the texture will be used in
  50623. */
  50624. constructor(url: string, scene: Scene);
  50625. /**
  50626. * Returns the texture matrix used in most of the material.
  50627. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50628. */
  50629. getTextureMatrix(): Matrix;
  50630. /**
  50631. * Occurs when the file being loaded is a .3dl LUT file.
  50632. */
  50633. private load3dlTexture;
  50634. /**
  50635. * Starts the loading process of the texture.
  50636. */
  50637. private loadTexture;
  50638. /**
  50639. * Clones the color gradind texture.
  50640. */
  50641. clone(): ColorGradingTexture;
  50642. /**
  50643. * Called during delayed load for textures.
  50644. */
  50645. delayLoad(): void;
  50646. /**
  50647. * Parses a color grading texture serialized by Babylon.
  50648. * @param parsedTexture The texture information being parsedTexture
  50649. * @param scene The scene to load the texture in
  50650. * @param rootUrl The root url of the data assets to load
  50651. * @return A color gradind texture
  50652. */
  50653. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50654. /**
  50655. * Serializes the LUT texture to json format.
  50656. */
  50657. serialize(): any;
  50658. }
  50659. }
  50660. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  50661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50662. import { Scene } from "babylonjs/scene";
  50663. import { Nullable } from "babylonjs/types";
  50664. /**
  50665. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50666. */
  50667. export class EquiRectangularCubeTexture extends BaseTexture {
  50668. /** The six faces of the cube. */
  50669. private static _FacesMapping;
  50670. private _noMipmap;
  50671. private _onLoad;
  50672. private _onError;
  50673. /** The size of the cubemap. */
  50674. private _size;
  50675. /** The buffer of the image. */
  50676. private _buffer;
  50677. /** The width of the input image. */
  50678. private _width;
  50679. /** The height of the input image. */
  50680. private _height;
  50681. /** The URL to the image. */
  50682. url: string;
  50683. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50684. coordinatesMode: number;
  50685. /**
  50686. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50687. * @param url The location of the image
  50688. * @param scene The scene the texture will be used in
  50689. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50690. * @param noMipmap Forces to not generate the mipmap if true
  50691. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50692. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50693. * @param onLoad — defines a callback called when texture is loaded
  50694. * @param onError — defines a callback called if there is an error
  50695. */
  50696. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50697. /**
  50698. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50699. */
  50700. private loadImage;
  50701. /**
  50702. * Convert the image buffer into a cubemap and create a CubeTexture.
  50703. */
  50704. private loadTexture;
  50705. /**
  50706. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50707. * @param buffer The ArrayBuffer that should be converted.
  50708. * @returns The buffer as Float32Array.
  50709. */
  50710. private getFloat32ArrayFromArrayBuffer;
  50711. /**
  50712. * Get the current class name of the texture useful for serialization or dynamic coding.
  50713. * @returns "EquiRectangularCubeTexture"
  50714. */
  50715. getClassName(): string;
  50716. /**
  50717. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50718. * @returns A clone of the current EquiRectangularCubeTexture.
  50719. */
  50720. clone(): EquiRectangularCubeTexture;
  50721. }
  50722. }
  50723. declare module "babylonjs/Misc/tga" {
  50724. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50725. /**
  50726. * Based on jsTGALoader - Javascript loader for TGA file
  50727. * By Vincent Thibault
  50728. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50729. */
  50730. export class TGATools {
  50731. private static _TYPE_INDEXED;
  50732. private static _TYPE_RGB;
  50733. private static _TYPE_GREY;
  50734. private static _TYPE_RLE_INDEXED;
  50735. private static _TYPE_RLE_RGB;
  50736. private static _TYPE_RLE_GREY;
  50737. private static _ORIGIN_MASK;
  50738. private static _ORIGIN_SHIFT;
  50739. private static _ORIGIN_BL;
  50740. private static _ORIGIN_BR;
  50741. private static _ORIGIN_UL;
  50742. private static _ORIGIN_UR;
  50743. /**
  50744. * Gets the header of a TGA file
  50745. * @param data defines the TGA data
  50746. * @returns the header
  50747. */
  50748. static GetTGAHeader(data: Uint8Array): any;
  50749. /**
  50750. * Uploads TGA content to a Babylon Texture
  50751. * @hidden
  50752. */
  50753. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50754. /** @hidden */
  50755. 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;
  50756. /** @hidden */
  50757. 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;
  50758. /** @hidden */
  50759. 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;
  50760. /** @hidden */
  50761. 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;
  50762. /** @hidden */
  50763. 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;
  50764. /** @hidden */
  50765. 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;
  50766. }
  50767. }
  50768. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  50769. import { Nullable } from "babylonjs/types";
  50770. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50771. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50772. /**
  50773. * Implementation of the TGA Texture Loader.
  50774. * @hidden
  50775. */
  50776. export class _TGATextureLoader implements IInternalTextureLoader {
  50777. /**
  50778. * Defines wether the loader supports cascade loading the different faces.
  50779. */
  50780. readonly supportCascades: boolean;
  50781. /**
  50782. * This returns if the loader support the current file information.
  50783. * @param extension defines the file extension of the file being loaded
  50784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50785. * @param fallback defines the fallback internal texture if any
  50786. * @param isBase64 defines whether the texture is encoded as a base64
  50787. * @param isBuffer defines whether the texture data are stored as a buffer
  50788. * @returns true if the loader can load the specified file
  50789. */
  50790. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50791. /**
  50792. * Transform the url before loading if required.
  50793. * @param rootUrl the url of the texture
  50794. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50795. * @returns the transformed texture
  50796. */
  50797. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50798. /**
  50799. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50800. * @param rootUrl the url of the texture
  50801. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50802. * @returns the fallback texture
  50803. */
  50804. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50805. /**
  50806. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50807. * @param data contains the texture data
  50808. * @param texture defines the BabylonJS internal texture
  50809. * @param createPolynomials will be true if polynomials have been requested
  50810. * @param onLoad defines the callback to trigger once the texture is ready
  50811. * @param onError defines the callback to trigger in case of error
  50812. */
  50813. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50814. /**
  50815. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50816. * @param data contains the texture data
  50817. * @param texture defines the BabylonJS internal texture
  50818. * @param callback defines the method to call once ready to upload
  50819. */
  50820. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50821. }
  50822. }
  50823. declare module "babylonjs/Materials/Textures/Loaders/index" {
  50824. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50825. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50826. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50827. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  50828. }
  50829. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  50830. import { Scene } from "babylonjs/scene";
  50831. import { Texture } from "babylonjs/Materials/Textures/texture";
  50832. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  50833. /**
  50834. * 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.
  50835. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50836. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50837. */
  50838. export class CustomProceduralTexture extends ProceduralTexture {
  50839. private _animate;
  50840. private _time;
  50841. private _config;
  50842. private _texturePath;
  50843. /**
  50844. * Instantiates a new Custom Procedural Texture.
  50845. * 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.
  50846. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50847. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50848. * @param name Define the name of the texture
  50849. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50850. * @param size Define the size of the texture to create
  50851. * @param scene Define the scene the texture belongs to
  50852. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50853. * @param generateMipMaps Define if the texture should creates mip maps or not
  50854. */
  50855. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50856. private _loadJson;
  50857. /**
  50858. * Is the texture ready to be used ? (rendered at least once)
  50859. * @returns true if ready, otherwise, false.
  50860. */
  50861. isReady(): boolean;
  50862. /**
  50863. * Render the texture to its associated render target.
  50864. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50865. */
  50866. render(useCameraPostProcess?: boolean): void;
  50867. /**
  50868. * Update the list of dependant textures samplers in the shader.
  50869. */
  50870. updateTextures(): void;
  50871. /**
  50872. * Update the uniform values of the procedural texture in the shader.
  50873. */
  50874. updateShaderUniforms(): void;
  50875. /**
  50876. * Define if the texture animates or not.
  50877. */
  50878. animate: boolean;
  50879. }
  50880. }
  50881. declare module "babylonjs/Shaders/noise.fragment" {
  50882. /** @hidden */
  50883. export var noisePixelShader: {
  50884. name: string;
  50885. shader: string;
  50886. };
  50887. }
  50888. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  50889. import { Nullable } from "babylonjs/types";
  50890. import { Scene } from "babylonjs/scene";
  50891. import { Texture } from "babylonjs/Materials/Textures/texture";
  50892. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  50893. import "babylonjs/Shaders/noise.fragment";
  50894. /**
  50895. * Class used to generate noise procedural textures
  50896. */
  50897. export class NoiseProceduralTexture extends ProceduralTexture {
  50898. private _time;
  50899. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50900. brightness: number;
  50901. /** Defines the number of octaves to process */
  50902. octaves: number;
  50903. /** Defines the level of persistence (0.8 by default) */
  50904. persistence: number;
  50905. /** Gets or sets animation speed factor (default is 1) */
  50906. animationSpeedFactor: number;
  50907. /**
  50908. * Creates a new NoiseProceduralTexture
  50909. * @param name defines the name fo the texture
  50910. * @param size defines the size of the texture (default is 256)
  50911. * @param scene defines the hosting scene
  50912. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50913. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50914. */
  50915. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50916. private _updateShaderUniforms;
  50917. protected _getDefines(): string;
  50918. /** Generate the current state of the procedural texture */
  50919. render(useCameraPostProcess?: boolean): void;
  50920. /**
  50921. * Serializes this noise procedural texture
  50922. * @returns a serialized noise procedural texture object
  50923. */
  50924. serialize(): any;
  50925. /**
  50926. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50927. * @param parsedTexture defines parsed texture data
  50928. * @param scene defines the current scene
  50929. * @param rootUrl defines the root URL containing noise procedural texture information
  50930. * @returns a parsed NoiseProceduralTexture
  50931. */
  50932. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50933. }
  50934. }
  50935. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  50936. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  50937. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  50938. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  50939. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  50940. }
  50941. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  50942. import { Nullable } from "babylonjs/types";
  50943. import { Scene } from "babylonjs/scene";
  50944. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50945. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50946. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  50947. /**
  50948. * Raw cube texture where the raw buffers are passed in
  50949. */
  50950. export class RawCubeTexture extends CubeTexture {
  50951. /**
  50952. * Creates a cube texture where the raw buffers are passed in.
  50953. * @param scene defines the scene the texture is attached to
  50954. * @param data defines the array of data to use to create each face
  50955. * @param size defines the size of the textures
  50956. * @param format defines the format of the data
  50957. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50958. * @param generateMipMaps defines if the engine should generate the mip levels
  50959. * @param invertY defines if data must be stored with Y axis inverted
  50960. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50961. * @param compression defines the compression used (null by default)
  50962. */
  50963. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50964. /**
  50965. * Updates the raw cube texture.
  50966. * @param data defines the data to store
  50967. * @param format defines the data format
  50968. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50969. * @param invertY defines if data must be stored with Y axis inverted
  50970. * @param compression defines the compression used (null by default)
  50971. * @param level defines which level of the texture to update
  50972. */
  50973. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50974. /**
  50975. * Updates a raw cube texture with RGBD encoded data.
  50976. * @param data defines the array of data [mipmap][face] to use to create each face
  50977. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50978. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50979. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50980. * @returns a promsie that resolves when the operation is complete
  50981. */
  50982. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50983. /**
  50984. * Clones the raw cube texture.
  50985. * @return a new cube texture
  50986. */
  50987. clone(): CubeTexture;
  50988. /** @hidden */
  50989. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50990. }
  50991. }
  50992. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  50993. import { Scene } from "babylonjs/scene";
  50994. import { Texture } from "babylonjs/Materials/Textures/texture";
  50995. /**
  50996. * Class used to store 3D textures containing user data
  50997. */
  50998. export class RawTexture3D extends Texture {
  50999. /** Gets or sets the texture format to use */
  51000. format: number;
  51001. private _engine;
  51002. /**
  51003. * Create a new RawTexture3D
  51004. * @param data defines the data of the texture
  51005. * @param width defines the width of the texture
  51006. * @param height defines the height of the texture
  51007. * @param depth defines the depth of the texture
  51008. * @param format defines the texture format to use
  51009. * @param scene defines the hosting scene
  51010. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51011. * @param invertY defines if texture must be stored with Y axis inverted
  51012. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51013. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51014. */
  51015. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51016. /** Gets or sets the texture format to use */
  51017. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51018. /**
  51019. * Update the texture with new data
  51020. * @param data defines the data to store in the texture
  51021. */
  51022. update(data: ArrayBufferView): void;
  51023. }
  51024. }
  51025. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51026. import { Scene } from "babylonjs/scene";
  51027. import { Plane } from "babylonjs/Maths/math";
  51028. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51029. /**
  51030. * Creates a refraction texture used by refraction channel of the standard material.
  51031. * It is like a mirror but to see through a material.
  51032. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51033. */
  51034. export class RefractionTexture extends RenderTargetTexture {
  51035. /**
  51036. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51037. * 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.
  51038. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51039. */
  51040. refractionPlane: Plane;
  51041. /**
  51042. * Define how deep under the surface we should see.
  51043. */
  51044. depth: number;
  51045. /**
  51046. * Creates a refraction texture used by refraction channel of the standard material.
  51047. * It is like a mirror but to see through a material.
  51048. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51049. * @param name Define the texture name
  51050. * @param size Define the size of the underlying texture
  51051. * @param scene Define the scene the refraction belongs to
  51052. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51053. */
  51054. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51055. /**
  51056. * Clone the refraction texture.
  51057. * @returns the cloned texture
  51058. */
  51059. clone(): RefractionTexture;
  51060. /**
  51061. * Serialize the texture to a JSON representation you could use in Parse later on
  51062. * @returns the serialized JSON representation
  51063. */
  51064. serialize(): any;
  51065. }
  51066. }
  51067. declare module "babylonjs/Materials/Textures/index" {
  51068. export * from "babylonjs/Materials/Textures/baseTexture";
  51069. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51070. export * from "babylonjs/Materials/Textures/cubeTexture";
  51071. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51072. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51073. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51074. export * from "babylonjs/Materials/Textures/internalTexture";
  51075. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51076. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  51077. export * from "babylonjs/Materials/Textures/Loaders/index";
  51078. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51079. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51080. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51081. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51082. export * from "babylonjs/Materials/Textures/rawTexture";
  51083. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51084. export * from "babylonjs/Materials/Textures/refractionTexture";
  51085. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51086. export * from "babylonjs/Materials/Textures/texture";
  51087. export * from "babylonjs/Materials/Textures/videoTexture";
  51088. }
  51089. declare module "babylonjs/Materials/index" {
  51090. export * from "babylonjs/Materials/Background/index";
  51091. export * from "babylonjs/Materials/colorCurves";
  51092. export * from "babylonjs/Materials/effect";
  51093. export * from "babylonjs/Materials/fresnelParameters";
  51094. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51095. export * from "babylonjs/Materials/material";
  51096. export * from "babylonjs/Materials/materialDefines";
  51097. export * from "babylonjs/Materials/materialHelper";
  51098. export * from "babylonjs/Materials/multiMaterial";
  51099. export * from "babylonjs/Materials/PBR/index";
  51100. export * from "babylonjs/Materials/pushMaterial";
  51101. export * from "babylonjs/Materials/shaderMaterial";
  51102. export * from "babylonjs/Materials/standardMaterial";
  51103. export * from "babylonjs/Materials/Textures/index";
  51104. export * from "babylonjs/Materials/uniformBuffer";
  51105. export * from "babylonjs/Materials/materialFlags";
  51106. }
  51107. declare module "babylonjs/Maths/index" {
  51108. export * from "babylonjs/Maths/math.scalar";
  51109. export * from "babylonjs/Maths/math";
  51110. export * from "babylonjs/Maths/sphericalPolynomial";
  51111. }
  51112. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51113. import { IDisposable } from "babylonjs/scene";
  51114. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51115. /**
  51116. * Configuration for Draco compression
  51117. */
  51118. export interface IDracoCompressionConfiguration {
  51119. /**
  51120. * Configuration for the decoder.
  51121. */
  51122. decoder?: {
  51123. /**
  51124. * The url to the WebAssembly module.
  51125. */
  51126. wasmUrl?: string;
  51127. /**
  51128. * The url to the WebAssembly binary.
  51129. */
  51130. wasmBinaryUrl?: string;
  51131. /**
  51132. * The url to the fallback JavaScript module.
  51133. */
  51134. fallbackUrl?: string;
  51135. };
  51136. }
  51137. /**
  51138. * Draco compression (https://google.github.io/draco/)
  51139. *
  51140. * This class wraps the Draco module.
  51141. *
  51142. * **Encoder**
  51143. *
  51144. * The encoder is not currently implemented.
  51145. *
  51146. * **Decoder**
  51147. *
  51148. * 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.
  51149. *
  51150. * To update the configuration, use the following code:
  51151. * ```javascript
  51152. * DracoCompression.Configuration = {
  51153. * decoder: {
  51154. * wasmUrl: "<url to the WebAssembly library>",
  51155. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51156. * fallbackUrl: "<url to the fallback JavaScript library>",
  51157. * }
  51158. * };
  51159. * ```
  51160. *
  51161. * 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.
  51162. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51163. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51164. *
  51165. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51166. * ```javascript
  51167. * var dracoCompression = new DracoCompression();
  51168. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51169. * [VertexBuffer.PositionKind]: 0
  51170. * });
  51171. * ```
  51172. *
  51173. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51174. */
  51175. export class DracoCompression implements IDisposable {
  51176. private static _DecoderModulePromise;
  51177. /**
  51178. * The configuration. Defaults to the following urls:
  51179. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51180. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51181. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51182. */
  51183. static Configuration: IDracoCompressionConfiguration;
  51184. /**
  51185. * Returns true if the decoder is available.
  51186. */
  51187. static readonly DecoderAvailable: boolean;
  51188. /**
  51189. * Constructor
  51190. */
  51191. constructor();
  51192. /**
  51193. * Stop all async operations and release resources.
  51194. */
  51195. dispose(): void;
  51196. /**
  51197. * Decode Draco compressed mesh data to vertex data.
  51198. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51199. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51200. * @returns A promise that resolves with the decoded vertex data
  51201. */
  51202. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  51203. [kind: string]: number;
  51204. }): Promise<VertexData>;
  51205. private static _GetDecoderModule;
  51206. private static _LoadScriptAsync;
  51207. private static _LoadFileAsync;
  51208. }
  51209. }
  51210. declare module "babylonjs/Meshes/Compression/index" {
  51211. export * from "babylonjs/Meshes/Compression/dracoCompression";
  51212. }
  51213. declare module "babylonjs/Meshes/csg" {
  51214. import { Nullable } from "babylonjs/types";
  51215. import { Scene } from "babylonjs/scene";
  51216. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  51217. import { Mesh } from "babylonjs/Meshes/mesh";
  51218. import { Material } from "babylonjs/Materials/material";
  51219. /**
  51220. * Class for building Constructive Solid Geometry
  51221. */
  51222. export class CSG {
  51223. private polygons;
  51224. /**
  51225. * The world matrix
  51226. */
  51227. matrix: Matrix;
  51228. /**
  51229. * Stores the position
  51230. */
  51231. position: Vector3;
  51232. /**
  51233. * Stores the rotation
  51234. */
  51235. rotation: Vector3;
  51236. /**
  51237. * Stores the rotation quaternion
  51238. */
  51239. rotationQuaternion: Nullable<Quaternion>;
  51240. /**
  51241. * Stores the scaling vector
  51242. */
  51243. scaling: Vector3;
  51244. /**
  51245. * Convert the Mesh to CSG
  51246. * @param mesh The Mesh to convert to CSG
  51247. * @returns A new CSG from the Mesh
  51248. */
  51249. static FromMesh(mesh: Mesh): CSG;
  51250. /**
  51251. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51252. * @param polygons Polygons used to construct a CSG solid
  51253. */
  51254. private static FromPolygons;
  51255. /**
  51256. * Clones, or makes a deep copy, of the CSG
  51257. * @returns A new CSG
  51258. */
  51259. clone(): CSG;
  51260. /**
  51261. * Unions this CSG with another CSG
  51262. * @param csg The CSG to union against this CSG
  51263. * @returns The unioned CSG
  51264. */
  51265. union(csg: CSG): CSG;
  51266. /**
  51267. * Unions this CSG with another CSG in place
  51268. * @param csg The CSG to union against this CSG
  51269. */
  51270. unionInPlace(csg: CSG): void;
  51271. /**
  51272. * Subtracts this CSG with another CSG
  51273. * @param csg The CSG to subtract against this CSG
  51274. * @returns A new CSG
  51275. */
  51276. subtract(csg: CSG): CSG;
  51277. /**
  51278. * Subtracts this CSG with another CSG in place
  51279. * @param csg The CSG to subtact against this CSG
  51280. */
  51281. subtractInPlace(csg: CSG): void;
  51282. /**
  51283. * Intersect this CSG with another CSG
  51284. * @param csg The CSG to intersect against this CSG
  51285. * @returns A new CSG
  51286. */
  51287. intersect(csg: CSG): CSG;
  51288. /**
  51289. * Intersects this CSG with another CSG in place
  51290. * @param csg The CSG to intersect against this CSG
  51291. */
  51292. intersectInPlace(csg: CSG): void;
  51293. /**
  51294. * Return a new CSG solid with solid and empty space switched. This solid is
  51295. * not modified.
  51296. * @returns A new CSG solid with solid and empty space switched
  51297. */
  51298. inverse(): CSG;
  51299. /**
  51300. * Inverses the CSG in place
  51301. */
  51302. inverseInPlace(): void;
  51303. /**
  51304. * This is used to keep meshes transformations so they can be restored
  51305. * when we build back a Babylon Mesh
  51306. * NB : All CSG operations are performed in world coordinates
  51307. * @param csg The CSG to copy the transform attributes from
  51308. * @returns This CSG
  51309. */
  51310. copyTransformAttributes(csg: CSG): CSG;
  51311. /**
  51312. * Build Raw mesh from CSG
  51313. * Coordinates here are in world space
  51314. * @param name The name of the mesh geometry
  51315. * @param scene The Scene
  51316. * @param keepSubMeshes Specifies if the submeshes should be kept
  51317. * @returns A new Mesh
  51318. */
  51319. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51320. /**
  51321. * Build Mesh from CSG taking material and transforms into account
  51322. * @param name The name of the Mesh
  51323. * @param material The material of the Mesh
  51324. * @param scene The Scene
  51325. * @param keepSubMeshes Specifies if submeshes should be kept
  51326. * @returns The new Mesh
  51327. */
  51328. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51329. }
  51330. }
  51331. declare module "babylonjs/Meshes/trailMesh" {
  51332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51333. import { Mesh } from "babylonjs/Meshes/mesh";
  51334. import { Scene } from "babylonjs/scene";
  51335. /**
  51336. * Class used to create a trail following a mesh
  51337. */
  51338. export class TrailMesh extends Mesh {
  51339. private _generator;
  51340. private _autoStart;
  51341. private _running;
  51342. private _diameter;
  51343. private _length;
  51344. private _sectionPolygonPointsCount;
  51345. private _sectionVectors;
  51346. private _sectionNormalVectors;
  51347. private _beforeRenderObserver;
  51348. /**
  51349. * @constructor
  51350. * @param name The value used by scene.getMeshByName() to do a lookup.
  51351. * @param generator The mesh to generate a trail.
  51352. * @param scene The scene to add this mesh to.
  51353. * @param diameter Diameter of trailing mesh. Default is 1.
  51354. * @param length Length of trailing mesh. Default is 60.
  51355. * @param autoStart Automatically start trailing mesh. Default true.
  51356. */
  51357. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51358. /**
  51359. * "TrailMesh"
  51360. * @returns "TrailMesh"
  51361. */
  51362. getClassName(): string;
  51363. private _createMesh;
  51364. /**
  51365. * Start trailing mesh.
  51366. */
  51367. start(): void;
  51368. /**
  51369. * Stop trailing mesh.
  51370. */
  51371. stop(): void;
  51372. /**
  51373. * Update trailing mesh geometry.
  51374. */
  51375. update(): void;
  51376. /**
  51377. * Returns a new TrailMesh object.
  51378. * @param name is a string, the name given to the new mesh
  51379. * @param newGenerator use new generator object for cloned trail mesh
  51380. * @returns a new mesh
  51381. */
  51382. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51383. /**
  51384. * Serializes this trail mesh
  51385. * @param serializationObject object to write serialization to
  51386. */
  51387. serialize(serializationObject: any): void;
  51388. /**
  51389. * Parses a serialized trail mesh
  51390. * @param parsedMesh the serialized mesh
  51391. * @param scene the scene to create the trail mesh in
  51392. * @returns the created trail mesh
  51393. */
  51394. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51395. }
  51396. }
  51397. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  51398. import { Vector4 } from "babylonjs/Maths/math";
  51399. import { Mesh } from "babylonjs/Meshes/mesh";
  51400. /**
  51401. * Class containing static functions to help procedurally build meshes
  51402. */
  51403. export class TorusKnotBuilder {
  51404. /**
  51405. * Creates a torus knot mesh
  51406. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51407. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51408. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51409. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51413. * @param name defines the name of the mesh
  51414. * @param options defines the options used to create the mesh
  51415. * @param scene defines the hosting scene
  51416. * @returns the torus knot mesh
  51417. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51418. */
  51419. static CreateTorusKnot(name: string, options: {
  51420. radius?: number;
  51421. tube?: number;
  51422. radialSegments?: number;
  51423. tubularSegments?: number;
  51424. p?: number;
  51425. q?: number;
  51426. updatable?: boolean;
  51427. sideOrientation?: number;
  51428. frontUVs?: Vector4;
  51429. backUVs?: Vector4;
  51430. }, scene: any): Mesh;
  51431. }
  51432. }
  51433. declare module "babylonjs/Meshes/polygonMesh" {
  51434. import { Scene } from "babylonjs/scene";
  51435. import { Vector2, Path2 } from "babylonjs/Maths/math";
  51436. import { Mesh } from "babylonjs/Meshes/mesh";
  51437. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51438. /**
  51439. * Polygon
  51440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51441. */
  51442. export class Polygon {
  51443. /**
  51444. * Creates a rectangle
  51445. * @param xmin bottom X coord
  51446. * @param ymin bottom Y coord
  51447. * @param xmax top X coord
  51448. * @param ymax top Y coord
  51449. * @returns points that make the resulting rectation
  51450. */
  51451. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51452. /**
  51453. * Creates a circle
  51454. * @param radius radius of circle
  51455. * @param cx scale in x
  51456. * @param cy scale in y
  51457. * @param numberOfSides number of sides that make up the circle
  51458. * @returns points that make the resulting circle
  51459. */
  51460. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51461. /**
  51462. * Creates a polygon from input string
  51463. * @param input Input polygon data
  51464. * @returns the parsed points
  51465. */
  51466. static Parse(input: string): Vector2[];
  51467. /**
  51468. * Starts building a polygon from x and y coordinates
  51469. * @param x x coordinate
  51470. * @param y y coordinate
  51471. * @returns the started path2
  51472. */
  51473. static StartingAt(x: number, y: number): Path2;
  51474. }
  51475. /**
  51476. * Builds a polygon
  51477. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51478. */
  51479. export class PolygonMeshBuilder {
  51480. private _points;
  51481. private _outlinepoints;
  51482. private _holes;
  51483. private _name;
  51484. private _scene;
  51485. private _epoints;
  51486. private _eholes;
  51487. private _addToepoint;
  51488. /**
  51489. * Babylon reference to the earcut plugin.
  51490. */
  51491. bjsEarcut: any;
  51492. /**
  51493. * Creates a PolygonMeshBuilder
  51494. * @param name name of the builder
  51495. * @param contours Path of the polygon
  51496. * @param scene scene to add to when creating the mesh
  51497. * @param earcutInjection can be used to inject your own earcut reference
  51498. */
  51499. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51500. /**
  51501. * Adds a whole within the polygon
  51502. * @param hole Array of points defining the hole
  51503. * @returns this
  51504. */
  51505. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51506. /**
  51507. * Creates the polygon
  51508. * @param updatable If the mesh should be updatable
  51509. * @param depth The depth of the mesh created
  51510. * @returns the created mesh
  51511. */
  51512. build(updatable?: boolean, depth?: number): Mesh;
  51513. /**
  51514. * Creates the polygon
  51515. * @param depth The depth of the mesh created
  51516. * @returns the created VertexData
  51517. */
  51518. buildVertexData(depth?: number): VertexData;
  51519. /**
  51520. * Adds a side to the polygon
  51521. * @param positions points that make the polygon
  51522. * @param normals normals of the polygon
  51523. * @param uvs uvs of the polygon
  51524. * @param indices indices of the polygon
  51525. * @param bounds bounds of the polygon
  51526. * @param points points of the polygon
  51527. * @param depth depth of the polygon
  51528. * @param flip flip of the polygon
  51529. */
  51530. private addSide;
  51531. }
  51532. }
  51533. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  51534. import { Scene } from "babylonjs/scene";
  51535. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  51536. import { Mesh } from "babylonjs/Meshes/mesh";
  51537. /**
  51538. * Class containing static functions to help procedurally build meshes
  51539. */
  51540. export class PolygonBuilder {
  51541. /**
  51542. * Creates a polygon mesh
  51543. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51544. * * 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
  51545. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51548. * * Remember you can only change the shape positions, not their number when updating a polygon
  51549. * @param name defines the name of the mesh
  51550. * @param options defines the options used to create the mesh
  51551. * @param scene defines the hosting scene
  51552. * @param earcutInjection can be used to inject your own earcut reference
  51553. * @returns the polygon mesh
  51554. */
  51555. static CreatePolygon(name: string, options: {
  51556. shape: Vector3[];
  51557. holes?: Vector3[][];
  51558. depth?: number;
  51559. faceUV?: Vector4[];
  51560. faceColors?: Color4[];
  51561. updatable?: boolean;
  51562. sideOrientation?: number;
  51563. frontUVs?: Vector4;
  51564. backUVs?: Vector4;
  51565. }, scene: Scene, earcutInjection?: any): Mesh;
  51566. /**
  51567. * Creates an extruded polygon mesh, with depth in the Y direction.
  51568. * * 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)
  51569. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51570. * @param name defines the name of the mesh
  51571. * @param options defines the options used to create the mesh
  51572. * @param scene defines the hosting scene
  51573. * @param earcutInjection can be used to inject your own earcut reference
  51574. * @returns the polygon mesh
  51575. */
  51576. static ExtrudePolygon(name: string, options: {
  51577. shape: Vector3[];
  51578. holes?: Vector3[][];
  51579. depth?: number;
  51580. faceUV?: Vector4[];
  51581. faceColors?: Color4[];
  51582. updatable?: boolean;
  51583. sideOrientation?: number;
  51584. frontUVs?: Vector4;
  51585. backUVs?: Vector4;
  51586. }, scene: Scene, earcutInjection?: any): Mesh;
  51587. }
  51588. }
  51589. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  51590. import { Scene } from "babylonjs/scene";
  51591. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51592. import { Mesh } from "babylonjs/Meshes/mesh";
  51593. /**
  51594. * Class containing static functions to help procedurally build meshes
  51595. */
  51596. export class LatheBuilder {
  51597. /**
  51598. * Creates lathe mesh.
  51599. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51600. * * 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
  51601. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51602. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51603. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51604. * * 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
  51605. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51606. * * 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
  51607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51609. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51611. * @param name defines the name of the mesh
  51612. * @param options defines the options used to create the mesh
  51613. * @param scene defines the hosting scene
  51614. * @returns the lathe mesh
  51615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51616. */
  51617. static CreateLathe(name: string, options: {
  51618. shape: Vector3[];
  51619. radius?: number;
  51620. tessellation?: number;
  51621. clip?: number;
  51622. arc?: number;
  51623. closed?: boolean;
  51624. updatable?: boolean;
  51625. sideOrientation?: number;
  51626. frontUVs?: Vector4;
  51627. backUVs?: Vector4;
  51628. cap?: number;
  51629. invertUV?: boolean;
  51630. }, scene: Scene): Mesh;
  51631. }
  51632. }
  51633. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  51634. import { Scene } from "babylonjs/scene";
  51635. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51636. import { Mesh } from "babylonjs/Meshes/mesh";
  51637. /**
  51638. * Class containing static functions to help procedurally build meshes
  51639. */
  51640. export class TubeBuilder {
  51641. /**
  51642. * Creates a tube mesh.
  51643. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51644. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51645. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51646. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51647. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51648. * * 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)
  51649. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51650. * * 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
  51651. * * 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
  51652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51653. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51654. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51656. * @param name defines the name of the mesh
  51657. * @param options defines the options used to create the mesh
  51658. * @param scene defines the hosting scene
  51659. * @returns the tube mesh
  51660. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51661. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51662. */
  51663. static CreateTube(name: string, options: {
  51664. path: Vector3[];
  51665. radius?: number;
  51666. tessellation?: number;
  51667. radiusFunction?: {
  51668. (i: number, distance: number): number;
  51669. };
  51670. cap?: number;
  51671. arc?: number;
  51672. updatable?: boolean;
  51673. sideOrientation?: number;
  51674. frontUVs?: Vector4;
  51675. backUVs?: Vector4;
  51676. instance?: Mesh;
  51677. invertUV?: boolean;
  51678. }, scene: Scene): Mesh;
  51679. }
  51680. }
  51681. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  51682. import { Scene } from "babylonjs/scene";
  51683. import { Vector4 } from "babylonjs/Maths/math";
  51684. import { Mesh } from "babylonjs/Meshes/mesh";
  51685. /**
  51686. * Class containing static functions to help procedurally build meshes
  51687. */
  51688. export class IcoSphereBuilder {
  51689. /**
  51690. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51691. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51692. * * 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`)
  51693. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51694. * * 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
  51695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51698. * @param name defines the name of the mesh
  51699. * @param options defines the options used to create the mesh
  51700. * @param scene defines the hosting scene
  51701. * @returns the icosahedron mesh
  51702. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51703. */
  51704. static CreateIcoSphere(name: string, options: {
  51705. radius?: number;
  51706. radiusX?: number;
  51707. radiusY?: number;
  51708. radiusZ?: number;
  51709. flat?: boolean;
  51710. subdivisions?: number;
  51711. sideOrientation?: number;
  51712. frontUVs?: Vector4;
  51713. backUVs?: Vector4;
  51714. updatable?: boolean;
  51715. }, scene: Scene): Mesh;
  51716. }
  51717. }
  51718. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  51719. import { Vector3 } from "babylonjs/Maths/math";
  51720. import { Mesh } from "babylonjs/Meshes/mesh";
  51721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51722. /**
  51723. * Class containing static functions to help procedurally build meshes
  51724. */
  51725. export class DecalBuilder {
  51726. /**
  51727. * Creates a decal mesh.
  51728. * 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
  51729. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51730. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51731. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51732. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51733. * @param name defines the name of the mesh
  51734. * @param sourceMesh defines the mesh where the decal must be applied
  51735. * @param options defines the options used to create the mesh
  51736. * @param scene defines the hosting scene
  51737. * @returns the decal mesh
  51738. * @see https://doc.babylonjs.com/how_to/decals
  51739. */
  51740. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51741. position?: Vector3;
  51742. normal?: Vector3;
  51743. size?: Vector3;
  51744. angle?: number;
  51745. }): Mesh;
  51746. }
  51747. }
  51748. declare module "babylonjs/Meshes/meshBuilder" {
  51749. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  51750. import { Nullable } from "babylonjs/types";
  51751. import { Scene } from "babylonjs/scene";
  51752. import { Mesh } from "babylonjs/Meshes/mesh";
  51753. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51754. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51756. /**
  51757. * Class containing static functions to help procedurally build meshes
  51758. */
  51759. export class MeshBuilder {
  51760. /**
  51761. * Creates a box mesh
  51762. * * The parameter `size` sets the size (float) of each box side (default 1)
  51763. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51764. * * 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)
  51765. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51769. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51770. * @param name defines the name of the mesh
  51771. * @param options defines the options used to create the mesh
  51772. * @param scene defines the hosting scene
  51773. * @returns the box mesh
  51774. */
  51775. static CreateBox(name: string, options: {
  51776. size?: number;
  51777. width?: number;
  51778. height?: number;
  51779. depth?: number;
  51780. faceUV?: Vector4[];
  51781. faceColors?: Color4[];
  51782. sideOrientation?: number;
  51783. frontUVs?: Vector4;
  51784. backUVs?: Vector4;
  51785. updatable?: boolean;
  51786. }, scene?: Nullable<Scene>): Mesh;
  51787. /**
  51788. * Creates a sphere mesh
  51789. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51790. * * 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`)
  51791. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51792. * * 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
  51793. * * 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)
  51794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51797. * @param name defines the name of the mesh
  51798. * @param options defines the options used to create the mesh
  51799. * @param scene defines the hosting scene
  51800. * @returns the sphere mesh
  51801. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51802. */
  51803. static CreateSphere(name: string, options: {
  51804. segments?: number;
  51805. diameter?: number;
  51806. diameterX?: number;
  51807. diameterY?: number;
  51808. diameterZ?: number;
  51809. arc?: number;
  51810. slice?: number;
  51811. sideOrientation?: number;
  51812. frontUVs?: Vector4;
  51813. backUVs?: Vector4;
  51814. updatable?: boolean;
  51815. }, scene: any): Mesh;
  51816. /**
  51817. * Creates a plane polygonal mesh. By default, this is a disc
  51818. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  51819. * * 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
  51820. * * 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
  51821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51824. * @param name defines the name of the mesh
  51825. * @param options defines the options used to create the mesh
  51826. * @param scene defines the hosting scene
  51827. * @returns the plane polygonal mesh
  51828. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  51829. */
  51830. static CreateDisc(name: string, options: {
  51831. radius?: number;
  51832. tessellation?: number;
  51833. arc?: number;
  51834. updatable?: boolean;
  51835. sideOrientation?: number;
  51836. frontUVs?: Vector4;
  51837. backUVs?: Vector4;
  51838. }, scene?: Nullable<Scene>): Mesh;
  51839. /**
  51840. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51841. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51842. * * 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`)
  51843. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51844. * * 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
  51845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51848. * @param name defines the name of the mesh
  51849. * @param options defines the options used to create the mesh
  51850. * @param scene defines the hosting scene
  51851. * @returns the icosahedron mesh
  51852. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51853. */
  51854. static CreateIcoSphere(name: string, options: {
  51855. radius?: number;
  51856. radiusX?: number;
  51857. radiusY?: number;
  51858. radiusZ?: number;
  51859. flat?: boolean;
  51860. subdivisions?: number;
  51861. sideOrientation?: number;
  51862. frontUVs?: Vector4;
  51863. backUVs?: Vector4;
  51864. updatable?: boolean;
  51865. }, scene: Scene): Mesh;
  51866. /**
  51867. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51868. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51869. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51870. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51871. * * 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
  51872. * * 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
  51873. * * 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
  51874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51876. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51877. * * 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
  51878. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51879. * * 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
  51880. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51882. * @param name defines the name of the mesh
  51883. * @param options defines the options used to create the mesh
  51884. * @param scene defines the hosting scene
  51885. * @returns the ribbon mesh
  51886. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51887. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51888. */
  51889. static CreateRibbon(name: string, options: {
  51890. pathArray: Vector3[][];
  51891. closeArray?: boolean;
  51892. closePath?: boolean;
  51893. offset?: number;
  51894. updatable?: boolean;
  51895. sideOrientation?: number;
  51896. frontUVs?: Vector4;
  51897. backUVs?: Vector4;
  51898. instance?: Mesh;
  51899. invertUV?: boolean;
  51900. uvs?: Vector2[];
  51901. colors?: Color4[];
  51902. }, scene?: Nullable<Scene>): Mesh;
  51903. /**
  51904. * Creates a cylinder or a cone mesh
  51905. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51906. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51907. * * 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.
  51908. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51909. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51910. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51911. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51912. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51913. * * 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).
  51914. * * 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
  51915. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51916. * * 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
  51917. * * 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.
  51918. * * If `enclose` is false, a ring surface is one element.
  51919. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51920. * * 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
  51921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51924. * @param name defines the name of the mesh
  51925. * @param options defines the options used to create the mesh
  51926. * @param scene defines the hosting scene
  51927. * @returns the cylinder mesh
  51928. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51929. */
  51930. static CreateCylinder(name: string, options: {
  51931. height?: number;
  51932. diameterTop?: number;
  51933. diameterBottom?: number;
  51934. diameter?: number;
  51935. tessellation?: number;
  51936. subdivisions?: number;
  51937. arc?: number;
  51938. faceColors?: Color4[];
  51939. faceUV?: Vector4[];
  51940. updatable?: boolean;
  51941. hasRings?: boolean;
  51942. enclose?: boolean;
  51943. sideOrientation?: number;
  51944. frontUVs?: Vector4;
  51945. backUVs?: Vector4;
  51946. }, scene: any): Mesh;
  51947. /**
  51948. * Creates a torus mesh
  51949. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51950. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51951. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51955. * @param name defines the name of the mesh
  51956. * @param options defines the options used to create the mesh
  51957. * @param scene defines the hosting scene
  51958. * @returns the torus mesh
  51959. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51960. */
  51961. static CreateTorus(name: string, options: {
  51962. diameter?: number;
  51963. thickness?: number;
  51964. tessellation?: number;
  51965. updatable?: boolean;
  51966. sideOrientation?: number;
  51967. frontUVs?: Vector4;
  51968. backUVs?: Vector4;
  51969. }, scene: any): Mesh;
  51970. /**
  51971. * Creates a torus knot mesh
  51972. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51973. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51974. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51975. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51979. * @param name defines the name of the mesh
  51980. * @param options defines the options used to create the mesh
  51981. * @param scene defines the hosting scene
  51982. * @returns the torus knot mesh
  51983. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51984. */
  51985. static CreateTorusKnot(name: string, options: {
  51986. radius?: number;
  51987. tube?: number;
  51988. radialSegments?: number;
  51989. tubularSegments?: number;
  51990. p?: number;
  51991. q?: number;
  51992. updatable?: boolean;
  51993. sideOrientation?: number;
  51994. frontUVs?: Vector4;
  51995. backUVs?: Vector4;
  51996. }, scene: any): Mesh;
  51997. /**
  51998. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51999. * * 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
  52000. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52001. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52002. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52003. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52004. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52005. * * 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
  52006. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52008. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52009. * @param name defines the name of the new line system
  52010. * @param options defines the options used to create the line system
  52011. * @param scene defines the hosting scene
  52012. * @returns a new line system mesh
  52013. */
  52014. static CreateLineSystem(name: string, options: {
  52015. lines: Vector3[][];
  52016. updatable?: boolean;
  52017. instance?: Nullable<LinesMesh>;
  52018. colors?: Nullable<Color4[][]>;
  52019. useVertexAlpha?: boolean;
  52020. }, scene: Nullable<Scene>): LinesMesh;
  52021. /**
  52022. * Creates a line mesh
  52023. * 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
  52024. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52025. * * The parameter `points` is an array successive Vector3
  52026. * * 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
  52027. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52028. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52029. * * When updating an instance, remember that only point positions can change, not the number of points
  52030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52031. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52032. * @param name defines the name of the new line system
  52033. * @param options defines the options used to create the line system
  52034. * @param scene defines the hosting scene
  52035. * @returns a new line mesh
  52036. */
  52037. static CreateLines(name: string, options: {
  52038. points: Vector3[];
  52039. updatable?: boolean;
  52040. instance?: Nullable<LinesMesh>;
  52041. colors?: Color4[];
  52042. useVertexAlpha?: boolean;
  52043. }, scene?: Nullable<Scene>): LinesMesh;
  52044. /**
  52045. * Creates a dashed line mesh
  52046. * * 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
  52047. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52048. * * The parameter `points` is an array successive Vector3
  52049. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52050. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52051. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52052. * * 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
  52053. * * When updating an instance, remember that only point positions can change, not the number of points
  52054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52055. * @param name defines the name of the mesh
  52056. * @param options defines the options used to create the mesh
  52057. * @param scene defines the hosting scene
  52058. * @returns the dashed line mesh
  52059. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52060. */
  52061. static CreateDashedLines(name: string, options: {
  52062. points: Vector3[];
  52063. dashSize?: number;
  52064. gapSize?: number;
  52065. dashNb?: number;
  52066. updatable?: boolean;
  52067. instance?: LinesMesh;
  52068. }, scene?: Nullable<Scene>): LinesMesh;
  52069. /**
  52070. * 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.
  52071. * * 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.
  52072. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52073. * * 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.
  52074. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52075. * * 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
  52076. * * 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
  52077. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52082. * @param name defines the name of the mesh
  52083. * @param options defines the options used to create the mesh
  52084. * @param scene defines the hosting scene
  52085. * @returns the extruded shape mesh
  52086. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52087. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52088. */
  52089. static ExtrudeShape(name: string, options: {
  52090. shape: Vector3[];
  52091. path: Vector3[];
  52092. scale?: number;
  52093. rotation?: number;
  52094. cap?: number;
  52095. updatable?: boolean;
  52096. sideOrientation?: number;
  52097. frontUVs?: Vector4;
  52098. backUVs?: Vector4;
  52099. instance?: Mesh;
  52100. invertUV?: boolean;
  52101. }, scene?: Nullable<Scene>): Mesh;
  52102. /**
  52103. * Creates an custom extruded shape mesh.
  52104. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52105. * * 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.
  52106. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52107. * * 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
  52108. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52109. * * 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
  52110. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52111. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52112. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52113. * * 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
  52114. * * 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
  52115. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52118. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52120. * @param name defines the name of the mesh
  52121. * @param options defines the options used to create the mesh
  52122. * @param scene defines the hosting scene
  52123. * @returns the custom extruded shape mesh
  52124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52125. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52127. */
  52128. static ExtrudeShapeCustom(name: string, options: {
  52129. shape: Vector3[];
  52130. path: Vector3[];
  52131. scaleFunction?: any;
  52132. rotationFunction?: any;
  52133. ribbonCloseArray?: boolean;
  52134. ribbonClosePath?: boolean;
  52135. cap?: number;
  52136. updatable?: boolean;
  52137. sideOrientation?: number;
  52138. frontUVs?: Vector4;
  52139. backUVs?: Vector4;
  52140. instance?: Mesh;
  52141. invertUV?: boolean;
  52142. }, scene: Scene): Mesh;
  52143. /**
  52144. * Creates lathe mesh.
  52145. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52146. * * 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
  52147. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52148. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52149. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52150. * * 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
  52151. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52152. * * 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
  52153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52155. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52157. * @param name defines the name of the mesh
  52158. * @param options defines the options used to create the mesh
  52159. * @param scene defines the hosting scene
  52160. * @returns the lathe mesh
  52161. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52162. */
  52163. static CreateLathe(name: string, options: {
  52164. shape: Vector3[];
  52165. radius?: number;
  52166. tessellation?: number;
  52167. clip?: number;
  52168. arc?: number;
  52169. closed?: boolean;
  52170. updatable?: boolean;
  52171. sideOrientation?: number;
  52172. frontUVs?: Vector4;
  52173. backUVs?: Vector4;
  52174. cap?: number;
  52175. invertUV?: boolean;
  52176. }, scene: Scene): Mesh;
  52177. /**
  52178. * Creates a plane mesh
  52179. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52180. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52181. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52185. * @param name defines the name of the mesh
  52186. * @param options defines the options used to create the mesh
  52187. * @param scene defines the hosting scene
  52188. * @returns the plane mesh
  52189. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52190. */
  52191. static CreatePlane(name: string, options: {
  52192. size?: number;
  52193. width?: number;
  52194. height?: number;
  52195. sideOrientation?: number;
  52196. frontUVs?: Vector4;
  52197. backUVs?: Vector4;
  52198. updatable?: boolean;
  52199. sourcePlane?: Plane;
  52200. }, scene: Scene): Mesh;
  52201. /**
  52202. * Creates a ground mesh
  52203. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52204. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52206. * @param name defines the name of the mesh
  52207. * @param options defines the options used to create the mesh
  52208. * @param scene defines the hosting scene
  52209. * @returns the ground mesh
  52210. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52211. */
  52212. static CreateGround(name: string, options: {
  52213. width?: number;
  52214. height?: number;
  52215. subdivisions?: number;
  52216. subdivisionsX?: number;
  52217. subdivisionsY?: number;
  52218. updatable?: boolean;
  52219. }, scene: any): Mesh;
  52220. /**
  52221. * Creates a tiled ground mesh
  52222. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52223. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52224. * * 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
  52225. * * 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
  52226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52227. * @param name defines the name of the mesh
  52228. * @param options defines the options used to create the mesh
  52229. * @param scene defines the hosting scene
  52230. * @returns the tiled ground mesh
  52231. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52232. */
  52233. static CreateTiledGround(name: string, options: {
  52234. xmin: number;
  52235. zmin: number;
  52236. xmax: number;
  52237. zmax: number;
  52238. subdivisions?: {
  52239. w: number;
  52240. h: number;
  52241. };
  52242. precision?: {
  52243. w: number;
  52244. h: number;
  52245. };
  52246. updatable?: boolean;
  52247. }, scene: Scene): Mesh;
  52248. /**
  52249. * Creates a ground mesh from a height map
  52250. * * The parameter `url` sets the URL of the height map image resource.
  52251. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52252. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52253. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52254. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52255. * * 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.
  52256. * * 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).
  52257. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52259. * @param name defines the name of the mesh
  52260. * @param url defines the url to the height map
  52261. * @param options defines the options used to create the mesh
  52262. * @param scene defines the hosting scene
  52263. * @returns the ground mesh
  52264. * @see https://doc.babylonjs.com/babylon101/height_map
  52265. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52266. */
  52267. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52268. width?: number;
  52269. height?: number;
  52270. subdivisions?: number;
  52271. minHeight?: number;
  52272. maxHeight?: number;
  52273. colorFilter?: Color3;
  52274. alphaFilter?: number;
  52275. updatable?: boolean;
  52276. onReady?: (mesh: GroundMesh) => void;
  52277. }, scene: Scene): GroundMesh;
  52278. /**
  52279. * Creates a polygon mesh
  52280. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52281. * * 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
  52282. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52285. * * Remember you can only change the shape positions, not their number when updating a polygon
  52286. * @param name defines the name of the mesh
  52287. * @param options defines the options used to create the mesh
  52288. * @param scene defines the hosting scene
  52289. * @param earcutInjection can be used to inject your own earcut reference
  52290. * @returns the polygon mesh
  52291. */
  52292. static CreatePolygon(name: string, options: {
  52293. shape: Vector3[];
  52294. holes?: Vector3[][];
  52295. depth?: number;
  52296. faceUV?: Vector4[];
  52297. faceColors?: Color4[];
  52298. updatable?: boolean;
  52299. sideOrientation?: number;
  52300. frontUVs?: Vector4;
  52301. backUVs?: Vector4;
  52302. }, scene: Scene, earcutInjection?: any): Mesh;
  52303. /**
  52304. * Creates an extruded polygon mesh, with depth in the Y direction.
  52305. * * 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)
  52306. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52307. * @param name defines the name of the mesh
  52308. * @param options defines the options used to create the mesh
  52309. * @param scene defines the hosting scene
  52310. * @param earcutInjection can be used to inject your own earcut reference
  52311. * @returns the polygon mesh
  52312. */
  52313. static ExtrudePolygon(name: string, options: {
  52314. shape: Vector3[];
  52315. holes?: Vector3[][];
  52316. depth?: number;
  52317. faceUV?: Vector4[];
  52318. faceColors?: Color4[];
  52319. updatable?: boolean;
  52320. sideOrientation?: number;
  52321. frontUVs?: Vector4;
  52322. backUVs?: Vector4;
  52323. }, scene: Scene, earcutInjection?: any): Mesh;
  52324. /**
  52325. * Creates a tube mesh.
  52326. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52327. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52328. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52329. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52330. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52331. * * 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)
  52332. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52333. * * 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
  52334. * * 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
  52335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52336. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52337. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52339. * @param name defines the name of the mesh
  52340. * @param options defines the options used to create the mesh
  52341. * @param scene defines the hosting scene
  52342. * @returns the tube mesh
  52343. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52344. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52345. */
  52346. static CreateTube(name: string, options: {
  52347. path: Vector3[];
  52348. radius?: number;
  52349. tessellation?: number;
  52350. radiusFunction?: {
  52351. (i: number, distance: number): number;
  52352. };
  52353. cap?: number;
  52354. arc?: number;
  52355. updatable?: boolean;
  52356. sideOrientation?: number;
  52357. frontUVs?: Vector4;
  52358. backUVs?: Vector4;
  52359. instance?: Mesh;
  52360. invertUV?: boolean;
  52361. }, scene: Scene): Mesh;
  52362. /**
  52363. * Creates a polyhedron mesh
  52364. * * 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
  52365. * * The parameter `size` (positive float, default 1) sets the polygon size
  52366. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52367. * * 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`
  52368. * * 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
  52369. * * 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)`)
  52370. * * 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
  52371. * * 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
  52372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52375. * @param name defines the name of the mesh
  52376. * @param options defines the options used to create the mesh
  52377. * @param scene defines the hosting scene
  52378. * @returns the polyhedron mesh
  52379. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52380. */
  52381. static CreatePolyhedron(name: string, options: {
  52382. type?: number;
  52383. size?: number;
  52384. sizeX?: number;
  52385. sizeY?: number;
  52386. sizeZ?: number;
  52387. custom?: any;
  52388. faceUV?: Vector4[];
  52389. faceColors?: Color4[];
  52390. flat?: boolean;
  52391. updatable?: boolean;
  52392. sideOrientation?: number;
  52393. frontUVs?: Vector4;
  52394. backUVs?: Vector4;
  52395. }, scene: Scene): Mesh;
  52396. /**
  52397. * Creates a decal mesh.
  52398. * 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
  52399. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52400. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52401. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52402. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52403. * @param name defines the name of the mesh
  52404. * @param sourceMesh defines the mesh where the decal must be applied
  52405. * @param options defines the options used to create the mesh
  52406. * @param scene defines the hosting scene
  52407. * @returns the decal mesh
  52408. * @see https://doc.babylonjs.com/how_to/decals
  52409. */
  52410. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52411. position?: Vector3;
  52412. normal?: Vector3;
  52413. size?: Vector3;
  52414. angle?: number;
  52415. }): Mesh;
  52416. }
  52417. }
  52418. declare module "babylonjs/Meshes/meshSimplification" {
  52419. import { Mesh } from "babylonjs/Meshes/mesh";
  52420. /**
  52421. * A simplifier interface for future simplification implementations
  52422. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52423. */
  52424. export interface ISimplifier {
  52425. /**
  52426. * Simplification of a given mesh according to the given settings.
  52427. * Since this requires computation, it is assumed that the function runs async.
  52428. * @param settings The settings of the simplification, including quality and distance
  52429. * @param successCallback A callback that will be called after the mesh was simplified.
  52430. * @param errorCallback in case of an error, this callback will be called. optional.
  52431. */
  52432. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52433. }
  52434. /**
  52435. * Expected simplification settings.
  52436. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52437. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52438. */
  52439. export interface ISimplificationSettings {
  52440. /**
  52441. * Gets or sets the expected quality
  52442. */
  52443. quality: number;
  52444. /**
  52445. * Gets or sets the distance when this optimized version should be used
  52446. */
  52447. distance: number;
  52448. /**
  52449. * Gets an already optimized mesh
  52450. */
  52451. optimizeMesh?: boolean;
  52452. }
  52453. /**
  52454. * Class used to specify simplification options
  52455. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52456. */
  52457. export class SimplificationSettings implements ISimplificationSettings {
  52458. /** expected quality */
  52459. quality: number;
  52460. /** distance when this optimized version should be used */
  52461. distance: number;
  52462. /** already optimized mesh */
  52463. optimizeMesh?: boolean | undefined;
  52464. /**
  52465. * Creates a SimplificationSettings
  52466. * @param quality expected quality
  52467. * @param distance distance when this optimized version should be used
  52468. * @param optimizeMesh already optimized mesh
  52469. */
  52470. constructor(
  52471. /** expected quality */
  52472. quality: number,
  52473. /** distance when this optimized version should be used */
  52474. distance: number,
  52475. /** already optimized mesh */
  52476. optimizeMesh?: boolean | undefined);
  52477. }
  52478. /**
  52479. * Interface used to define a simplification task
  52480. */
  52481. export interface ISimplificationTask {
  52482. /**
  52483. * Array of settings
  52484. */
  52485. settings: Array<ISimplificationSettings>;
  52486. /**
  52487. * Simplification type
  52488. */
  52489. simplificationType: SimplificationType;
  52490. /**
  52491. * Mesh to simplify
  52492. */
  52493. mesh: Mesh;
  52494. /**
  52495. * Callback called on success
  52496. */
  52497. successCallback?: () => void;
  52498. /**
  52499. * Defines if parallel processing can be used
  52500. */
  52501. parallelProcessing: boolean;
  52502. }
  52503. /**
  52504. * Queue used to order the simplification tasks
  52505. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52506. */
  52507. export class SimplificationQueue {
  52508. private _simplificationArray;
  52509. /**
  52510. * Gets a boolean indicating that the process is still running
  52511. */
  52512. running: boolean;
  52513. /**
  52514. * Creates a new queue
  52515. */
  52516. constructor();
  52517. /**
  52518. * Adds a new simplification task
  52519. * @param task defines a task to add
  52520. */
  52521. addTask(task: ISimplificationTask): void;
  52522. /**
  52523. * Execute next task
  52524. */
  52525. executeNext(): void;
  52526. /**
  52527. * Execute a simplification task
  52528. * @param task defines the task to run
  52529. */
  52530. runSimplification(task: ISimplificationTask): void;
  52531. private getSimplifier;
  52532. }
  52533. /**
  52534. * The implemented types of simplification
  52535. * At the moment only Quadratic Error Decimation is implemented
  52536. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52537. */
  52538. export enum SimplificationType {
  52539. /** Quadratic error decimation */
  52540. QUADRATIC = 0
  52541. }
  52542. }
  52543. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  52544. import { Scene } from "babylonjs/scene";
  52545. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  52546. import { ISceneComponent } from "babylonjs/sceneComponent";
  52547. module "babylonjs/scene" {
  52548. interface Scene {
  52549. /** @hidden (Backing field) */
  52550. _simplificationQueue: SimplificationQueue;
  52551. /**
  52552. * Gets or sets the simplification queue attached to the scene
  52553. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52554. */
  52555. simplificationQueue: SimplificationQueue;
  52556. }
  52557. }
  52558. module "babylonjs/Meshes/mesh" {
  52559. interface Mesh {
  52560. /**
  52561. * Simplify the mesh according to the given array of settings.
  52562. * Function will return immediately and will simplify async
  52563. * @param settings a collection of simplification settings
  52564. * @param parallelProcessing should all levels calculate parallel or one after the other
  52565. * @param simplificationType the type of simplification to run
  52566. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52567. * @returns the current mesh
  52568. */
  52569. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52570. }
  52571. }
  52572. /**
  52573. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52574. * created in a scene
  52575. */
  52576. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52577. /**
  52578. * The component name helpfull to identify the component in the list of scene components.
  52579. */
  52580. readonly name: string;
  52581. /**
  52582. * The scene the component belongs to.
  52583. */
  52584. scene: Scene;
  52585. /**
  52586. * Creates a new instance of the component for the given scene
  52587. * @param scene Defines the scene to register the component in
  52588. */
  52589. constructor(scene: Scene);
  52590. /**
  52591. * Registers the component in a given scene
  52592. */
  52593. register(): void;
  52594. /**
  52595. * Rebuilds the elements related to this component in case of
  52596. * context lost for instance.
  52597. */
  52598. rebuild(): void;
  52599. /**
  52600. * Disposes the component and the associated ressources
  52601. */
  52602. dispose(): void;
  52603. private _beforeCameraUpdate;
  52604. }
  52605. }
  52606. declare module "babylonjs/Meshes/Builders/index" {
  52607. export * from "babylonjs/Meshes/Builders/boxBuilder";
  52608. export * from "babylonjs/Meshes/Builders/discBuilder";
  52609. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  52610. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  52611. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  52612. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  52613. export * from "babylonjs/Meshes/Builders/torusBuilder";
  52614. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  52615. export * from "babylonjs/Meshes/Builders/linesBuilder";
  52616. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  52617. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  52618. export * from "babylonjs/Meshes/Builders/latheBuilder";
  52619. export * from "babylonjs/Meshes/Builders/planeBuilder";
  52620. export * from "babylonjs/Meshes/Builders/groundBuilder";
  52621. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  52622. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  52623. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  52624. export * from "babylonjs/Meshes/Builders/decalBuilder";
  52625. }
  52626. declare module "babylonjs/Meshes/index" {
  52627. export * from "babylonjs/Meshes/abstractMesh";
  52628. export * from "babylonjs/Meshes/buffer";
  52629. export * from "babylonjs/Meshes/Compression/index";
  52630. export * from "babylonjs/Meshes/csg";
  52631. export * from "babylonjs/Meshes/geometry";
  52632. export * from "babylonjs/Meshes/groundMesh";
  52633. export * from "babylonjs/Meshes/trailMesh";
  52634. export * from "babylonjs/Meshes/instancedMesh";
  52635. export * from "babylonjs/Meshes/linesMesh";
  52636. export * from "babylonjs/Meshes/mesh";
  52637. export * from "babylonjs/Meshes/mesh.vertexData";
  52638. export * from "babylonjs/Meshes/meshBuilder";
  52639. export * from "babylonjs/Meshes/meshSimplification";
  52640. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  52641. export * from "babylonjs/Meshes/polygonMesh";
  52642. export * from "babylonjs/Meshes/subMesh";
  52643. export * from "babylonjs/Meshes/transformNode";
  52644. export * from "babylonjs/Meshes/Builders/index";
  52645. }
  52646. declare module "babylonjs/Morph/index" {
  52647. export * from "babylonjs/Morph/morphTarget";
  52648. export * from "babylonjs/Morph/morphTargetManager";
  52649. }
  52650. declare module "babylonjs/Offline/database" {
  52651. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  52652. /**
  52653. * Class used to enable access to IndexedDB
  52654. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52655. */
  52656. export class Database implements IOfflineProvider {
  52657. private _callbackManifestChecked;
  52658. private _currentSceneUrl;
  52659. private _db;
  52660. private _enableSceneOffline;
  52661. private _enableTexturesOffline;
  52662. private _manifestVersionFound;
  52663. private _mustUpdateRessources;
  52664. private _hasReachedQuota;
  52665. private _isSupported;
  52666. private _idbFactory;
  52667. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  52668. private static IsUASupportingBlobStorage;
  52669. /**
  52670. * Gets a boolean indicating if Database storate is enabled (off by default)
  52671. */
  52672. static IDBStorageEnabled: boolean;
  52673. /**
  52674. * Gets a boolean indicating if scene must be saved in the database
  52675. */
  52676. readonly enableSceneOffline: boolean;
  52677. /**
  52678. * Gets a boolean indicating if textures must be saved in the database
  52679. */
  52680. readonly enableTexturesOffline: boolean;
  52681. /**
  52682. * Creates a new Database
  52683. * @param urlToScene defines the url to load the scene
  52684. * @param callbackManifestChecked defines the callback to use when manifest is checked
  52685. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  52686. */
  52687. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  52688. private static _ParseURL;
  52689. private static _ReturnFullUrlLocation;
  52690. private _checkManifestFile;
  52691. /**
  52692. * Open the database and make it available
  52693. * @param successCallback defines the callback to call on success
  52694. * @param errorCallback defines the callback to call on error
  52695. */
  52696. open(successCallback: () => void, errorCallback: () => void): void;
  52697. /**
  52698. * Loads an image from the database
  52699. * @param url defines the url to load from
  52700. * @param image defines the target DOM image
  52701. */
  52702. loadImage(url: string, image: HTMLImageElement): void;
  52703. private _loadImageFromDBAsync;
  52704. private _saveImageIntoDBAsync;
  52705. private _checkVersionFromDB;
  52706. private _loadVersionFromDBAsync;
  52707. private _saveVersionIntoDBAsync;
  52708. /**
  52709. * Loads a file from database
  52710. * @param url defines the URL to load from
  52711. * @param sceneLoaded defines a callback to call on success
  52712. * @param progressCallBack defines a callback to call when progress changed
  52713. * @param errorCallback defines a callback to call on error
  52714. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  52715. */
  52716. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  52717. private _loadFileAsync;
  52718. private _saveFileAsync;
  52719. /**
  52720. * Validates if xhr data is correct
  52721. * @param xhr defines the request to validate
  52722. * @param dataType defines the expected data type
  52723. * @returns true if data is correct
  52724. */
  52725. private static _ValidateXHRData;
  52726. }
  52727. }
  52728. declare module "babylonjs/Offline/index" {
  52729. export * from "babylonjs/Offline/database";
  52730. export * from "babylonjs/Offline/IOfflineProvider";
  52731. }
  52732. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  52733. /** @hidden */
  52734. export var gpuUpdateParticlesPixelShader: {
  52735. name: string;
  52736. shader: string;
  52737. };
  52738. }
  52739. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  52740. /** @hidden */
  52741. export var gpuUpdateParticlesVertexShader: {
  52742. name: string;
  52743. shader: string;
  52744. };
  52745. }
  52746. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  52747. /** @hidden */
  52748. export var clipPlaneFragmentDeclaration2: {
  52749. name: string;
  52750. shader: string;
  52751. };
  52752. }
  52753. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  52754. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  52755. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52756. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52757. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52758. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52759. /** @hidden */
  52760. export var gpuRenderParticlesPixelShader: {
  52761. name: string;
  52762. shader: string;
  52763. };
  52764. }
  52765. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  52766. /** @hidden */
  52767. export var clipPlaneVertexDeclaration2: {
  52768. name: string;
  52769. shader: string;
  52770. };
  52771. }
  52772. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  52773. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  52774. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52775. /** @hidden */
  52776. export var gpuRenderParticlesVertexShader: {
  52777. name: string;
  52778. shader: string;
  52779. };
  52780. }
  52781. declare module "babylonjs/Particles/gpuParticleSystem" {
  52782. import { Nullable } from "babylonjs/types";
  52783. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  52784. import { Observable } from "babylonjs/Misc/observable";
  52785. import { Color4, Color3 } from "babylonjs/Maths/math";
  52786. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52787. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  52788. import { Scene, IDisposable } from "babylonjs/scene";
  52789. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  52790. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  52791. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  52792. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  52793. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  52794. /**
  52795. * This represents a GPU particle system in Babylon
  52796. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  52797. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  52798. */
  52799. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  52800. /**
  52801. * The layer mask we are rendering the particles through.
  52802. */
  52803. layerMask: number;
  52804. private _capacity;
  52805. private _activeCount;
  52806. private _currentActiveCount;
  52807. private _accumulatedCount;
  52808. private _renderEffect;
  52809. private _updateEffect;
  52810. private _buffer0;
  52811. private _buffer1;
  52812. private _spriteBuffer;
  52813. private _updateVAO;
  52814. private _renderVAO;
  52815. private _targetIndex;
  52816. private _sourceBuffer;
  52817. private _targetBuffer;
  52818. private _engine;
  52819. private _currentRenderId;
  52820. private _started;
  52821. private _stopped;
  52822. private _timeDelta;
  52823. private _randomTexture;
  52824. private _randomTexture2;
  52825. private _attributesStrideSize;
  52826. private _updateEffectOptions;
  52827. private _randomTextureSize;
  52828. private _actualFrame;
  52829. private readonly _rawTextureWidth;
  52830. /**
  52831. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  52832. */
  52833. static readonly IsSupported: boolean;
  52834. /**
  52835. * An event triggered when the system is disposed.
  52836. */
  52837. onDisposeObservable: Observable<GPUParticleSystem>;
  52838. /**
  52839. * Gets the maximum number of particles active at the same time.
  52840. * @returns The max number of active particles.
  52841. */
  52842. getCapacity(): number;
  52843. /**
  52844. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  52845. * to override the particles.
  52846. */
  52847. forceDepthWrite: boolean;
  52848. /**
  52849. * Gets or set the number of active particles
  52850. */
  52851. activeParticleCount: number;
  52852. private _preWarmDone;
  52853. /**
  52854. * Is this system ready to be used/rendered
  52855. * @return true if the system is ready
  52856. */
  52857. isReady(): boolean;
  52858. /**
  52859. * Gets if the system has been started. (Note: this will still be true after stop is called)
  52860. * @returns True if it has been started, otherwise false.
  52861. */
  52862. isStarted(): boolean;
  52863. /**
  52864. * Starts the particle system and begins to emit
  52865. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  52866. */
  52867. start(delay?: number): void;
  52868. /**
  52869. * Stops the particle system.
  52870. */
  52871. stop(): void;
  52872. /**
  52873. * Remove all active particles
  52874. */
  52875. reset(): void;
  52876. /**
  52877. * Returns the string "GPUParticleSystem"
  52878. * @returns a string containing the class name
  52879. */
  52880. getClassName(): string;
  52881. private _colorGradientsTexture;
  52882. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  52883. /**
  52884. * Adds a new color gradient
  52885. * @param gradient defines the gradient to use (between 0 and 1)
  52886. * @param color1 defines the color to affect to the specified gradient
  52887. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  52888. * @returns the current particle system
  52889. */
  52890. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  52891. /**
  52892. * Remove a specific color gradient
  52893. * @param gradient defines the gradient to remove
  52894. * @returns the current particle system
  52895. */
  52896. removeColorGradient(gradient: number): GPUParticleSystem;
  52897. private _angularSpeedGradientsTexture;
  52898. private _sizeGradientsTexture;
  52899. private _velocityGradientsTexture;
  52900. private _limitVelocityGradientsTexture;
  52901. private _dragGradientsTexture;
  52902. private _addFactorGradient;
  52903. /**
  52904. * Adds a new size gradient
  52905. * @param gradient defines the gradient to use (between 0 and 1)
  52906. * @param factor defines the size factor to affect to the specified gradient
  52907. * @returns the current particle system
  52908. */
  52909. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  52910. /**
  52911. * Remove a specific size gradient
  52912. * @param gradient defines the gradient to remove
  52913. * @returns the current particle system
  52914. */
  52915. removeSizeGradient(gradient: number): GPUParticleSystem;
  52916. /**
  52917. * Adds a new angular speed gradient
  52918. * @param gradient defines the gradient to use (between 0 and 1)
  52919. * @param factor defines the angular speed to affect to the specified gradient
  52920. * @returns the current particle system
  52921. */
  52922. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  52923. /**
  52924. * Remove a specific angular speed gradient
  52925. * @param gradient defines the gradient to remove
  52926. * @returns the current particle system
  52927. */
  52928. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  52929. /**
  52930. * Adds a new velocity gradient
  52931. * @param gradient defines the gradient to use (between 0 and 1)
  52932. * @param factor defines the velocity to affect to the specified gradient
  52933. * @returns the current particle system
  52934. */
  52935. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52936. /**
  52937. * Remove a specific velocity gradient
  52938. * @param gradient defines the gradient to remove
  52939. * @returns the current particle system
  52940. */
  52941. removeVelocityGradient(gradient: number): GPUParticleSystem;
  52942. /**
  52943. * Adds a new limit velocity gradient
  52944. * @param gradient defines the gradient to use (between 0 and 1)
  52945. * @param factor defines the limit velocity value to affect to the specified gradient
  52946. * @returns the current particle system
  52947. */
  52948. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52949. /**
  52950. * Remove a specific limit velocity gradient
  52951. * @param gradient defines the gradient to remove
  52952. * @returns the current particle system
  52953. */
  52954. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  52955. /**
  52956. * Adds a new drag gradient
  52957. * @param gradient defines the gradient to use (between 0 and 1)
  52958. * @param factor defines the drag value to affect to the specified gradient
  52959. * @returns the current particle system
  52960. */
  52961. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  52962. /**
  52963. * Remove a specific drag gradient
  52964. * @param gradient defines the gradient to remove
  52965. * @returns the current particle system
  52966. */
  52967. removeDragGradient(gradient: number): GPUParticleSystem;
  52968. /**
  52969. * Not supported by GPUParticleSystem
  52970. * @param gradient defines the gradient to use (between 0 and 1)
  52971. * @param factor defines the emit rate value to affect to the specified gradient
  52972. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52973. * @returns the current particle system
  52974. */
  52975. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52976. /**
  52977. * Not supported by GPUParticleSystem
  52978. * @param gradient defines the gradient to remove
  52979. * @returns the current particle system
  52980. */
  52981. removeEmitRateGradient(gradient: number): IParticleSystem;
  52982. /**
  52983. * Not supported by GPUParticleSystem
  52984. * @param gradient defines the gradient to use (between 0 and 1)
  52985. * @param factor defines the start size value to affect to the specified gradient
  52986. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52987. * @returns the current particle system
  52988. */
  52989. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52990. /**
  52991. * Not supported by GPUParticleSystem
  52992. * @param gradient defines the gradient to remove
  52993. * @returns the current particle system
  52994. */
  52995. removeStartSizeGradient(gradient: number): IParticleSystem;
  52996. /**
  52997. * Not supported by GPUParticleSystem
  52998. * @param gradient defines the gradient to use (between 0 and 1)
  52999. * @param min defines the color remap minimal range
  53000. * @param max defines the color remap maximal range
  53001. * @returns the current particle system
  53002. */
  53003. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53004. /**
  53005. * Not supported by GPUParticleSystem
  53006. * @param gradient defines the gradient to remove
  53007. * @returns the current particle system
  53008. */
  53009. removeColorRemapGradient(): IParticleSystem;
  53010. /**
  53011. * Not supported by GPUParticleSystem
  53012. * @param gradient defines the gradient to use (between 0 and 1)
  53013. * @param min defines the alpha remap minimal range
  53014. * @param max defines the alpha remap maximal range
  53015. * @returns the current particle system
  53016. */
  53017. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53018. /**
  53019. * Not supported by GPUParticleSystem
  53020. * @param gradient defines the gradient to remove
  53021. * @returns the current particle system
  53022. */
  53023. removeAlphaRemapGradient(): IParticleSystem;
  53024. /**
  53025. * Not supported by GPUParticleSystem
  53026. * @param gradient defines the gradient to use (between 0 and 1)
  53027. * @param color defines the color to affect to the specified gradient
  53028. * @returns the current particle system
  53029. */
  53030. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53031. /**
  53032. * Not supported by GPUParticleSystem
  53033. * @param gradient defines the gradient to remove
  53034. * @returns the current particle system
  53035. */
  53036. removeRampGradient(): IParticleSystem;
  53037. /**
  53038. * Not supported by GPUParticleSystem
  53039. * @returns the list of ramp gradients
  53040. */
  53041. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53042. /**
  53043. * Not supported by GPUParticleSystem
  53044. * Gets or sets a boolean indicating that ramp gradients must be used
  53045. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53046. */
  53047. useRampGradients: boolean;
  53048. /**
  53049. * Not supported by GPUParticleSystem
  53050. * @param gradient defines the gradient to use (between 0 and 1)
  53051. * @param factor defines the life time factor to affect to the specified gradient
  53052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53053. * @returns the current particle system
  53054. */
  53055. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53056. /**
  53057. * Not supported by GPUParticleSystem
  53058. * @param gradient defines the gradient to remove
  53059. * @returns the current particle system
  53060. */
  53061. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53062. /**
  53063. * Instantiates a GPU particle system.
  53064. * 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.
  53065. * @param name The name of the particle system
  53066. * @param options The options used to create the system
  53067. * @param scene The scene the particle system belongs to
  53068. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53069. */
  53070. constructor(name: string, options: Partial<{
  53071. capacity: number;
  53072. randomTextureSize: number;
  53073. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53074. protected _reset(): void;
  53075. private _createUpdateVAO;
  53076. private _createRenderVAO;
  53077. private _initialize;
  53078. /** @hidden */
  53079. _recreateUpdateEffect(): void;
  53080. /** @hidden */
  53081. _recreateRenderEffect(): void;
  53082. /**
  53083. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53084. * @param preWarm defines if we are in the pre-warmimg phase
  53085. */
  53086. animate(preWarm?: boolean): void;
  53087. private _createFactorGradientTexture;
  53088. private _createSizeGradientTexture;
  53089. private _createAngularSpeedGradientTexture;
  53090. private _createVelocityGradientTexture;
  53091. private _createLimitVelocityGradientTexture;
  53092. private _createDragGradientTexture;
  53093. private _createColorGradientTexture;
  53094. /**
  53095. * Renders the particle system in its current state
  53096. * @param preWarm defines if the system should only update the particles but not render them
  53097. * @returns the current number of particles
  53098. */
  53099. render(preWarm?: boolean): number;
  53100. /**
  53101. * Rebuilds the particle system
  53102. */
  53103. rebuild(): void;
  53104. private _releaseBuffers;
  53105. private _releaseVAOs;
  53106. /**
  53107. * Disposes the particle system and free the associated resources
  53108. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53109. */
  53110. dispose(disposeTexture?: boolean): void;
  53111. /**
  53112. * Clones the particle system.
  53113. * @param name The name of the cloned object
  53114. * @param newEmitter The new emitter to use
  53115. * @returns the cloned particle system
  53116. */
  53117. clone(name: string, newEmitter: any): GPUParticleSystem;
  53118. /**
  53119. * Serializes the particle system to a JSON object.
  53120. * @returns the JSON object
  53121. */
  53122. serialize(): any;
  53123. /**
  53124. * Parses a JSON object to create a GPU particle system.
  53125. * @param parsedParticleSystem The JSON object to parse
  53126. * @param scene The scene to create the particle system in
  53127. * @param rootUrl The root url to use to load external dependencies like texture
  53128. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53129. * @returns the parsed GPU particle system
  53130. */
  53131. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53132. }
  53133. }
  53134. declare module "babylonjs/Particles/particleSystemSet" {
  53135. import { Nullable } from "babylonjs/types";
  53136. import { Color3 } from "babylonjs/Maths/math";
  53137. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53139. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53140. import { Scene, IDisposable } from "babylonjs/scene";
  53141. /**
  53142. * Represents a set of particle systems working together to create a specific effect
  53143. */
  53144. export class ParticleSystemSet implements IDisposable {
  53145. private _emitterCreationOptions;
  53146. private _emitterNode;
  53147. /**
  53148. * Gets the particle system list
  53149. */
  53150. systems: IParticleSystem[];
  53151. /**
  53152. * Gets the emitter node used with this set
  53153. */
  53154. readonly emitterNode: Nullable<TransformNode>;
  53155. /**
  53156. * Creates a new emitter mesh as a sphere
  53157. * @param options defines the options used to create the sphere
  53158. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53159. * @param scene defines the hosting scene
  53160. */
  53161. setEmitterAsSphere(options: {
  53162. diameter: number;
  53163. segments: number;
  53164. color: Color3;
  53165. }, renderingGroupId: number, scene: Scene): void;
  53166. /**
  53167. * Starts all particle systems of the set
  53168. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53169. */
  53170. start(emitter?: AbstractMesh): void;
  53171. /**
  53172. * Release all associated resources
  53173. */
  53174. dispose(): void;
  53175. /**
  53176. * Serialize the set into a JSON compatible object
  53177. * @returns a JSON compatible representation of the set
  53178. */
  53179. serialize(): any;
  53180. /**
  53181. * Parse a new ParticleSystemSet from a serialized source
  53182. * @param data defines a JSON compatible representation of the set
  53183. * @param scene defines the hosting scene
  53184. * @param gpu defines if we want GPU particles or CPU particles
  53185. * @returns a new ParticleSystemSet
  53186. */
  53187. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53188. }
  53189. }
  53190. declare module "babylonjs/Particles/particleHelper" {
  53191. import { Nullable } from "babylonjs/types";
  53192. import { Scene } from "babylonjs/scene";
  53193. import { Vector3 } from "babylonjs/Maths/math";
  53194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53195. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53196. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  53197. /**
  53198. * This class is made for on one-liner static method to help creating particle system set.
  53199. */
  53200. export class ParticleHelper {
  53201. /**
  53202. * Gets or sets base Assets URL
  53203. */
  53204. static BaseAssetsUrl: string;
  53205. /**
  53206. * Create a default particle system that you can tweak
  53207. * @param emitter defines the emitter to use
  53208. * @param capacity defines the system capacity (default is 500 particles)
  53209. * @param scene defines the hosting scene
  53210. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53211. * @returns the new Particle system
  53212. */
  53213. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53214. /**
  53215. * This is the main static method (one-liner) of this helper to create different particle systems
  53216. * @param type This string represents the type to the particle system to create
  53217. * @param scene The scene where the particle system should live
  53218. * @param gpu If the system will use gpu
  53219. * @returns the ParticleSystemSet created
  53220. */
  53221. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53222. /**
  53223. * Static function used to export a particle system to a ParticleSystemSet variable.
  53224. * Please note that the emitter shape is not exported
  53225. * @param systems defines the particle systems to export
  53226. * @returns the created particle system set
  53227. */
  53228. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53229. }
  53230. }
  53231. declare module "babylonjs/Particles/particleSystemComponent" {
  53232. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53233. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53234. import "babylonjs/Shaders/particles.vertex";
  53235. module "babylonjs/Engines/engine" {
  53236. interface Engine {
  53237. /**
  53238. * Create an effect to use with particle systems.
  53239. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53240. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53241. * @param uniformsNames defines a list of attribute names
  53242. * @param samplers defines an array of string used to represent textures
  53243. * @param defines defines the string containing the defines to use to compile the shaders
  53244. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53245. * @param onCompiled defines a function to call when the effect creation is successful
  53246. * @param onError defines a function to call when the effect creation has failed
  53247. * @returns the new Effect
  53248. */
  53249. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53250. }
  53251. }
  53252. module "babylonjs/Meshes/mesh" {
  53253. interface Mesh {
  53254. /**
  53255. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53256. * @returns an array of IParticleSystem
  53257. */
  53258. getEmittedParticleSystems(): IParticleSystem[];
  53259. /**
  53260. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53261. * @returns an array of IParticleSystem
  53262. */
  53263. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53264. }
  53265. }
  53266. /**
  53267. * @hidden
  53268. */
  53269. export var _IDoNeedToBeInTheBuild: number;
  53270. }
  53271. declare module "babylonjs/Particles/index" {
  53272. export * from "babylonjs/Particles/baseParticleSystem";
  53273. export * from "babylonjs/Particles/EmitterTypes/index";
  53274. export * from "babylonjs/Particles/gpuParticleSystem";
  53275. export * from "babylonjs/Particles/IParticleSystem";
  53276. export * from "babylonjs/Particles/particle";
  53277. export * from "babylonjs/Particles/particleHelper";
  53278. export * from "babylonjs/Particles/particleSystem";
  53279. export * from "babylonjs/Particles/particleSystemComponent";
  53280. export * from "babylonjs/Particles/particleSystemSet";
  53281. export * from "babylonjs/Particles/solidParticle";
  53282. export * from "babylonjs/Particles/solidParticleSystem";
  53283. export * from "babylonjs/Particles/subEmitter";
  53284. }
  53285. declare module "babylonjs/Physics/physicsEngineComponent" {
  53286. import { Nullable } from "babylonjs/types";
  53287. import { Observable, Observer } from "babylonjs/Misc/observable";
  53288. import { Vector3 } from "babylonjs/Maths/math";
  53289. import { Mesh } from "babylonjs/Meshes/mesh";
  53290. import { ISceneComponent } from "babylonjs/sceneComponent";
  53291. import { Scene } from "babylonjs/scene";
  53292. import { Node } from "babylonjs/node";
  53293. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53294. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53295. module "babylonjs/scene" {
  53296. interface Scene {
  53297. /** @hidden (Backing field) */
  53298. _physicsEngine: Nullable<IPhysicsEngine>;
  53299. /**
  53300. * Gets the current physics engine
  53301. * @returns a IPhysicsEngine or null if none attached
  53302. */
  53303. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53304. /**
  53305. * Enables physics to the current scene
  53306. * @param gravity defines the scene's gravity for the physics engine
  53307. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53308. * @return a boolean indicating if the physics engine was initialized
  53309. */
  53310. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53311. /**
  53312. * Disables and disposes the physics engine associated with the scene
  53313. */
  53314. disablePhysicsEngine(): void;
  53315. /**
  53316. * Gets a boolean indicating if there is an active physics engine
  53317. * @returns a boolean indicating if there is an active physics engine
  53318. */
  53319. isPhysicsEnabled(): boolean;
  53320. /**
  53321. * Deletes a physics compound impostor
  53322. * @param compound defines the compound to delete
  53323. */
  53324. deleteCompoundImpostor(compound: any): void;
  53325. /**
  53326. * An event triggered when physic simulation is about to be run
  53327. */
  53328. onBeforePhysicsObservable: Observable<Scene>;
  53329. /**
  53330. * An event triggered when physic simulation has been done
  53331. */
  53332. onAfterPhysicsObservable: Observable<Scene>;
  53333. }
  53334. }
  53335. module "babylonjs/Meshes/abstractMesh" {
  53336. interface AbstractMesh {
  53337. /** @hidden */
  53338. _physicsImpostor: Nullable<PhysicsImpostor>;
  53339. /**
  53340. * Gets or sets impostor used for physic simulation
  53341. * @see http://doc.babylonjs.com/features/physics_engine
  53342. */
  53343. physicsImpostor: Nullable<PhysicsImpostor>;
  53344. /**
  53345. * Gets the current physics impostor
  53346. * @see http://doc.babylonjs.com/features/physics_engine
  53347. * @returns a physics impostor or null
  53348. */
  53349. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53350. /** Apply a physic impulse to the mesh
  53351. * @param force defines the force to apply
  53352. * @param contactPoint defines where to apply the force
  53353. * @returns the current mesh
  53354. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53355. */
  53356. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53357. /**
  53358. * Creates a physic joint between two meshes
  53359. * @param otherMesh defines the other mesh to use
  53360. * @param pivot1 defines the pivot to use on this mesh
  53361. * @param pivot2 defines the pivot to use on the other mesh
  53362. * @param options defines additional options (can be plugin dependent)
  53363. * @returns the current mesh
  53364. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53365. */
  53366. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53367. /** @hidden */
  53368. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53369. }
  53370. }
  53371. /**
  53372. * Defines the physics engine scene component responsible to manage a physics engine
  53373. */
  53374. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53375. /**
  53376. * The component name helpful to identify the component in the list of scene components.
  53377. */
  53378. readonly name: string;
  53379. /**
  53380. * The scene the component belongs to.
  53381. */
  53382. scene: Scene;
  53383. /**
  53384. * Creates a new instance of the component for the given scene
  53385. * @param scene Defines the scene to register the component in
  53386. */
  53387. constructor(scene: Scene);
  53388. /**
  53389. * Registers the component in a given scene
  53390. */
  53391. register(): void;
  53392. /**
  53393. * Rebuilds the elements related to this component in case of
  53394. * context lost for instance.
  53395. */
  53396. rebuild(): void;
  53397. /**
  53398. * Disposes the component and the associated ressources
  53399. */
  53400. dispose(): void;
  53401. }
  53402. }
  53403. declare module "babylonjs/Physics/physicsHelper" {
  53404. import { Nullable } from "babylonjs/types";
  53405. import { Vector3 } from "babylonjs/Maths/math";
  53406. import { Mesh } from "babylonjs/Meshes/mesh";
  53407. import { Scene } from "babylonjs/scene";
  53408. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53409. /**
  53410. * A helper for physics simulations
  53411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53412. */
  53413. export class PhysicsHelper {
  53414. private _scene;
  53415. private _physicsEngine;
  53416. /**
  53417. * Initializes the Physics helper
  53418. * @param scene Babylon.js scene
  53419. */
  53420. constructor(scene: Scene);
  53421. /**
  53422. * Applies a radial explosion impulse
  53423. * @param origin the origin of the explosion
  53424. * @param radiusOrEventOptions the radius or the options of radial explosion
  53425. * @param strength the explosion strength
  53426. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53427. * @returns A physics radial explosion event, or null
  53428. */
  53429. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53430. /**
  53431. * Applies a radial explosion force
  53432. * @param origin the origin of the explosion
  53433. * @param radiusOrEventOptions the radius or the options of radial explosion
  53434. * @param strength the explosion strength
  53435. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53436. * @returns A physics radial explosion event, or null
  53437. */
  53438. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53439. /**
  53440. * Creates a gravitational field
  53441. * @param origin the origin of the explosion
  53442. * @param radiusOrEventOptions the radius or the options of radial explosion
  53443. * @param strength the explosion strength
  53444. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53445. * @returns A physics gravitational field event, or null
  53446. */
  53447. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53448. /**
  53449. * Creates a physics updraft event
  53450. * @param origin the origin of the updraft
  53451. * @param radiusOrEventOptions the radius or the options of the updraft
  53452. * @param strength the strength of the updraft
  53453. * @param height the height of the updraft
  53454. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53455. * @returns A physics updraft event, or null
  53456. */
  53457. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53458. /**
  53459. * Creates a physics vortex event
  53460. * @param origin the of the vortex
  53461. * @param radiusOrEventOptions the radius or the options of the vortex
  53462. * @param strength the strength of the vortex
  53463. * @param height the height of the vortex
  53464. * @returns a Physics vortex event, or null
  53465. * A physics vortex event or null
  53466. */
  53467. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53468. }
  53469. /**
  53470. * Represents a physics radial explosion event
  53471. */
  53472. class PhysicsRadialExplosionEvent {
  53473. private _scene;
  53474. private _options;
  53475. private _sphere;
  53476. private _dataFetched;
  53477. /**
  53478. * Initializes a radial explosioin event
  53479. * @param _scene BabylonJS scene
  53480. * @param _options The options for the vortex event
  53481. */
  53482. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53483. /**
  53484. * Returns the data related to the radial explosion event (sphere).
  53485. * @returns The radial explosion event data
  53486. */
  53487. getData(): PhysicsRadialExplosionEventData;
  53488. /**
  53489. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53490. * @param impostor A physics imposter
  53491. * @param origin the origin of the explosion
  53492. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53493. */
  53494. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53495. /**
  53496. * Triggers affecterd impostors callbacks
  53497. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53498. */
  53499. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53500. /**
  53501. * Disposes the sphere.
  53502. * @param force Specifies if the sphere should be disposed by force
  53503. */
  53504. dispose(force?: boolean): void;
  53505. /*** Helpers ***/
  53506. private _prepareSphere;
  53507. private _intersectsWithSphere;
  53508. }
  53509. /**
  53510. * Represents a gravitational field event
  53511. */
  53512. class PhysicsGravitationalFieldEvent {
  53513. private _physicsHelper;
  53514. private _scene;
  53515. private _origin;
  53516. private _options;
  53517. private _tickCallback;
  53518. private _sphere;
  53519. private _dataFetched;
  53520. /**
  53521. * Initializes the physics gravitational field event
  53522. * @param _physicsHelper A physics helper
  53523. * @param _scene BabylonJS scene
  53524. * @param _origin The origin position of the gravitational field event
  53525. * @param _options The options for the vortex event
  53526. */
  53527. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53528. /**
  53529. * Returns the data related to the gravitational field event (sphere).
  53530. * @returns A gravitational field event
  53531. */
  53532. getData(): PhysicsGravitationalFieldEventData;
  53533. /**
  53534. * Enables the gravitational field.
  53535. */
  53536. enable(): void;
  53537. /**
  53538. * Disables the gravitational field.
  53539. */
  53540. disable(): void;
  53541. /**
  53542. * Disposes the sphere.
  53543. * @param force The force to dispose from the gravitational field event
  53544. */
  53545. dispose(force?: boolean): void;
  53546. private _tick;
  53547. }
  53548. /**
  53549. * Represents a physics updraft event
  53550. */
  53551. class PhysicsUpdraftEvent {
  53552. private _scene;
  53553. private _origin;
  53554. private _options;
  53555. private _physicsEngine;
  53556. private _originTop;
  53557. private _originDirection;
  53558. private _tickCallback;
  53559. private _cylinder;
  53560. private _cylinderPosition;
  53561. private _dataFetched;
  53562. /**
  53563. * Initializes the physics updraft event
  53564. * @param _scene BabylonJS scene
  53565. * @param _origin The origin position of the updraft
  53566. * @param _options The options for the updraft event
  53567. */
  53568. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53569. /**
  53570. * Returns the data related to the updraft event (cylinder).
  53571. * @returns A physics updraft event
  53572. */
  53573. getData(): PhysicsUpdraftEventData;
  53574. /**
  53575. * Enables the updraft.
  53576. */
  53577. enable(): void;
  53578. /**
  53579. * Disables the updraft.
  53580. */
  53581. disable(): void;
  53582. /**
  53583. * Disposes the cylinder.
  53584. * @param force Specifies if the updraft should be disposed by force
  53585. */
  53586. dispose(force?: boolean): void;
  53587. private getImpostorHitData;
  53588. private _tick;
  53589. /*** Helpers ***/
  53590. private _prepareCylinder;
  53591. private _intersectsWithCylinder;
  53592. }
  53593. /**
  53594. * Represents a physics vortex event
  53595. */
  53596. class PhysicsVortexEvent {
  53597. private _scene;
  53598. private _origin;
  53599. private _options;
  53600. private _physicsEngine;
  53601. private _originTop;
  53602. private _tickCallback;
  53603. private _cylinder;
  53604. private _cylinderPosition;
  53605. private _dataFetched;
  53606. /**
  53607. * Initializes the physics vortex event
  53608. * @param _scene The BabylonJS scene
  53609. * @param _origin The origin position of the vortex
  53610. * @param _options The options for the vortex event
  53611. */
  53612. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53613. /**
  53614. * Returns the data related to the vortex event (cylinder).
  53615. * @returns The physics vortex event data
  53616. */
  53617. getData(): PhysicsVortexEventData;
  53618. /**
  53619. * Enables the vortex.
  53620. */
  53621. enable(): void;
  53622. /**
  53623. * Disables the cortex.
  53624. */
  53625. disable(): void;
  53626. /**
  53627. * Disposes the sphere.
  53628. * @param force
  53629. */
  53630. dispose(force?: boolean): void;
  53631. private getImpostorHitData;
  53632. private _tick;
  53633. /*** Helpers ***/
  53634. private _prepareCylinder;
  53635. private _intersectsWithCylinder;
  53636. }
  53637. /**
  53638. * Options fot the radial explosion event
  53639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53640. */
  53641. export class PhysicsRadialExplosionEventOptions {
  53642. /**
  53643. * The radius of the sphere for the radial explosion.
  53644. */
  53645. radius: number;
  53646. /**
  53647. * The strenth of the explosion.
  53648. */
  53649. strength: number;
  53650. /**
  53651. * The strenght of the force in correspondence to the distance of the affected object
  53652. */
  53653. falloff: PhysicsRadialImpulseFalloff;
  53654. /**
  53655. * Sphere options for the radial explosion.
  53656. */
  53657. sphere: {
  53658. segments: number;
  53659. diameter: number;
  53660. };
  53661. /**
  53662. * Sphere options for the radial explosion.
  53663. */
  53664. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  53665. }
  53666. /**
  53667. * Options fot the updraft event
  53668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53669. */
  53670. export class PhysicsUpdraftEventOptions {
  53671. /**
  53672. * The radius of the cylinder for the vortex
  53673. */
  53674. radius: number;
  53675. /**
  53676. * The strenth of the updraft.
  53677. */
  53678. strength: number;
  53679. /**
  53680. * The height of the cylinder for the updraft.
  53681. */
  53682. height: number;
  53683. /**
  53684. * The mode for the the updraft.
  53685. */
  53686. updraftMode: PhysicsUpdraftMode;
  53687. }
  53688. /**
  53689. * Options fot the vortex event
  53690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53691. */
  53692. export class PhysicsVortexEventOptions {
  53693. /**
  53694. * The radius of the cylinder for the vortex
  53695. */
  53696. radius: number;
  53697. /**
  53698. * The strenth of the vortex.
  53699. */
  53700. strength: number;
  53701. /**
  53702. * The height of the cylinder for the vortex.
  53703. */
  53704. height: number;
  53705. /**
  53706. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  53707. */
  53708. centripetalForceThreshold: number;
  53709. /**
  53710. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  53711. */
  53712. centripetalForceMultiplier: number;
  53713. /**
  53714. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  53715. */
  53716. centrifugalForceMultiplier: number;
  53717. /**
  53718. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  53719. */
  53720. updraftForceMultiplier: number;
  53721. }
  53722. /**
  53723. * The strenght of the force in correspondence to the distance of the affected object
  53724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53725. */
  53726. export enum PhysicsRadialImpulseFalloff {
  53727. /** Defines that impulse is constant in strength across it's whole radius */
  53728. Constant = 0,
  53729. /** Defines that impulse gets weaker if it's further from the origin */
  53730. Linear = 1
  53731. }
  53732. /**
  53733. * The strength of the force in correspondence to the distance of the affected object
  53734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53735. */
  53736. export enum PhysicsUpdraftMode {
  53737. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  53738. Center = 0,
  53739. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  53740. Perpendicular = 1
  53741. }
  53742. /**
  53743. * Interface for a physics hit data
  53744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53745. */
  53746. export interface PhysicsHitData {
  53747. /**
  53748. * The force applied at the contact point
  53749. */
  53750. force: Vector3;
  53751. /**
  53752. * The contact point
  53753. */
  53754. contactPoint: Vector3;
  53755. /**
  53756. * The distance from the origin to the contact point
  53757. */
  53758. distanceFromOrigin: number;
  53759. }
  53760. /**
  53761. * Interface for radial explosion event data
  53762. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53763. */
  53764. export interface PhysicsRadialExplosionEventData {
  53765. /**
  53766. * A sphere used for the radial explosion event
  53767. */
  53768. sphere: Mesh;
  53769. }
  53770. /**
  53771. * Interface for gravitational field event data
  53772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53773. */
  53774. export interface PhysicsGravitationalFieldEventData {
  53775. /**
  53776. * A sphere mesh used for the gravitational field event
  53777. */
  53778. sphere: Mesh;
  53779. }
  53780. /**
  53781. * Interface for updraft event data
  53782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53783. */
  53784. export interface PhysicsUpdraftEventData {
  53785. /**
  53786. * A cylinder used for the updraft event
  53787. */
  53788. cylinder: Mesh;
  53789. }
  53790. /**
  53791. * Interface for vortex event data
  53792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53793. */
  53794. export interface PhysicsVortexEventData {
  53795. /**
  53796. * A cylinder used for the vortex event
  53797. */
  53798. cylinder: Mesh;
  53799. }
  53800. /**
  53801. * Interface for an affected physics impostor
  53802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53803. */
  53804. export interface PhysicsAffectedImpostorWithData {
  53805. /**
  53806. * The impostor affected by the effect
  53807. */
  53808. impostor: PhysicsImpostor;
  53809. /**
  53810. * The data about the hit/horce from the explosion
  53811. */
  53812. hitData: PhysicsHitData;
  53813. }
  53814. }
  53815. declare module "babylonjs/Physics/Plugins/index" {
  53816. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  53817. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  53818. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  53819. }
  53820. declare module "babylonjs/Physics/index" {
  53821. export * from "babylonjs/Physics/IPhysicsEngine";
  53822. export * from "babylonjs/Physics/physicsEngine";
  53823. export * from "babylonjs/Physics/physicsEngineComponent";
  53824. export * from "babylonjs/Physics/physicsHelper";
  53825. export * from "babylonjs/Physics/physicsImpostor";
  53826. export * from "babylonjs/Physics/physicsJoint";
  53827. export * from "babylonjs/Physics/Plugins/index";
  53828. }
  53829. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  53830. /** @hidden */
  53831. export var blackAndWhitePixelShader: {
  53832. name: string;
  53833. shader: string;
  53834. };
  53835. }
  53836. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  53837. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53838. import { Camera } from "babylonjs/Cameras/camera";
  53839. import { Engine } from "babylonjs/Engines/engine";
  53840. import "babylonjs/Shaders/blackAndWhite.fragment";
  53841. /**
  53842. * Post process used to render in black and white
  53843. */
  53844. export class BlackAndWhitePostProcess extends PostProcess {
  53845. /**
  53846. * Linear about to convert he result to black and white (default: 1)
  53847. */
  53848. degree: number;
  53849. /**
  53850. * Creates a black and white post process
  53851. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  53852. * @param name The name of the effect.
  53853. * @param options The required width/height ratio to downsize to before computing the render pass.
  53854. * @param camera The camera to apply the render pass to.
  53855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53856. * @param engine The engine which the post process will be applied. (default: current engine)
  53857. * @param reusable If the post process can be reused on the same frame. (default: false)
  53858. */
  53859. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53860. }
  53861. }
  53862. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  53863. import { Nullable } from "babylonjs/types";
  53864. import { Camera } from "babylonjs/Cameras/camera";
  53865. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53866. import { Engine } from "babylonjs/Engines/engine";
  53867. /**
  53868. * This represents a set of one or more post processes in Babylon.
  53869. * A post process can be used to apply a shader to a texture after it is rendered.
  53870. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53871. */
  53872. export class PostProcessRenderEffect {
  53873. private _postProcesses;
  53874. private _getPostProcesses;
  53875. private _singleInstance;
  53876. private _cameras;
  53877. private _indicesForCamera;
  53878. /**
  53879. * Name of the effect
  53880. * @hidden
  53881. */
  53882. _name: string;
  53883. /**
  53884. * Instantiates a post process render effect.
  53885. * A post process can be used to apply a shader to a texture after it is rendered.
  53886. * @param engine The engine the effect is tied to
  53887. * @param name The name of the effect
  53888. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  53889. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  53890. */
  53891. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  53892. /**
  53893. * Checks if all the post processes in the effect are supported.
  53894. */
  53895. readonly isSupported: boolean;
  53896. /**
  53897. * Updates the current state of the effect
  53898. * @hidden
  53899. */
  53900. _update(): void;
  53901. /**
  53902. * Attaches the effect on cameras
  53903. * @param cameras The camera to attach to.
  53904. * @hidden
  53905. */
  53906. _attachCameras(cameras: Camera): void;
  53907. /**
  53908. * Attaches the effect on cameras
  53909. * @param cameras The camera to attach to.
  53910. * @hidden
  53911. */
  53912. _attachCameras(cameras: Camera[]): void;
  53913. /**
  53914. * Detatches the effect on cameras
  53915. * @param cameras The camera to detatch from.
  53916. * @hidden
  53917. */
  53918. _detachCameras(cameras: Camera): void;
  53919. /**
  53920. * Detatches the effect on cameras
  53921. * @param cameras The camera to detatch from.
  53922. * @hidden
  53923. */
  53924. _detachCameras(cameras: Camera[]): void;
  53925. /**
  53926. * Enables the effect on given cameras
  53927. * @param cameras The camera to enable.
  53928. * @hidden
  53929. */
  53930. _enable(cameras: Camera): void;
  53931. /**
  53932. * Enables the effect on given cameras
  53933. * @param cameras The camera to enable.
  53934. * @hidden
  53935. */
  53936. _enable(cameras: Nullable<Camera[]>): void;
  53937. /**
  53938. * Disables the effect on the given cameras
  53939. * @param cameras The camera to disable.
  53940. * @hidden
  53941. */
  53942. _disable(cameras: Camera): void;
  53943. /**
  53944. * Disables the effect on the given cameras
  53945. * @param cameras The camera to disable.
  53946. * @hidden
  53947. */
  53948. _disable(cameras: Nullable<Camera[]>): void;
  53949. /**
  53950. * Gets a list of the post processes contained in the effect.
  53951. * @param camera The camera to get the post processes on.
  53952. * @returns The list of the post processes in the effect.
  53953. */
  53954. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  53955. }
  53956. }
  53957. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  53958. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53959. /** @hidden */
  53960. export var extractHighlightsPixelShader: {
  53961. name: string;
  53962. shader: string;
  53963. };
  53964. }
  53965. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  53966. import { Nullable } from "babylonjs/types";
  53967. import { Camera } from "babylonjs/Cameras/camera";
  53968. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53969. import { Engine } from "babylonjs/Engines/engine";
  53970. import "babylonjs/Shaders/extractHighlights.fragment";
  53971. /**
  53972. * 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.
  53973. */
  53974. export class ExtractHighlightsPostProcess extends PostProcess {
  53975. /**
  53976. * The luminance threshold, pixels below this value will be set to black.
  53977. */
  53978. threshold: number;
  53979. /** @hidden */
  53980. _exposure: number;
  53981. /**
  53982. * Post process which has the input texture to be used when performing highlight extraction
  53983. * @hidden
  53984. */
  53985. _inputPostProcess: Nullable<PostProcess>;
  53986. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53987. }
  53988. }
  53989. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  53990. /** @hidden */
  53991. export var bloomMergePixelShader: {
  53992. name: string;
  53993. shader: string;
  53994. };
  53995. }
  53996. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  53997. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53998. import { Nullable } from "babylonjs/types";
  53999. import { Engine } from "babylonjs/Engines/engine";
  54000. import { Camera } from "babylonjs/Cameras/camera";
  54001. import "babylonjs/Shaders/bloomMerge.fragment";
  54002. /**
  54003. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54004. */
  54005. export class BloomMergePostProcess extends PostProcess {
  54006. /** Weight of the bloom to be added to the original input. */
  54007. weight: number;
  54008. /**
  54009. * Creates a new instance of @see BloomMergePostProcess
  54010. * @param name The name of the effect.
  54011. * @param originalFromInput Post process which's input will be used for the merge.
  54012. * @param blurred Blurred highlights post process which's output will be used.
  54013. * @param weight Weight of the bloom to be added to the original input.
  54014. * @param options The required width/height ratio to downsize to before computing the render pass.
  54015. * @param camera The camera to apply the render pass to.
  54016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54017. * @param engine The engine which the post process will be applied. (default: current engine)
  54018. * @param reusable If the post process can be reused on the same frame. (default: false)
  54019. * @param textureType Type of textures used when performing the post process. (default: 0)
  54020. * @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)
  54021. */
  54022. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54023. /** Weight of the bloom to be added to the original input. */
  54024. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54025. }
  54026. }
  54027. declare module "babylonjs/PostProcesses/bloomEffect" {
  54028. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54029. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54030. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54031. import { Camera } from "babylonjs/Cameras/camera";
  54032. import { Scene } from "babylonjs/scene";
  54033. /**
  54034. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54035. */
  54036. export class BloomEffect extends PostProcessRenderEffect {
  54037. private bloomScale;
  54038. /**
  54039. * @hidden Internal
  54040. */
  54041. _effects: Array<PostProcess>;
  54042. /**
  54043. * @hidden Internal
  54044. */
  54045. _downscale: ExtractHighlightsPostProcess;
  54046. private _blurX;
  54047. private _blurY;
  54048. private _merge;
  54049. /**
  54050. * The luminance threshold to find bright areas of the image to bloom.
  54051. */
  54052. threshold: number;
  54053. /**
  54054. * The strength of the bloom.
  54055. */
  54056. weight: number;
  54057. /**
  54058. * Specifies the size of the bloom blur kernel, relative to the final output size
  54059. */
  54060. kernel: number;
  54061. /**
  54062. * Creates a new instance of @see BloomEffect
  54063. * @param scene The scene the effect belongs to.
  54064. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54065. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54066. * @param bloomWeight The the strength of bloom.
  54067. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54068. * @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)
  54069. */
  54070. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54071. /**
  54072. * Disposes each of the internal effects for a given camera.
  54073. * @param camera The camera to dispose the effect on.
  54074. */
  54075. disposeEffects(camera: Camera): void;
  54076. /**
  54077. * @hidden Internal
  54078. */
  54079. _updateEffects(): void;
  54080. /**
  54081. * Internal
  54082. * @returns if all the contained post processes are ready.
  54083. * @hidden
  54084. */
  54085. _isReady(): boolean;
  54086. }
  54087. }
  54088. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54089. /** @hidden */
  54090. export var chromaticAberrationPixelShader: {
  54091. name: string;
  54092. shader: string;
  54093. };
  54094. }
  54095. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54096. import { Vector2 } from "babylonjs/Maths/math";
  54097. import { Nullable } from "babylonjs/types";
  54098. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54099. import { Camera } from "babylonjs/Cameras/camera";
  54100. import { Engine } from "babylonjs/Engines/engine";
  54101. import "babylonjs/Shaders/chromaticAberration.fragment";
  54102. /**
  54103. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54104. */
  54105. export class ChromaticAberrationPostProcess extends PostProcess {
  54106. /**
  54107. * The amount of seperation of rgb channels (default: 30)
  54108. */
  54109. aberrationAmount: number;
  54110. /**
  54111. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54112. */
  54113. radialIntensity: number;
  54114. /**
  54115. * 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))
  54116. */
  54117. direction: Vector2;
  54118. /**
  54119. * 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))
  54120. */
  54121. centerPosition: Vector2;
  54122. /**
  54123. * Creates a new instance ChromaticAberrationPostProcess
  54124. * @param name The name of the effect.
  54125. * @param screenWidth The width of the screen to apply the effect on.
  54126. * @param screenHeight The height of the screen to apply the effect on.
  54127. * @param options The required width/height ratio to downsize to before computing the render pass.
  54128. * @param camera The camera to apply the render pass to.
  54129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54130. * @param engine The engine which the post process will be applied. (default: current engine)
  54131. * @param reusable If the post process can be reused on the same frame. (default: false)
  54132. * @param textureType Type of textures used when performing the post process. (default: 0)
  54133. * @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)
  54134. */
  54135. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54136. }
  54137. }
  54138. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54139. /** @hidden */
  54140. export var circleOfConfusionPixelShader: {
  54141. name: string;
  54142. shader: string;
  54143. };
  54144. }
  54145. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54146. import { Nullable } from "babylonjs/types";
  54147. import { Engine } from "babylonjs/Engines/engine";
  54148. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54149. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54150. import { Camera } from "babylonjs/Cameras/camera";
  54151. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54152. /**
  54153. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54154. */
  54155. export class CircleOfConfusionPostProcess extends PostProcess {
  54156. /**
  54157. * 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.
  54158. */
  54159. lensSize: number;
  54160. /**
  54161. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54162. */
  54163. fStop: number;
  54164. /**
  54165. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54166. */
  54167. focusDistance: number;
  54168. /**
  54169. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54170. */
  54171. focalLength: number;
  54172. private _depthTexture;
  54173. /**
  54174. * Creates a new instance CircleOfConfusionPostProcess
  54175. * @param name The name of the effect.
  54176. * @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.
  54177. * @param options The required width/height ratio to downsize to before computing the render pass.
  54178. * @param camera The camera to apply the render pass to.
  54179. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54180. * @param engine The engine which the post process will be applied. (default: current engine)
  54181. * @param reusable If the post process can be reused on the same frame. (default: false)
  54182. * @param textureType Type of textures used when performing the post process. (default: 0)
  54183. * @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)
  54184. */
  54185. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54186. /**
  54187. * 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.
  54188. */
  54189. depthTexture: RenderTargetTexture;
  54190. }
  54191. }
  54192. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54193. /** @hidden */
  54194. export var colorCorrectionPixelShader: {
  54195. name: string;
  54196. shader: string;
  54197. };
  54198. }
  54199. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  54200. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54201. import { Engine } from "babylonjs/Engines/engine";
  54202. import { Camera } from "babylonjs/Cameras/camera";
  54203. import "babylonjs/Shaders/colorCorrection.fragment";
  54204. /**
  54205. *
  54206. * This post-process allows the modification of rendered colors by using
  54207. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54208. *
  54209. * The object needs to be provided an url to a texture containing the color
  54210. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54211. * Use an image editing software to tweak the LUT to match your needs.
  54212. *
  54213. * For an example of a color LUT, see here:
  54214. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54215. * For explanations on color grading, see here:
  54216. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54217. *
  54218. */
  54219. export class ColorCorrectionPostProcess extends PostProcess {
  54220. private _colorTableTexture;
  54221. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54222. }
  54223. }
  54224. declare module "babylonjs/Shaders/convolution.fragment" {
  54225. /** @hidden */
  54226. export var convolutionPixelShader: {
  54227. name: string;
  54228. shader: string;
  54229. };
  54230. }
  54231. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  54232. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54233. import { Nullable } from "babylonjs/types";
  54234. import { Camera } from "babylonjs/Cameras/camera";
  54235. import { Engine } from "babylonjs/Engines/engine";
  54236. import "babylonjs/Shaders/convolution.fragment";
  54237. /**
  54238. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54239. * input texture to perform effects such as edge detection or sharpening
  54240. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54241. */
  54242. export class ConvolutionPostProcess extends PostProcess {
  54243. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54244. kernel: number[];
  54245. /**
  54246. * Creates a new instance ConvolutionPostProcess
  54247. * @param name The name of the effect.
  54248. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54249. * @param options The required width/height ratio to downsize to before computing the render pass.
  54250. * @param camera The camera to apply the render pass to.
  54251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54252. * @param engine The engine which the post process will be applied. (default: current engine)
  54253. * @param reusable If the post process can be reused on the same frame. (default: false)
  54254. * @param textureType Type of textures used when performing the post process. (default: 0)
  54255. */
  54256. constructor(name: string,
  54257. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54258. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54259. /**
  54260. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54261. */
  54262. static EdgeDetect0Kernel: number[];
  54263. /**
  54264. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54265. */
  54266. static EdgeDetect1Kernel: number[];
  54267. /**
  54268. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54269. */
  54270. static EdgeDetect2Kernel: number[];
  54271. /**
  54272. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54273. */
  54274. static SharpenKernel: number[];
  54275. /**
  54276. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54277. */
  54278. static EmbossKernel: number[];
  54279. /**
  54280. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54281. */
  54282. static GaussianKernel: number[];
  54283. }
  54284. }
  54285. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  54286. import { Nullable } from "babylonjs/types";
  54287. import { Vector2 } from "babylonjs/Maths/math";
  54288. import { Camera } from "babylonjs/Cameras/camera";
  54289. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54290. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54291. import { Engine } from "babylonjs/Engines/engine";
  54292. import { Scene } from "babylonjs/scene";
  54293. /**
  54294. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54295. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54296. * based on samples that have a large difference in distance than the center pixel.
  54297. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54298. */
  54299. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54300. direction: Vector2;
  54301. /**
  54302. * Creates a new instance CircleOfConfusionPostProcess
  54303. * @param name The name of the effect.
  54304. * @param scene The scene the effect belongs to.
  54305. * @param direction The direction the blur should be applied.
  54306. * @param kernel The size of the kernel used to blur.
  54307. * @param options The required width/height ratio to downsize to before computing the render pass.
  54308. * @param camera The camera to apply the render pass to.
  54309. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54310. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54312. * @param engine The engine which the post process will be applied. (default: current engine)
  54313. * @param reusable If the post process can be reused on the same frame. (default: false)
  54314. * @param textureType Type of textures used when performing the post process. (default: 0)
  54315. * @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)
  54316. */
  54317. 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);
  54318. }
  54319. }
  54320. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  54321. /** @hidden */
  54322. export var depthOfFieldMergePixelShader: {
  54323. name: string;
  54324. shader: string;
  54325. };
  54326. }
  54327. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  54328. import { Nullable } from "babylonjs/types";
  54329. import { Camera } from "babylonjs/Cameras/camera";
  54330. import { Effect } from "babylonjs/Materials/effect";
  54331. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54332. import { Engine } from "babylonjs/Engines/engine";
  54333. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54334. /**
  54335. * Options to be set when merging outputs from the default pipeline.
  54336. */
  54337. export class DepthOfFieldMergePostProcessOptions {
  54338. /**
  54339. * The original image to merge on top of
  54340. */
  54341. originalFromInput: PostProcess;
  54342. /**
  54343. * Parameters to perform the merge of the depth of field effect
  54344. */
  54345. depthOfField?: {
  54346. circleOfConfusion: PostProcess;
  54347. blurSteps: Array<PostProcess>;
  54348. };
  54349. /**
  54350. * Parameters to perform the merge of bloom effect
  54351. */
  54352. bloom?: {
  54353. blurred: PostProcess;
  54354. weight: number;
  54355. };
  54356. }
  54357. /**
  54358. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54359. */
  54360. export class DepthOfFieldMergePostProcess extends PostProcess {
  54361. private blurSteps;
  54362. /**
  54363. * Creates a new instance of DepthOfFieldMergePostProcess
  54364. * @param name The name of the effect.
  54365. * @param originalFromInput Post process which's input will be used for the merge.
  54366. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54367. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54368. * @param options The required width/height ratio to downsize to before computing the render pass.
  54369. * @param camera The camera to apply the render pass to.
  54370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54371. * @param engine The engine which the post process will be applied. (default: current engine)
  54372. * @param reusable If the post process can be reused on the same frame. (default: false)
  54373. * @param textureType Type of textures used when performing the post process. (default: 0)
  54374. * @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)
  54375. */
  54376. 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);
  54377. /**
  54378. * Updates the effect with the current post process compile time values and recompiles the shader.
  54379. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54380. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54381. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54382. * @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
  54383. * @param onCompiled Called when the shader has been compiled.
  54384. * @param onError Called if there is an error when compiling a shader.
  54385. */
  54386. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54387. }
  54388. }
  54389. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54390. import { Nullable } from "babylonjs/types";
  54391. import { Camera } from "babylonjs/Cameras/camera";
  54392. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54393. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54394. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54395. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54396. import { Scene } from "babylonjs/scene";
  54397. /**
  54398. * Specifies the level of max blur that should be applied when using the depth of field effect
  54399. */
  54400. export enum DepthOfFieldEffectBlurLevel {
  54401. /**
  54402. * Subtle blur
  54403. */
  54404. Low = 0,
  54405. /**
  54406. * Medium blur
  54407. */
  54408. Medium = 1,
  54409. /**
  54410. * Large blur
  54411. */
  54412. High = 2
  54413. }
  54414. /**
  54415. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54416. */
  54417. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54418. private _circleOfConfusion;
  54419. /**
  54420. * @hidden Internal, blurs from high to low
  54421. */
  54422. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54423. private _depthOfFieldBlurY;
  54424. private _dofMerge;
  54425. /**
  54426. * @hidden Internal post processes in depth of field effect
  54427. */
  54428. _effects: Array<PostProcess>;
  54429. /**
  54430. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54431. */
  54432. focalLength: number;
  54433. /**
  54434. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54435. */
  54436. fStop: number;
  54437. /**
  54438. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54439. */
  54440. focusDistance: number;
  54441. /**
  54442. * 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.
  54443. */
  54444. lensSize: number;
  54445. /**
  54446. * Creates a new instance DepthOfFieldEffect
  54447. * @param scene The scene the effect belongs to.
  54448. * @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.
  54449. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54450. * @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)
  54451. */
  54452. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54453. /**
  54454. * 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.
  54455. */
  54456. depthTexture: RenderTargetTexture;
  54457. /**
  54458. * Disposes each of the internal effects for a given camera.
  54459. * @param camera The camera to dispose the effect on.
  54460. */
  54461. disposeEffects(camera: Camera): void;
  54462. /**
  54463. * @hidden Internal
  54464. */
  54465. _updateEffects(): void;
  54466. /**
  54467. * Internal
  54468. * @returns if all the contained post processes are ready.
  54469. * @hidden
  54470. */
  54471. _isReady(): boolean;
  54472. }
  54473. }
  54474. declare module "babylonjs/Shaders/displayPass.fragment" {
  54475. /** @hidden */
  54476. export var displayPassPixelShader: {
  54477. name: string;
  54478. shader: string;
  54479. };
  54480. }
  54481. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54482. import { Nullable } from "babylonjs/types";
  54483. import { Camera } from "babylonjs/Cameras/camera";
  54484. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54485. import { Engine } from "babylonjs/Engines/engine";
  54486. import "babylonjs/Shaders/displayPass.fragment";
  54487. /**
  54488. * DisplayPassPostProcess which produces an output the same as it's input
  54489. */
  54490. export class DisplayPassPostProcess extends PostProcess {
  54491. /**
  54492. * Creates the DisplayPassPostProcess
  54493. * @param name The name of the effect.
  54494. * @param options The required width/height ratio to downsize to before computing the render pass.
  54495. * @param camera The camera to apply the render pass to.
  54496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54497. * @param engine The engine which the post process will be applied. (default: current engine)
  54498. * @param reusable If the post process can be reused on the same frame. (default: false)
  54499. */
  54500. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54501. }
  54502. }
  54503. declare module "babylonjs/Shaders/filter.fragment" {
  54504. /** @hidden */
  54505. export var filterPixelShader: {
  54506. name: string;
  54507. shader: string;
  54508. };
  54509. }
  54510. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54511. import { Nullable } from "babylonjs/types";
  54512. import { Matrix } from "babylonjs/Maths/math";
  54513. import { Camera } from "babylonjs/Cameras/camera";
  54514. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54515. import { Engine } from "babylonjs/Engines/engine";
  54516. import "babylonjs/Shaders/filter.fragment";
  54517. /**
  54518. * Applies a kernel filter to the image
  54519. */
  54520. export class FilterPostProcess extends PostProcess {
  54521. /** The matrix to be applied to the image */
  54522. kernelMatrix: Matrix;
  54523. /**
  54524. *
  54525. * @param name The name of the effect.
  54526. * @param kernelMatrix The matrix to be applied to the image
  54527. * @param options The required width/height ratio to downsize to before computing the render pass.
  54528. * @param camera The camera to apply the render pass to.
  54529. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54530. * @param engine The engine which the post process will be applied. (default: current engine)
  54531. * @param reusable If the post process can be reused on the same frame. (default: false)
  54532. */
  54533. constructor(name: string,
  54534. /** The matrix to be applied to the image */
  54535. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54536. }
  54537. }
  54538. declare module "babylonjs/Shaders/fxaa.fragment" {
  54539. /** @hidden */
  54540. export var fxaaPixelShader: {
  54541. name: string;
  54542. shader: string;
  54543. };
  54544. }
  54545. declare module "babylonjs/Shaders/fxaa.vertex" {
  54546. /** @hidden */
  54547. export var fxaaVertexShader: {
  54548. name: string;
  54549. shader: string;
  54550. };
  54551. }
  54552. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54553. import { Nullable } from "babylonjs/types";
  54554. import { Camera } from "babylonjs/Cameras/camera";
  54555. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54556. import { Engine } from "babylonjs/Engines/engine";
  54557. import "babylonjs/Shaders/fxaa.fragment";
  54558. import "babylonjs/Shaders/fxaa.vertex";
  54559. /**
  54560. * Fxaa post process
  54561. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54562. */
  54563. export class FxaaPostProcess extends PostProcess {
  54564. /** @hidden */
  54565. texelWidth: number;
  54566. /** @hidden */
  54567. texelHeight: number;
  54568. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54569. private _getDefines;
  54570. }
  54571. }
  54572. declare module "babylonjs/Shaders/grain.fragment" {
  54573. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54574. /** @hidden */
  54575. export var grainPixelShader: {
  54576. name: string;
  54577. shader: string;
  54578. };
  54579. }
  54580. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54581. import { Nullable } from "babylonjs/types";
  54582. import { Camera } from "babylonjs/Cameras/camera";
  54583. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54584. import { Engine } from "babylonjs/Engines/engine";
  54585. import "babylonjs/Shaders/grain.fragment";
  54586. /**
  54587. * The GrainPostProcess adds noise to the image at mid luminance levels
  54588. */
  54589. export class GrainPostProcess extends PostProcess {
  54590. /**
  54591. * The intensity of the grain added (default: 30)
  54592. */
  54593. intensity: number;
  54594. /**
  54595. * If the grain should be randomized on every frame
  54596. */
  54597. animated: boolean;
  54598. /**
  54599. * Creates a new instance of @see GrainPostProcess
  54600. * @param name The name of the effect.
  54601. * @param options The required width/height ratio to downsize to before computing the render pass.
  54602. * @param camera The camera to apply the render pass to.
  54603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54604. * @param engine The engine which the post process will be applied. (default: current engine)
  54605. * @param reusable If the post process can be reused on the same frame. (default: false)
  54606. * @param textureType Type of textures used when performing the post process. (default: 0)
  54607. * @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)
  54608. */
  54609. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54610. }
  54611. }
  54612. declare module "babylonjs/Shaders/highlights.fragment" {
  54613. /** @hidden */
  54614. export var highlightsPixelShader: {
  54615. name: string;
  54616. shader: string;
  54617. };
  54618. }
  54619. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54620. import { Nullable } from "babylonjs/types";
  54621. import { Camera } from "babylonjs/Cameras/camera";
  54622. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54623. import { Engine } from "babylonjs/Engines/engine";
  54624. import "babylonjs/Shaders/highlights.fragment";
  54625. /**
  54626. * Extracts highlights from the image
  54627. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54628. */
  54629. export class HighlightsPostProcess extends PostProcess {
  54630. /**
  54631. * Extracts highlights from the image
  54632. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54633. * @param name The name of the effect.
  54634. * @param options The required width/height ratio to downsize to before computing the render pass.
  54635. * @param camera The camera to apply the render pass to.
  54636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54637. * @param engine The engine which the post process will be applied. (default: current engine)
  54638. * @param reusable If the post process can be reused on the same frame. (default: false)
  54639. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54640. */
  54641. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54642. }
  54643. }
  54644. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54645. /** @hidden */
  54646. export var mrtFragmentDeclaration: {
  54647. name: string;
  54648. shader: string;
  54649. };
  54650. }
  54651. declare module "babylonjs/Shaders/geometry.fragment" {
  54652. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54653. /** @hidden */
  54654. export var geometryPixelShader: {
  54655. name: string;
  54656. shader: string;
  54657. };
  54658. }
  54659. declare module "babylonjs/Shaders/geometry.vertex" {
  54660. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54661. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54662. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54663. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54664. /** @hidden */
  54665. export var geometryVertexShader: {
  54666. name: string;
  54667. shader: string;
  54668. };
  54669. }
  54670. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54671. import { Matrix } from "babylonjs/Maths/math";
  54672. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54673. import { Mesh } from "babylonjs/Meshes/mesh";
  54674. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54675. import { Effect } from "babylonjs/Materials/effect";
  54676. import { Scene } from "babylonjs/scene";
  54677. import "babylonjs/Shaders/geometry.fragment";
  54678. import "babylonjs/Shaders/geometry.vertex";
  54679. /**
  54680. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54681. */
  54682. export class GeometryBufferRenderer {
  54683. /**
  54684. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54685. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54686. */
  54687. static readonly POSITION_TEXTURE_TYPE: number;
  54688. /**
  54689. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54690. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54691. */
  54692. static readonly VELOCITY_TEXTURE_TYPE: number;
  54693. /**
  54694. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54695. * in order to compute objects velocities when enableVelocity is set to "true"
  54696. * @hidden
  54697. */
  54698. _previousTransformationMatrices: {
  54699. [index: number]: Matrix;
  54700. };
  54701. private _scene;
  54702. private _multiRenderTarget;
  54703. private _ratio;
  54704. private _enablePosition;
  54705. private _enableVelocity;
  54706. private _positionIndex;
  54707. private _velocityIndex;
  54708. protected _effect: Effect;
  54709. protected _cachedDefines: string;
  54710. /**
  54711. * Set the render list (meshes to be rendered) used in the G buffer.
  54712. */
  54713. renderList: Mesh[];
  54714. /**
  54715. * Gets wether or not G buffer are supported by the running hardware.
  54716. * This requires draw buffer supports
  54717. */
  54718. readonly isSupported: boolean;
  54719. /**
  54720. * Returns the index of the given texture type in the G-Buffer textures array
  54721. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54722. * @returns the index of the given texture type in the G-Buffer textures array
  54723. */
  54724. getTextureIndex(textureType: number): number;
  54725. /**
  54726. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54727. */
  54728. /**
  54729. * Sets whether or not objects positions are enabled for the G buffer.
  54730. */
  54731. enablePosition: boolean;
  54732. /**
  54733. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54734. */
  54735. /**
  54736. * Sets wether or not objects velocities are enabled for the G buffer.
  54737. */
  54738. enableVelocity: boolean;
  54739. /**
  54740. * Gets the scene associated with the buffer.
  54741. */
  54742. readonly scene: Scene;
  54743. /**
  54744. * Gets the ratio used by the buffer during its creation.
  54745. * How big is the buffer related to the main canvas.
  54746. */
  54747. readonly ratio: number;
  54748. /** @hidden */
  54749. static _SceneComponentInitialization: (scene: Scene) => void;
  54750. /**
  54751. * Creates a new G Buffer for the scene
  54752. * @param scene The scene the buffer belongs to
  54753. * @param ratio How big is the buffer related to the main canvas.
  54754. */
  54755. constructor(scene: Scene, ratio?: number);
  54756. /**
  54757. * Checks wether everything is ready to render a submesh to the G buffer.
  54758. * @param subMesh the submesh to check readiness for
  54759. * @param useInstances is the mesh drawn using instance or not
  54760. * @returns true if ready otherwise false
  54761. */
  54762. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54763. /**
  54764. * Gets the current underlying G Buffer.
  54765. * @returns the buffer
  54766. */
  54767. getGBuffer(): MultiRenderTarget;
  54768. /**
  54769. * Gets the number of samples used to render the buffer (anti aliasing).
  54770. */
  54771. /**
  54772. * Sets the number of samples used to render the buffer (anti aliasing).
  54773. */
  54774. samples: number;
  54775. /**
  54776. * Disposes the renderer and frees up associated resources.
  54777. */
  54778. dispose(): void;
  54779. protected _createRenderTargets(): void;
  54780. }
  54781. }
  54782. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54783. import { Nullable } from "babylonjs/types";
  54784. import { Scene } from "babylonjs/scene";
  54785. import { ISceneComponent } from "babylonjs/sceneComponent";
  54786. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54787. module "babylonjs/scene" {
  54788. interface Scene {
  54789. /** @hidden (Backing field) */
  54790. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54791. /**
  54792. * Gets or Sets the current geometry buffer associated to the scene.
  54793. */
  54794. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54795. /**
  54796. * Enables a GeometryBufferRender and associates it with the scene
  54797. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54798. * @returns the GeometryBufferRenderer
  54799. */
  54800. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54801. /**
  54802. * Disables the GeometryBufferRender associated with the scene
  54803. */
  54804. disableGeometryBufferRenderer(): void;
  54805. }
  54806. }
  54807. /**
  54808. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54809. * in several rendering techniques.
  54810. */
  54811. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54812. /**
  54813. * The component name helpful to identify the component in the list of scene components.
  54814. */
  54815. readonly name: string;
  54816. /**
  54817. * The scene the component belongs to.
  54818. */
  54819. scene: Scene;
  54820. /**
  54821. * Creates a new instance of the component for the given scene
  54822. * @param scene Defines the scene to register the component in
  54823. */
  54824. constructor(scene: Scene);
  54825. /**
  54826. * Registers the component in a given scene
  54827. */
  54828. register(): void;
  54829. /**
  54830. * Rebuilds the elements related to this component in case of
  54831. * context lost for instance.
  54832. */
  54833. rebuild(): void;
  54834. /**
  54835. * Disposes the component and the associated ressources
  54836. */
  54837. dispose(): void;
  54838. private _gatherRenderTargets;
  54839. }
  54840. }
  54841. declare module "babylonjs/Shaders/motionBlur.fragment" {
  54842. /** @hidden */
  54843. export var motionBlurPixelShader: {
  54844. name: string;
  54845. shader: string;
  54846. };
  54847. }
  54848. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  54849. import { Nullable } from "babylonjs/types";
  54850. import { Camera } from "babylonjs/Cameras/camera";
  54851. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54852. import { Scene } from "babylonjs/scene";
  54853. import "babylonjs/Animations/animatable";
  54854. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54855. import "babylonjs/Shaders/motionBlur.fragment";
  54856. import { Engine } from "babylonjs/Engines/engine";
  54857. /**
  54858. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54859. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54860. * As an example, all you have to do is to create the post-process:
  54861. * var mb = new BABYLON.MotionBlurPostProcess(
  54862. * 'mb', // The name of the effect.
  54863. * scene, // The scene containing the objects to blur according to their velocity.
  54864. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54865. * camera // The camera to apply the render pass to.
  54866. * );
  54867. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54868. */
  54869. export class MotionBlurPostProcess extends PostProcess {
  54870. /**
  54871. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54872. */
  54873. motionStrength: number;
  54874. /**
  54875. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54876. */
  54877. /**
  54878. * Sets the number of iterations to be used for motion blur quality
  54879. */
  54880. motionBlurSamples: number;
  54881. private _motionBlurSamples;
  54882. private _geometryBufferRenderer;
  54883. /**
  54884. * Creates a new instance MotionBlurPostProcess
  54885. * @param name The name of the effect.
  54886. * @param scene The scene containing the objects to blur according to their velocity.
  54887. * @param options The required width/height ratio to downsize to before computing the render pass.
  54888. * @param camera The camera to apply the render pass to.
  54889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54890. * @param engine The engine which the post process will be applied. (default: current engine)
  54891. * @param reusable If the post process can be reused on the same frame. (default: false)
  54892. * @param textureType Type of textures used when performing the post process. (default: 0)
  54893. * @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)
  54894. */
  54895. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54896. /**
  54897. * Disposes the post process.
  54898. * @param camera The camera to dispose the post process on.
  54899. */
  54900. dispose(camera?: Camera): void;
  54901. }
  54902. }
  54903. declare module "babylonjs/Shaders/refraction.fragment" {
  54904. /** @hidden */
  54905. export var refractionPixelShader: {
  54906. name: string;
  54907. shader: string;
  54908. };
  54909. }
  54910. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  54911. import { Color3 } from "babylonjs/Maths/math";
  54912. import { Camera } from "babylonjs/Cameras/camera";
  54913. import { Texture } from "babylonjs/Materials/Textures/texture";
  54914. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54915. import { Engine } from "babylonjs/Engines/engine";
  54916. import "babylonjs/Shaders/refraction.fragment";
  54917. /**
  54918. * Post process which applies a refractin texture
  54919. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54920. */
  54921. export class RefractionPostProcess extends PostProcess {
  54922. /** the base color of the refraction (used to taint the rendering) */
  54923. color: Color3;
  54924. /** simulated refraction depth */
  54925. depth: number;
  54926. /** the coefficient of the base color (0 to remove base color tainting) */
  54927. colorLevel: number;
  54928. private _refTexture;
  54929. private _ownRefractionTexture;
  54930. /**
  54931. * Gets or sets the refraction texture
  54932. * Please note that you are responsible for disposing the texture if you set it manually
  54933. */
  54934. refractionTexture: Texture;
  54935. /**
  54936. * Initializes the RefractionPostProcess
  54937. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54938. * @param name The name of the effect.
  54939. * @param refractionTextureUrl Url of the refraction texture to use
  54940. * @param color the base color of the refraction (used to taint the rendering)
  54941. * @param depth simulated refraction depth
  54942. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  54943. * @param camera The camera to apply the render pass to.
  54944. * @param options The required width/height ratio to downsize to before computing the render pass.
  54945. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54946. * @param engine The engine which the post process will be applied. (default: current engine)
  54947. * @param reusable If the post process can be reused on the same frame. (default: false)
  54948. */
  54949. constructor(name: string, refractionTextureUrl: string,
  54950. /** the base color of the refraction (used to taint the rendering) */
  54951. color: Color3,
  54952. /** simulated refraction depth */
  54953. depth: number,
  54954. /** the coefficient of the base color (0 to remove base color tainting) */
  54955. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54956. /**
  54957. * Disposes of the post process
  54958. * @param camera Camera to dispose post process on
  54959. */
  54960. dispose(camera: Camera): void;
  54961. }
  54962. }
  54963. declare module "babylonjs/Shaders/sharpen.fragment" {
  54964. /** @hidden */
  54965. export var sharpenPixelShader: {
  54966. name: string;
  54967. shader: string;
  54968. };
  54969. }
  54970. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  54971. import { Nullable } from "babylonjs/types";
  54972. import { Camera } from "babylonjs/Cameras/camera";
  54973. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54974. import "babylonjs/Shaders/sharpen.fragment";
  54975. import { Engine } from "babylonjs/Engines/engine";
  54976. /**
  54977. * The SharpenPostProcess applies a sharpen kernel to every pixel
  54978. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54979. */
  54980. export class SharpenPostProcess extends PostProcess {
  54981. /**
  54982. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  54983. */
  54984. colorAmount: number;
  54985. /**
  54986. * How much sharpness should be applied (default: 0.3)
  54987. */
  54988. edgeAmount: number;
  54989. /**
  54990. * Creates a new instance ConvolutionPostProcess
  54991. * @param name The name of the effect.
  54992. * @param options The required width/height ratio to downsize to before computing the render pass.
  54993. * @param camera The camera to apply the render pass to.
  54994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54995. * @param engine The engine which the post process will be applied. (default: current engine)
  54996. * @param reusable If the post process can be reused on the same frame. (default: false)
  54997. * @param textureType Type of textures used when performing the post process. (default: 0)
  54998. * @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)
  54999. */
  55000. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55001. }
  55002. }
  55003. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55004. import { Nullable } from "babylonjs/types";
  55005. import { Camera } from "babylonjs/Cameras/camera";
  55006. import { Engine } from "babylonjs/Engines/engine";
  55007. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55008. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55009. /**
  55010. * PostProcessRenderPipeline
  55011. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55012. */
  55013. export class PostProcessRenderPipeline {
  55014. private engine;
  55015. private _renderEffects;
  55016. private _renderEffectsForIsolatedPass;
  55017. /**
  55018. * List of inspectable custom properties (used by the Inspector)
  55019. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55020. */
  55021. inspectableCustomProperties: IInspectable[];
  55022. /**
  55023. * @hidden
  55024. */
  55025. protected _cameras: Camera[];
  55026. /** @hidden */
  55027. _name: string;
  55028. /**
  55029. * Gets pipeline name
  55030. */
  55031. readonly name: string;
  55032. /**
  55033. * Initializes a PostProcessRenderPipeline
  55034. * @param engine engine to add the pipeline to
  55035. * @param name name of the pipeline
  55036. */
  55037. constructor(engine: Engine, name: string);
  55038. /**
  55039. * Gets the class name
  55040. * @returns "PostProcessRenderPipeline"
  55041. */
  55042. getClassName(): string;
  55043. /**
  55044. * If all the render effects in the pipeline are supported
  55045. */
  55046. readonly isSupported: boolean;
  55047. /**
  55048. * Adds an effect to the pipeline
  55049. * @param renderEffect the effect to add
  55050. */
  55051. addEffect(renderEffect: PostProcessRenderEffect): void;
  55052. /** @hidden */
  55053. _rebuild(): void;
  55054. /** @hidden */
  55055. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55056. /** @hidden */
  55057. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55058. /** @hidden */
  55059. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55060. /** @hidden */
  55061. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55062. /** @hidden */
  55063. _attachCameras(cameras: Camera, unique: boolean): void;
  55064. /** @hidden */
  55065. _attachCameras(cameras: Camera[], unique: boolean): void;
  55066. /** @hidden */
  55067. _detachCameras(cameras: Camera): void;
  55068. /** @hidden */
  55069. _detachCameras(cameras: Nullable<Camera[]>): void;
  55070. /** @hidden */
  55071. _update(): void;
  55072. /** @hidden */
  55073. _reset(): void;
  55074. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55075. /**
  55076. * Disposes of the pipeline
  55077. */
  55078. dispose(): void;
  55079. }
  55080. }
  55081. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55082. import { Camera } from "babylonjs/Cameras/camera";
  55083. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55084. /**
  55085. * PostProcessRenderPipelineManager class
  55086. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55087. */
  55088. export class PostProcessRenderPipelineManager {
  55089. private _renderPipelines;
  55090. /**
  55091. * Initializes a PostProcessRenderPipelineManager
  55092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55093. */
  55094. constructor();
  55095. /**
  55096. * Gets the list of supported render pipelines
  55097. */
  55098. readonly supportedPipelines: PostProcessRenderPipeline[];
  55099. /**
  55100. * Adds a pipeline to the manager
  55101. * @param renderPipeline The pipeline to add
  55102. */
  55103. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55104. /**
  55105. * Attaches a camera to the pipeline
  55106. * @param renderPipelineName The name of the pipeline to attach to
  55107. * @param cameras the camera to attach
  55108. * @param unique if the camera can be attached multiple times to the pipeline
  55109. */
  55110. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55111. /**
  55112. * Detaches a camera from the pipeline
  55113. * @param renderPipelineName The name of the pipeline to detach from
  55114. * @param cameras the camera to detach
  55115. */
  55116. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55117. /**
  55118. * Enables an effect by name on a pipeline
  55119. * @param renderPipelineName the name of the pipeline to enable the effect in
  55120. * @param renderEffectName the name of the effect to enable
  55121. * @param cameras the cameras that the effect should be enabled on
  55122. */
  55123. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55124. /**
  55125. * Disables an effect by name on a pipeline
  55126. * @param renderPipelineName the name of the pipeline to disable the effect in
  55127. * @param renderEffectName the name of the effect to disable
  55128. * @param cameras the cameras that the effect should be disabled on
  55129. */
  55130. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55131. /**
  55132. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55133. */
  55134. update(): void;
  55135. /** @hidden */
  55136. _rebuild(): void;
  55137. /**
  55138. * Disposes of the manager and pipelines
  55139. */
  55140. dispose(): void;
  55141. }
  55142. }
  55143. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55144. import { ISceneComponent } from "babylonjs/sceneComponent";
  55145. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55146. import { Scene } from "babylonjs/scene";
  55147. module "babylonjs/scene" {
  55148. interface Scene {
  55149. /** @hidden (Backing field) */
  55150. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55151. /**
  55152. * Gets the postprocess render pipeline manager
  55153. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55154. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55155. */
  55156. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55157. }
  55158. }
  55159. /**
  55160. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55161. */
  55162. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55163. /**
  55164. * The component name helpfull to identify the component in the list of scene components.
  55165. */
  55166. readonly name: string;
  55167. /**
  55168. * The scene the component belongs to.
  55169. */
  55170. scene: Scene;
  55171. /**
  55172. * Creates a new instance of the component for the given scene
  55173. * @param scene Defines the scene to register the component in
  55174. */
  55175. constructor(scene: Scene);
  55176. /**
  55177. * Registers the component in a given scene
  55178. */
  55179. register(): void;
  55180. /**
  55181. * Rebuilds the elements related to this component in case of
  55182. * context lost for instance.
  55183. */
  55184. rebuild(): void;
  55185. /**
  55186. * Disposes the component and the associated ressources
  55187. */
  55188. dispose(): void;
  55189. private _gatherRenderTargets;
  55190. }
  55191. }
  55192. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  55193. import { IAnimatable } from "babylonjs/Misc/tools";
  55194. import { Camera } from "babylonjs/Cameras/camera";
  55195. import { IDisposable } from "babylonjs/scene";
  55196. import { Scene } from "babylonjs/scene";
  55197. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  55198. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55199. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55200. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  55201. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55202. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55203. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  55204. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55205. import { Animation } from "babylonjs/Animations/animation";
  55206. /**
  55207. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55208. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55209. */
  55210. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55211. private _scene;
  55212. private _camerasToBeAttached;
  55213. /**
  55214. * ID of the sharpen post process,
  55215. */
  55216. private readonly SharpenPostProcessId;
  55217. /**
  55218. * @ignore
  55219. * ID of the image processing post process;
  55220. */
  55221. readonly ImageProcessingPostProcessId: string;
  55222. /**
  55223. * @ignore
  55224. * ID of the Fast Approximate Anti-Aliasing post process;
  55225. */
  55226. readonly FxaaPostProcessId: string;
  55227. /**
  55228. * ID of the chromatic aberration post process,
  55229. */
  55230. private readonly ChromaticAberrationPostProcessId;
  55231. /**
  55232. * ID of the grain post process
  55233. */
  55234. private readonly GrainPostProcessId;
  55235. /**
  55236. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55237. */
  55238. sharpen: SharpenPostProcess;
  55239. private _sharpenEffect;
  55240. private bloom;
  55241. /**
  55242. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55243. */
  55244. depthOfField: DepthOfFieldEffect;
  55245. /**
  55246. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55247. */
  55248. fxaa: FxaaPostProcess;
  55249. /**
  55250. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55251. */
  55252. imageProcessing: ImageProcessingPostProcess;
  55253. /**
  55254. * Chromatic aberration post process which will shift rgb colors in the image
  55255. */
  55256. chromaticAberration: ChromaticAberrationPostProcess;
  55257. private _chromaticAberrationEffect;
  55258. /**
  55259. * Grain post process which add noise to the image
  55260. */
  55261. grain: GrainPostProcess;
  55262. private _grainEffect;
  55263. /**
  55264. * Glow post process which adds a glow to emissive areas of the image
  55265. */
  55266. private _glowLayer;
  55267. /**
  55268. * Animations which can be used to tweak settings over a period of time
  55269. */
  55270. animations: Animation[];
  55271. private _imageProcessingConfigurationObserver;
  55272. private _sharpenEnabled;
  55273. private _bloomEnabled;
  55274. private _depthOfFieldEnabled;
  55275. private _depthOfFieldBlurLevel;
  55276. private _fxaaEnabled;
  55277. private _imageProcessingEnabled;
  55278. private _defaultPipelineTextureType;
  55279. private _bloomScale;
  55280. private _chromaticAberrationEnabled;
  55281. private _grainEnabled;
  55282. private _buildAllowed;
  55283. /**
  55284. * Gets active scene
  55285. */
  55286. readonly scene: Scene;
  55287. /**
  55288. * Enable or disable the sharpen process from the pipeline
  55289. */
  55290. sharpenEnabled: boolean;
  55291. private _resizeObserver;
  55292. private _hardwareScaleLevel;
  55293. private _bloomKernel;
  55294. /**
  55295. * Specifies the size of the bloom blur kernel, relative to the final output size
  55296. */
  55297. bloomKernel: number;
  55298. /**
  55299. * Specifies the weight of the bloom in the final rendering
  55300. */
  55301. private _bloomWeight;
  55302. /**
  55303. * Specifies the luma threshold for the area that will be blurred by the bloom
  55304. */
  55305. private _bloomThreshold;
  55306. private _hdr;
  55307. /**
  55308. * The strength of the bloom.
  55309. */
  55310. bloomWeight: number;
  55311. /**
  55312. * The strength of the bloom.
  55313. */
  55314. bloomThreshold: number;
  55315. /**
  55316. * The scale of the bloom, lower value will provide better performance.
  55317. */
  55318. bloomScale: number;
  55319. /**
  55320. * Enable or disable the bloom from the pipeline
  55321. */
  55322. bloomEnabled: boolean;
  55323. private _rebuildBloom;
  55324. /**
  55325. * If the depth of field is enabled.
  55326. */
  55327. depthOfFieldEnabled: boolean;
  55328. /**
  55329. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55330. */
  55331. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55332. /**
  55333. * If the anti aliasing is enabled.
  55334. */
  55335. fxaaEnabled: boolean;
  55336. private _samples;
  55337. /**
  55338. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55339. */
  55340. samples: number;
  55341. /**
  55342. * If image processing is enabled.
  55343. */
  55344. imageProcessingEnabled: boolean;
  55345. /**
  55346. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55347. */
  55348. glowLayerEnabled: boolean;
  55349. /**
  55350. * Enable or disable the chromaticAberration process from the pipeline
  55351. */
  55352. chromaticAberrationEnabled: boolean;
  55353. /**
  55354. * Enable or disable the grain process from the pipeline
  55355. */
  55356. grainEnabled: boolean;
  55357. /**
  55358. * @constructor
  55359. * @param name - The rendering pipeline name (default: "")
  55360. * @param hdr - If high dynamic range textures should be used (default: true)
  55361. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55362. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55363. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55364. */
  55365. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55366. /**
  55367. * Get the class name
  55368. * @returns "DefaultRenderingPipeline"
  55369. */
  55370. getClassName(): string;
  55371. /**
  55372. * Force the compilation of the entire pipeline.
  55373. */
  55374. prepare(): void;
  55375. private _hasCleared;
  55376. private _prevPostProcess;
  55377. private _prevPrevPostProcess;
  55378. private _setAutoClearAndTextureSharing;
  55379. private _depthOfFieldSceneObserver;
  55380. private _buildPipeline;
  55381. private _disposePostProcesses;
  55382. /**
  55383. * Adds a camera to the pipeline
  55384. * @param camera the camera to be added
  55385. */
  55386. addCamera(camera: Camera): void;
  55387. /**
  55388. * Removes a camera from the pipeline
  55389. * @param camera the camera to remove
  55390. */
  55391. removeCamera(camera: Camera): void;
  55392. /**
  55393. * Dispose of the pipeline and stop all post processes
  55394. */
  55395. dispose(): void;
  55396. /**
  55397. * Serialize the rendering pipeline (Used when exporting)
  55398. * @returns the serialized object
  55399. */
  55400. serialize(): any;
  55401. /**
  55402. * Parse the serialized pipeline
  55403. * @param source Source pipeline.
  55404. * @param scene The scene to load the pipeline to.
  55405. * @param rootUrl The URL of the serialized pipeline.
  55406. * @returns An instantiated pipeline from the serialized object.
  55407. */
  55408. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55409. }
  55410. }
  55411. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55412. /** @hidden */
  55413. export var lensHighlightsPixelShader: {
  55414. name: string;
  55415. shader: string;
  55416. };
  55417. }
  55418. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55419. /** @hidden */
  55420. export var depthOfFieldPixelShader: {
  55421. name: string;
  55422. shader: string;
  55423. };
  55424. }
  55425. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55426. import { Camera } from "babylonjs/Cameras/camera";
  55427. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55428. import { Scene } from "babylonjs/scene";
  55429. import "babylonjs/Shaders/chromaticAberration.fragment";
  55430. import "babylonjs/Shaders/lensHighlights.fragment";
  55431. import "babylonjs/Shaders/depthOfField.fragment";
  55432. /**
  55433. * BABYLON.JS Chromatic Aberration GLSL Shader
  55434. * Author: Olivier Guyot
  55435. * Separates very slightly R, G and B colors on the edges of the screen
  55436. * Inspired by Francois Tarlier & Martins Upitis
  55437. */
  55438. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55439. /**
  55440. * @ignore
  55441. * The chromatic aberration PostProcess id in the pipeline
  55442. */
  55443. LensChromaticAberrationEffect: string;
  55444. /**
  55445. * @ignore
  55446. * The highlights enhancing PostProcess id in the pipeline
  55447. */
  55448. HighlightsEnhancingEffect: string;
  55449. /**
  55450. * @ignore
  55451. * The depth-of-field PostProcess id in the pipeline
  55452. */
  55453. LensDepthOfFieldEffect: string;
  55454. private _scene;
  55455. private _depthTexture;
  55456. private _grainTexture;
  55457. private _chromaticAberrationPostProcess;
  55458. private _highlightsPostProcess;
  55459. private _depthOfFieldPostProcess;
  55460. private _edgeBlur;
  55461. private _grainAmount;
  55462. private _chromaticAberration;
  55463. private _distortion;
  55464. private _highlightsGain;
  55465. private _highlightsThreshold;
  55466. private _dofDistance;
  55467. private _dofAperture;
  55468. private _dofDarken;
  55469. private _dofPentagon;
  55470. private _blurNoise;
  55471. /**
  55472. * @constructor
  55473. *
  55474. * Effect parameters are as follow:
  55475. * {
  55476. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55477. * edge_blur: number; // from 0 to x (1 for realism)
  55478. * distortion: number; // from 0 to x (1 for realism)
  55479. * grain_amount: number; // from 0 to 1
  55480. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55481. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55482. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55483. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55484. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55485. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55486. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55487. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55488. * }
  55489. * Note: if an effect parameter is unset, effect is disabled
  55490. *
  55491. * @param name The rendering pipeline name
  55492. * @param parameters - An object containing all parameters (see above)
  55493. * @param scene The scene linked to this pipeline
  55494. * @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)
  55495. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55496. */
  55497. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55498. /**
  55499. * Get the class name
  55500. * @returns "LensRenderingPipeline"
  55501. */
  55502. getClassName(): string;
  55503. /**
  55504. * Gets associated scene
  55505. */
  55506. readonly scene: Scene;
  55507. /**
  55508. * Gets or sets the edge blur
  55509. */
  55510. edgeBlur: number;
  55511. /**
  55512. * Gets or sets the grain amount
  55513. */
  55514. grainAmount: number;
  55515. /**
  55516. * Gets or sets the chromatic aberration amount
  55517. */
  55518. chromaticAberration: number;
  55519. /**
  55520. * Gets or sets the depth of field aperture
  55521. */
  55522. dofAperture: number;
  55523. /**
  55524. * Gets or sets the edge distortion
  55525. */
  55526. edgeDistortion: number;
  55527. /**
  55528. * Gets or sets the depth of field distortion
  55529. */
  55530. dofDistortion: number;
  55531. /**
  55532. * Gets or sets the darken out of focus amount
  55533. */
  55534. darkenOutOfFocus: number;
  55535. /**
  55536. * Gets or sets a boolean indicating if blur noise is enabled
  55537. */
  55538. blurNoise: boolean;
  55539. /**
  55540. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55541. */
  55542. pentagonBokeh: boolean;
  55543. /**
  55544. * Gets or sets the highlight grain amount
  55545. */
  55546. highlightsGain: number;
  55547. /**
  55548. * Gets or sets the highlight threshold
  55549. */
  55550. highlightsThreshold: number;
  55551. /**
  55552. * Sets the amount of blur at the edges
  55553. * @param amount blur amount
  55554. */
  55555. setEdgeBlur(amount: number): void;
  55556. /**
  55557. * Sets edge blur to 0
  55558. */
  55559. disableEdgeBlur(): void;
  55560. /**
  55561. * Sets the amout of grain
  55562. * @param amount Amount of grain
  55563. */
  55564. setGrainAmount(amount: number): void;
  55565. /**
  55566. * Set grain amount to 0
  55567. */
  55568. disableGrain(): void;
  55569. /**
  55570. * Sets the chromatic aberration amount
  55571. * @param amount amount of chromatic aberration
  55572. */
  55573. setChromaticAberration(amount: number): void;
  55574. /**
  55575. * Sets chromatic aberration amount to 0
  55576. */
  55577. disableChromaticAberration(): void;
  55578. /**
  55579. * Sets the EdgeDistortion amount
  55580. * @param amount amount of EdgeDistortion
  55581. */
  55582. setEdgeDistortion(amount: number): void;
  55583. /**
  55584. * Sets edge distortion to 0
  55585. */
  55586. disableEdgeDistortion(): void;
  55587. /**
  55588. * Sets the FocusDistance amount
  55589. * @param amount amount of FocusDistance
  55590. */
  55591. setFocusDistance(amount: number): void;
  55592. /**
  55593. * Disables depth of field
  55594. */
  55595. disableDepthOfField(): void;
  55596. /**
  55597. * Sets the Aperture amount
  55598. * @param amount amount of Aperture
  55599. */
  55600. setAperture(amount: number): void;
  55601. /**
  55602. * Sets the DarkenOutOfFocus amount
  55603. * @param amount amount of DarkenOutOfFocus
  55604. */
  55605. setDarkenOutOfFocus(amount: number): void;
  55606. private _pentagonBokehIsEnabled;
  55607. /**
  55608. * Creates a pentagon bokeh effect
  55609. */
  55610. enablePentagonBokeh(): void;
  55611. /**
  55612. * Disables the pentagon bokeh effect
  55613. */
  55614. disablePentagonBokeh(): void;
  55615. /**
  55616. * Enables noise blur
  55617. */
  55618. enableNoiseBlur(): void;
  55619. /**
  55620. * Disables noise blur
  55621. */
  55622. disableNoiseBlur(): void;
  55623. /**
  55624. * Sets the HighlightsGain amount
  55625. * @param amount amount of HighlightsGain
  55626. */
  55627. setHighlightsGain(amount: number): void;
  55628. /**
  55629. * Sets the HighlightsThreshold amount
  55630. * @param amount amount of HighlightsThreshold
  55631. */
  55632. setHighlightsThreshold(amount: number): void;
  55633. /**
  55634. * Disables highlights
  55635. */
  55636. disableHighlights(): void;
  55637. /**
  55638. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55639. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55640. */
  55641. dispose(disableDepthRender?: boolean): void;
  55642. private _createChromaticAberrationPostProcess;
  55643. private _createHighlightsPostProcess;
  55644. private _createDepthOfFieldPostProcess;
  55645. private _createGrainTexture;
  55646. }
  55647. }
  55648. declare module "babylonjs/Shaders/ssao2.fragment" {
  55649. /** @hidden */
  55650. export var ssao2PixelShader: {
  55651. name: string;
  55652. shader: string;
  55653. };
  55654. }
  55655. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55656. /** @hidden */
  55657. export var ssaoCombinePixelShader: {
  55658. name: string;
  55659. shader: string;
  55660. };
  55661. }
  55662. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55663. import { Camera } from "babylonjs/Cameras/camera";
  55664. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55665. import { Scene } from "babylonjs/scene";
  55666. import "babylonjs/Shaders/ssao2.fragment";
  55667. import "babylonjs/Shaders/ssaoCombine.fragment";
  55668. /**
  55669. * Render pipeline to produce ssao effect
  55670. */
  55671. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55672. /**
  55673. * @ignore
  55674. * The PassPostProcess id in the pipeline that contains the original scene color
  55675. */
  55676. SSAOOriginalSceneColorEffect: string;
  55677. /**
  55678. * @ignore
  55679. * The SSAO PostProcess id in the pipeline
  55680. */
  55681. SSAORenderEffect: string;
  55682. /**
  55683. * @ignore
  55684. * The horizontal blur PostProcess id in the pipeline
  55685. */
  55686. SSAOBlurHRenderEffect: string;
  55687. /**
  55688. * @ignore
  55689. * The vertical blur PostProcess id in the pipeline
  55690. */
  55691. SSAOBlurVRenderEffect: string;
  55692. /**
  55693. * @ignore
  55694. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55695. */
  55696. SSAOCombineRenderEffect: string;
  55697. /**
  55698. * The output strength of the SSAO post-process. Default value is 1.0.
  55699. */
  55700. totalStrength: number;
  55701. /**
  55702. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55703. */
  55704. maxZ: number;
  55705. /**
  55706. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55707. */
  55708. minZAspect: number;
  55709. private _samples;
  55710. /**
  55711. * Number of samples used for the SSAO calculations. Default value is 8
  55712. */
  55713. samples: number;
  55714. private _textureSamples;
  55715. /**
  55716. * Number of samples to use for antialiasing
  55717. */
  55718. textureSamples: number;
  55719. /**
  55720. * Ratio object used for SSAO ratio and blur ratio
  55721. */
  55722. private _ratio;
  55723. /**
  55724. * Dynamically generated sphere sampler.
  55725. */
  55726. private _sampleSphere;
  55727. /**
  55728. * Blur filter offsets
  55729. */
  55730. private _samplerOffsets;
  55731. private _expensiveBlur;
  55732. /**
  55733. * If bilateral blur should be used
  55734. */
  55735. expensiveBlur: boolean;
  55736. /**
  55737. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55738. */
  55739. radius: number;
  55740. /**
  55741. * The base color of the SSAO post-process
  55742. * The final result is "base + ssao" between [0, 1]
  55743. */
  55744. base: number;
  55745. /**
  55746. * Support test.
  55747. */
  55748. static readonly IsSupported: boolean;
  55749. private _scene;
  55750. private _depthTexture;
  55751. private _normalTexture;
  55752. private _randomTexture;
  55753. private _originalColorPostProcess;
  55754. private _ssaoPostProcess;
  55755. private _blurHPostProcess;
  55756. private _blurVPostProcess;
  55757. private _ssaoCombinePostProcess;
  55758. private _firstUpdate;
  55759. /**
  55760. * Gets active scene
  55761. */
  55762. readonly scene: Scene;
  55763. /**
  55764. * @constructor
  55765. * @param name The rendering pipeline name
  55766. * @param scene The scene linked to this pipeline
  55767. * @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 }
  55768. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55769. */
  55770. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55771. /**
  55772. * Get the class name
  55773. * @returns "SSAO2RenderingPipeline"
  55774. */
  55775. getClassName(): string;
  55776. /**
  55777. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55778. */
  55779. dispose(disableGeometryBufferRenderer?: boolean): void;
  55780. private _createBlurPostProcess;
  55781. /** @hidden */
  55782. _rebuild(): void;
  55783. private _bits;
  55784. private _radicalInverse_VdC;
  55785. private _hammersley;
  55786. private _hemisphereSample_uniform;
  55787. private _generateHemisphere;
  55788. private _createSSAOPostProcess;
  55789. private _createSSAOCombinePostProcess;
  55790. private _createRandomTexture;
  55791. /**
  55792. * Serialize the rendering pipeline (Used when exporting)
  55793. * @returns the serialized object
  55794. */
  55795. serialize(): any;
  55796. /**
  55797. * Parse the serialized pipeline
  55798. * @param source Source pipeline.
  55799. * @param scene The scene to load the pipeline to.
  55800. * @param rootUrl The URL of the serialized pipeline.
  55801. * @returns An instantiated pipeline from the serialized object.
  55802. */
  55803. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55804. }
  55805. }
  55806. declare module "babylonjs/Shaders/ssao.fragment" {
  55807. /** @hidden */
  55808. export var ssaoPixelShader: {
  55809. name: string;
  55810. shader: string;
  55811. };
  55812. }
  55813. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  55814. import { Camera } from "babylonjs/Cameras/camera";
  55815. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55816. import { Scene } from "babylonjs/scene";
  55817. import "babylonjs/Shaders/ssao.fragment";
  55818. import "babylonjs/Shaders/ssaoCombine.fragment";
  55819. /**
  55820. * Render pipeline to produce ssao effect
  55821. */
  55822. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55823. /**
  55824. * @ignore
  55825. * The PassPostProcess id in the pipeline that contains the original scene color
  55826. */
  55827. SSAOOriginalSceneColorEffect: string;
  55828. /**
  55829. * @ignore
  55830. * The SSAO PostProcess id in the pipeline
  55831. */
  55832. SSAORenderEffect: string;
  55833. /**
  55834. * @ignore
  55835. * The horizontal blur PostProcess id in the pipeline
  55836. */
  55837. SSAOBlurHRenderEffect: string;
  55838. /**
  55839. * @ignore
  55840. * The vertical blur PostProcess id in the pipeline
  55841. */
  55842. SSAOBlurVRenderEffect: string;
  55843. /**
  55844. * @ignore
  55845. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55846. */
  55847. SSAOCombineRenderEffect: string;
  55848. /**
  55849. * The output strength of the SSAO post-process. Default value is 1.0.
  55850. */
  55851. totalStrength: number;
  55852. /**
  55853. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55854. */
  55855. radius: number;
  55856. /**
  55857. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55858. * Must not be equal to fallOff and superior to fallOff.
  55859. * Default value is 0.0075
  55860. */
  55861. area: number;
  55862. /**
  55863. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55864. * Must not be equal to area and inferior to area.
  55865. * Default value is 0.000001
  55866. */
  55867. fallOff: number;
  55868. /**
  55869. * The base color of the SSAO post-process
  55870. * The final result is "base + ssao" between [0, 1]
  55871. */
  55872. base: number;
  55873. private _scene;
  55874. private _depthTexture;
  55875. private _randomTexture;
  55876. private _originalColorPostProcess;
  55877. private _ssaoPostProcess;
  55878. private _blurHPostProcess;
  55879. private _blurVPostProcess;
  55880. private _ssaoCombinePostProcess;
  55881. private _firstUpdate;
  55882. /**
  55883. * Gets active scene
  55884. */
  55885. readonly scene: Scene;
  55886. /**
  55887. * @constructor
  55888. * @param name - The rendering pipeline name
  55889. * @param scene - The scene linked to this pipeline
  55890. * @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 }
  55891. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55892. */
  55893. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55894. /**
  55895. * Get the class name
  55896. * @returns "SSAORenderingPipeline"
  55897. */
  55898. getClassName(): string;
  55899. /**
  55900. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55901. */
  55902. dispose(disableDepthRender?: boolean): void;
  55903. private _createBlurPostProcess;
  55904. /** @hidden */
  55905. _rebuild(): void;
  55906. private _createSSAOPostProcess;
  55907. private _createSSAOCombinePostProcess;
  55908. private _createRandomTexture;
  55909. }
  55910. }
  55911. declare module "babylonjs/Shaders/standard.fragment" {
  55912. /** @hidden */
  55913. export var standardPixelShader: {
  55914. name: string;
  55915. shader: string;
  55916. };
  55917. }
  55918. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  55919. import { Nullable } from "babylonjs/types";
  55920. import { IAnimatable } from "babylonjs/Misc/tools";
  55921. import { Camera } from "babylonjs/Cameras/camera";
  55922. import { Texture } from "babylonjs/Materials/Textures/texture";
  55923. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55924. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55925. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55926. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55927. import { IDisposable } from "babylonjs/scene";
  55928. import { SpotLight } from "babylonjs/Lights/spotLight";
  55929. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  55930. import { Scene } from "babylonjs/scene";
  55931. import { Animation } from "babylonjs/Animations/animation";
  55932. import "babylonjs/Shaders/standard.fragment";
  55933. /**
  55934. * Standard rendering pipeline
  55935. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55936. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55937. */
  55938. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55939. /**
  55940. * Public members
  55941. */
  55942. /**
  55943. * Post-process which contains the original scene color before the pipeline applies all the effects
  55944. */
  55945. originalPostProcess: Nullable<PostProcess>;
  55946. /**
  55947. * Post-process used to down scale an image x4
  55948. */
  55949. downSampleX4PostProcess: Nullable<PostProcess>;
  55950. /**
  55951. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  55952. */
  55953. brightPassPostProcess: Nullable<PostProcess>;
  55954. /**
  55955. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  55956. */
  55957. blurHPostProcesses: PostProcess[];
  55958. /**
  55959. * Post-process array storing all the vertical blur post-processes used by the pipeline
  55960. */
  55961. blurVPostProcesses: PostProcess[];
  55962. /**
  55963. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  55964. */
  55965. textureAdderPostProcess: Nullable<PostProcess>;
  55966. /**
  55967. * Post-process used to create volumetric lighting effect
  55968. */
  55969. volumetricLightPostProcess: Nullable<PostProcess>;
  55970. /**
  55971. * Post-process used to smooth the previous volumetric light post-process on the X axis
  55972. */
  55973. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  55974. /**
  55975. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  55976. */
  55977. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  55978. /**
  55979. * Post-process used to merge the volumetric light effect and the real scene color
  55980. */
  55981. volumetricLightMergePostProces: Nullable<PostProcess>;
  55982. /**
  55983. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  55984. */
  55985. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  55986. /**
  55987. * Base post-process used to calculate the average luminance of the final image for HDR
  55988. */
  55989. luminancePostProcess: Nullable<PostProcess>;
  55990. /**
  55991. * Post-processes used to create down sample post-processes in order to get
  55992. * the average luminance of the final image for HDR
  55993. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  55994. */
  55995. luminanceDownSamplePostProcesses: PostProcess[];
  55996. /**
  55997. * Post-process used to create a HDR effect (light adaptation)
  55998. */
  55999. hdrPostProcess: Nullable<PostProcess>;
  56000. /**
  56001. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56002. */
  56003. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56004. /**
  56005. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56006. */
  56007. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56008. /**
  56009. * Post-process used to merge the final HDR post-process and the real scene color
  56010. */
  56011. hdrFinalPostProcess: Nullable<PostProcess>;
  56012. /**
  56013. * Post-process used to create a lens flare effect
  56014. */
  56015. lensFlarePostProcess: Nullable<PostProcess>;
  56016. /**
  56017. * Post-process that merges the result of the lens flare post-process and the real scene color
  56018. */
  56019. lensFlareComposePostProcess: Nullable<PostProcess>;
  56020. /**
  56021. * Post-process used to create a motion blur effect
  56022. */
  56023. motionBlurPostProcess: Nullable<PostProcess>;
  56024. /**
  56025. * Post-process used to create a depth of field effect
  56026. */
  56027. depthOfFieldPostProcess: Nullable<PostProcess>;
  56028. /**
  56029. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56030. */
  56031. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56032. /**
  56033. * Represents the brightness threshold in order to configure the illuminated surfaces
  56034. */
  56035. brightThreshold: number;
  56036. /**
  56037. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56038. */
  56039. blurWidth: number;
  56040. /**
  56041. * Sets if the blur for highlighted surfaces must be only horizontal
  56042. */
  56043. horizontalBlur: boolean;
  56044. /**
  56045. * Sets the overall exposure used by the pipeline
  56046. */
  56047. exposure: number;
  56048. /**
  56049. * Texture used typically to simulate "dirty" on camera lens
  56050. */
  56051. lensTexture: Nullable<Texture>;
  56052. /**
  56053. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56054. */
  56055. volumetricLightCoefficient: number;
  56056. /**
  56057. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56058. */
  56059. volumetricLightPower: number;
  56060. /**
  56061. * Used the set the blur intensity to smooth the volumetric lights
  56062. */
  56063. volumetricLightBlurScale: number;
  56064. /**
  56065. * Light (spot or directional) used to generate the volumetric lights rays
  56066. * The source light must have a shadow generate so the pipeline can get its
  56067. * depth map
  56068. */
  56069. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56070. /**
  56071. * For eye adaptation, represents the minimum luminance the eye can see
  56072. */
  56073. hdrMinimumLuminance: number;
  56074. /**
  56075. * For eye adaptation, represents the decrease luminance speed
  56076. */
  56077. hdrDecreaseRate: number;
  56078. /**
  56079. * For eye adaptation, represents the increase luminance speed
  56080. */
  56081. hdrIncreaseRate: number;
  56082. /**
  56083. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56084. */
  56085. lensColorTexture: Nullable<Texture>;
  56086. /**
  56087. * The overall strengh for the lens flare effect
  56088. */
  56089. lensFlareStrength: number;
  56090. /**
  56091. * Dispersion coefficient for lens flare ghosts
  56092. */
  56093. lensFlareGhostDispersal: number;
  56094. /**
  56095. * Main lens flare halo width
  56096. */
  56097. lensFlareHaloWidth: number;
  56098. /**
  56099. * Based on the lens distortion effect, defines how much the lens flare result
  56100. * is distorted
  56101. */
  56102. lensFlareDistortionStrength: number;
  56103. /**
  56104. * Lens star texture must be used to simulate rays on the flares and is available
  56105. * in the documentation
  56106. */
  56107. lensStarTexture: Nullable<Texture>;
  56108. /**
  56109. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56110. * flare effect by taking account of the dirt texture
  56111. */
  56112. lensFlareDirtTexture: Nullable<Texture>;
  56113. /**
  56114. * Represents the focal length for the depth of field effect
  56115. */
  56116. depthOfFieldDistance: number;
  56117. /**
  56118. * Represents the blur intensity for the blurred part of the depth of field effect
  56119. */
  56120. depthOfFieldBlurWidth: number;
  56121. /**
  56122. * For motion blur, defines how much the image is blurred by the movement
  56123. */
  56124. motionStrength: number;
  56125. /**
  56126. * List of animations for the pipeline (IAnimatable implementation)
  56127. */
  56128. animations: Animation[];
  56129. /**
  56130. * Private members
  56131. */
  56132. private _scene;
  56133. private _currentDepthOfFieldSource;
  56134. private _basePostProcess;
  56135. private _hdrCurrentLuminance;
  56136. private _floatTextureType;
  56137. private _ratio;
  56138. private _bloomEnabled;
  56139. private _depthOfFieldEnabled;
  56140. private _vlsEnabled;
  56141. private _lensFlareEnabled;
  56142. private _hdrEnabled;
  56143. private _motionBlurEnabled;
  56144. private _fxaaEnabled;
  56145. private _motionBlurSamples;
  56146. private _volumetricLightStepsCount;
  56147. private _samples;
  56148. /**
  56149. * @ignore
  56150. * Specifies if the bloom pipeline is enabled
  56151. */
  56152. BloomEnabled: boolean;
  56153. /**
  56154. * @ignore
  56155. * Specifies if the depth of field pipeline is enabed
  56156. */
  56157. DepthOfFieldEnabled: boolean;
  56158. /**
  56159. * @ignore
  56160. * Specifies if the lens flare pipeline is enabed
  56161. */
  56162. LensFlareEnabled: boolean;
  56163. /**
  56164. * @ignore
  56165. * Specifies if the HDR pipeline is enabled
  56166. */
  56167. HDREnabled: boolean;
  56168. /**
  56169. * @ignore
  56170. * Specifies if the volumetric lights scattering effect is enabled
  56171. */
  56172. VLSEnabled: boolean;
  56173. /**
  56174. * @ignore
  56175. * Specifies if the motion blur effect is enabled
  56176. */
  56177. MotionBlurEnabled: boolean;
  56178. /**
  56179. * Specifies if anti-aliasing is enabled
  56180. */
  56181. fxaaEnabled: boolean;
  56182. /**
  56183. * Specifies the number of steps used to calculate the volumetric lights
  56184. * Typically in interval [50, 200]
  56185. */
  56186. volumetricLightStepsCount: number;
  56187. /**
  56188. * Specifies the number of samples used for the motion blur effect
  56189. * Typically in interval [16, 64]
  56190. */
  56191. motionBlurSamples: number;
  56192. /**
  56193. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56194. */
  56195. samples: number;
  56196. /**
  56197. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56198. * @constructor
  56199. * @param name The rendering pipeline name
  56200. * @param scene The scene linked to this pipeline
  56201. * @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)
  56202. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56203. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56204. */
  56205. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56206. private _buildPipeline;
  56207. private _createDownSampleX4PostProcess;
  56208. private _createBrightPassPostProcess;
  56209. private _createBlurPostProcesses;
  56210. private _createTextureAdderPostProcess;
  56211. private _createVolumetricLightPostProcess;
  56212. private _createLuminancePostProcesses;
  56213. private _createHdrPostProcess;
  56214. private _createLensFlarePostProcess;
  56215. private _createDepthOfFieldPostProcess;
  56216. private _createMotionBlurPostProcess;
  56217. private _getDepthTexture;
  56218. private _disposePostProcesses;
  56219. /**
  56220. * Dispose of the pipeline and stop all post processes
  56221. */
  56222. dispose(): void;
  56223. /**
  56224. * Serialize the rendering pipeline (Used when exporting)
  56225. * @returns the serialized object
  56226. */
  56227. serialize(): any;
  56228. /**
  56229. * Parse the serialized pipeline
  56230. * @param source Source pipeline.
  56231. * @param scene The scene to load the pipeline to.
  56232. * @param rootUrl The URL of the serialized pipeline.
  56233. * @returns An instantiated pipeline from the serialized object.
  56234. */
  56235. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56236. /**
  56237. * Luminance steps
  56238. */
  56239. static LuminanceSteps: number;
  56240. }
  56241. }
  56242. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  56243. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  56244. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  56245. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  56246. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  56247. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  56248. }
  56249. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  56250. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  56251. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56252. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56253. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56254. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56255. }
  56256. declare module "babylonjs/Shaders/tonemap.fragment" {
  56257. /** @hidden */
  56258. export var tonemapPixelShader: {
  56259. name: string;
  56260. shader: string;
  56261. };
  56262. }
  56263. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  56264. import { Camera } from "babylonjs/Cameras/camera";
  56265. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56266. import "babylonjs/Shaders/tonemap.fragment";
  56267. import { Engine } from "babylonjs/Engines/engine";
  56268. /** Defines operator used for tonemapping */
  56269. export enum TonemappingOperator {
  56270. /** Hable */
  56271. Hable = 0,
  56272. /** Reinhard */
  56273. Reinhard = 1,
  56274. /** HejiDawson */
  56275. HejiDawson = 2,
  56276. /** Photographic */
  56277. Photographic = 3
  56278. }
  56279. /**
  56280. * Defines a post process to apply tone mapping
  56281. */
  56282. export class TonemapPostProcess extends PostProcess {
  56283. private _operator;
  56284. /** Defines the required exposure adjustement */
  56285. exposureAdjustment: number;
  56286. /**
  56287. * Creates a new TonemapPostProcess
  56288. * @param name defines the name of the postprocess
  56289. * @param _operator defines the operator to use
  56290. * @param exposureAdjustment defines the required exposure adjustement
  56291. * @param camera defines the camera to use (can be null)
  56292. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56293. * @param engine defines the hosting engine (can be ignore if camera is set)
  56294. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56295. */
  56296. constructor(name: string, _operator: TonemappingOperator,
  56297. /** Defines the required exposure adjustement */
  56298. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56299. }
  56300. }
  56301. declare module "babylonjs/Shaders/depth.vertex" {
  56302. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56303. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56304. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56305. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56306. /** @hidden */
  56307. export var depthVertexShader: {
  56308. name: string;
  56309. shader: string;
  56310. };
  56311. }
  56312. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  56313. /** @hidden */
  56314. export var volumetricLightScatteringPixelShader: {
  56315. name: string;
  56316. shader: string;
  56317. };
  56318. }
  56319. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  56320. /** @hidden */
  56321. export var volumetricLightScatteringPassPixelShader: {
  56322. name: string;
  56323. shader: string;
  56324. };
  56325. }
  56326. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  56327. import { Vector3 } from "babylonjs/Maths/math";
  56328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56329. import { Mesh } from "babylonjs/Meshes/mesh";
  56330. import { Camera } from "babylonjs/Cameras/camera";
  56331. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56332. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56333. import { Scene } from "babylonjs/scene";
  56334. import "babylonjs/Meshes/Builders/planeBuilder";
  56335. import "babylonjs/Shaders/depth.vertex";
  56336. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  56337. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  56338. import { Engine } from "babylonjs/Engines/engine";
  56339. /**
  56340. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56341. */
  56342. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56343. private _volumetricLightScatteringPass;
  56344. private _volumetricLightScatteringRTT;
  56345. private _viewPort;
  56346. private _screenCoordinates;
  56347. private _cachedDefines;
  56348. /**
  56349. * If not undefined, the mesh position is computed from the attached node position
  56350. */
  56351. attachedNode: {
  56352. position: Vector3;
  56353. };
  56354. /**
  56355. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56356. */
  56357. customMeshPosition: Vector3;
  56358. /**
  56359. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56360. */
  56361. useCustomMeshPosition: boolean;
  56362. /**
  56363. * If the post-process should inverse the light scattering direction
  56364. */
  56365. invert: boolean;
  56366. /**
  56367. * The internal mesh used by the post-process
  56368. */
  56369. mesh: Mesh;
  56370. /**
  56371. * @hidden
  56372. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56373. */
  56374. useDiffuseColor: boolean;
  56375. /**
  56376. * Array containing the excluded meshes not rendered in the internal pass
  56377. */
  56378. excludedMeshes: AbstractMesh[];
  56379. /**
  56380. * Controls the overall intensity of the post-process
  56381. */
  56382. exposure: number;
  56383. /**
  56384. * Dissipates each sample's contribution in range [0, 1]
  56385. */
  56386. decay: number;
  56387. /**
  56388. * Controls the overall intensity of each sample
  56389. */
  56390. weight: number;
  56391. /**
  56392. * Controls the density of each sample
  56393. */
  56394. density: number;
  56395. /**
  56396. * @constructor
  56397. * @param name The post-process name
  56398. * @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)
  56399. * @param camera The camera that the post-process will be attached to
  56400. * @param mesh The mesh used to create the light scattering
  56401. * @param samples The post-process quality, default 100
  56402. * @param samplingModeThe post-process filtering mode
  56403. * @param engine The babylon engine
  56404. * @param reusable If the post-process is reusable
  56405. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56406. */
  56407. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56408. /**
  56409. * Returns the string "VolumetricLightScatteringPostProcess"
  56410. * @returns "VolumetricLightScatteringPostProcess"
  56411. */
  56412. getClassName(): string;
  56413. private _isReady;
  56414. /**
  56415. * Sets the new light position for light scattering effect
  56416. * @param position The new custom light position
  56417. */
  56418. setCustomMeshPosition(position: Vector3): void;
  56419. /**
  56420. * Returns the light position for light scattering effect
  56421. * @return Vector3 The custom light position
  56422. */
  56423. getCustomMeshPosition(): Vector3;
  56424. /**
  56425. * Disposes the internal assets and detaches the post-process from the camera
  56426. */
  56427. dispose(camera: Camera): void;
  56428. /**
  56429. * Returns the render target texture used by the post-process
  56430. * @return the render target texture used by the post-process
  56431. */
  56432. getPass(): RenderTargetTexture;
  56433. private _meshExcluded;
  56434. private _createPass;
  56435. private _updateMeshScreenCoordinates;
  56436. /**
  56437. * Creates a default mesh for the Volumeric Light Scattering post-process
  56438. * @param name The mesh name
  56439. * @param scene The scene where to create the mesh
  56440. * @return the default mesh
  56441. */
  56442. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56443. }
  56444. }
  56445. declare module "babylonjs/PostProcesses/index" {
  56446. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  56447. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  56448. export * from "babylonjs/PostProcesses/bloomEffect";
  56449. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  56450. export * from "babylonjs/PostProcesses/blurPostProcess";
  56451. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56452. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  56453. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  56454. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  56455. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  56456. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  56457. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  56458. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  56459. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56460. export * from "babylonjs/PostProcesses/filterPostProcess";
  56461. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  56462. export * from "babylonjs/PostProcesses/grainPostProcess";
  56463. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  56464. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56465. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  56466. export * from "babylonjs/PostProcesses/passPostProcess";
  56467. export * from "babylonjs/PostProcesses/postProcess";
  56468. export * from "babylonjs/PostProcesses/postProcessManager";
  56469. export * from "babylonjs/PostProcesses/refractionPostProcess";
  56470. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  56471. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  56472. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  56473. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  56474. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56475. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56476. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  56477. }
  56478. declare module "babylonjs/Probes/index" {
  56479. export * from "babylonjs/Probes/reflectionProbe";
  56480. }
  56481. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56482. import { Scene } from "babylonjs/scene";
  56483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56484. import { Color3 } from "babylonjs/Maths/math";
  56485. import { SmartArray } from "babylonjs/Misc/smartArray";
  56486. import { ISceneComponent } from "babylonjs/sceneComponent";
  56487. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56488. import "babylonjs/Meshes/Builders/boxBuilder";
  56489. import "babylonjs/Shaders/color.fragment";
  56490. import "babylonjs/Shaders/color.vertex";
  56491. module "babylonjs/scene" {
  56492. interface Scene {
  56493. /** @hidden (Backing field) */
  56494. _boundingBoxRenderer: BoundingBoxRenderer;
  56495. /** @hidden (Backing field) */
  56496. _forceShowBoundingBoxes: boolean;
  56497. /**
  56498. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56499. */
  56500. forceShowBoundingBoxes: boolean;
  56501. /**
  56502. * Gets the bounding box renderer associated with the scene
  56503. * @returns a BoundingBoxRenderer
  56504. */
  56505. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56506. }
  56507. }
  56508. module "babylonjs/Meshes/abstractMesh" {
  56509. interface AbstractMesh {
  56510. /** @hidden (Backing field) */
  56511. _showBoundingBox: boolean;
  56512. /**
  56513. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56514. */
  56515. showBoundingBox: boolean;
  56516. }
  56517. }
  56518. /**
  56519. * Component responsible of rendering the bounding box of the meshes in a scene.
  56520. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56521. */
  56522. export class BoundingBoxRenderer implements ISceneComponent {
  56523. /**
  56524. * The component name helpfull to identify the component in the list of scene components.
  56525. */
  56526. readonly name: string;
  56527. /**
  56528. * The scene the component belongs to.
  56529. */
  56530. scene: Scene;
  56531. /**
  56532. * Color of the bounding box lines placed in front of an object
  56533. */
  56534. frontColor: Color3;
  56535. /**
  56536. * Color of the bounding box lines placed behind an object
  56537. */
  56538. backColor: Color3;
  56539. /**
  56540. * Defines if the renderer should show the back lines or not
  56541. */
  56542. showBackLines: boolean;
  56543. /**
  56544. * @hidden
  56545. */
  56546. renderList: SmartArray<BoundingBox>;
  56547. private _colorShader;
  56548. private _vertexBuffers;
  56549. private _indexBuffer;
  56550. /**
  56551. * Instantiates a new bounding box renderer in a scene.
  56552. * @param scene the scene the renderer renders in
  56553. */
  56554. constructor(scene: Scene);
  56555. /**
  56556. * Registers the component in a given scene
  56557. */
  56558. register(): void;
  56559. private _evaluateSubMesh;
  56560. private _activeMesh;
  56561. private _prepareRessources;
  56562. private _createIndexBuffer;
  56563. /**
  56564. * Rebuilds the elements related to this component in case of
  56565. * context lost for instance.
  56566. */
  56567. rebuild(): void;
  56568. /**
  56569. * @hidden
  56570. */
  56571. reset(): void;
  56572. /**
  56573. * Render the bounding boxes of a specific rendering group
  56574. * @param renderingGroupId defines the rendering group to render
  56575. */
  56576. render(renderingGroupId: number): void;
  56577. /**
  56578. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56579. * @param mesh Define the mesh to render the occlusion bounding box for
  56580. */
  56581. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56582. /**
  56583. * Dispose and release the resources attached to this renderer.
  56584. */
  56585. dispose(): void;
  56586. }
  56587. }
  56588. declare module "babylonjs/Shaders/depth.fragment" {
  56589. /** @hidden */
  56590. export var depthPixelShader: {
  56591. name: string;
  56592. shader: string;
  56593. };
  56594. }
  56595. declare module "babylonjs/Rendering/depthRenderer" {
  56596. import { Nullable } from "babylonjs/types";
  56597. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56598. import { Scene } from "babylonjs/scene";
  56599. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56600. import { Camera } from "babylonjs/Cameras/camera";
  56601. import "babylonjs/Shaders/depth.fragment";
  56602. import "babylonjs/Shaders/depth.vertex";
  56603. /**
  56604. * This represents a depth renderer in Babylon.
  56605. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56606. */
  56607. export class DepthRenderer {
  56608. private _scene;
  56609. private _depthMap;
  56610. private _effect;
  56611. private _cachedDefines;
  56612. private _camera;
  56613. /**
  56614. * Specifiess that the depth renderer will only be used within
  56615. * the camera it is created for.
  56616. * This can help forcing its rendering during the camera processing.
  56617. */
  56618. useOnlyInActiveCamera: boolean;
  56619. /** @hidden */
  56620. static _SceneComponentInitialization: (scene: Scene) => void;
  56621. /**
  56622. * Instantiates a depth renderer
  56623. * @param scene The scene the renderer belongs to
  56624. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56625. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56626. */
  56627. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56628. /**
  56629. * Creates the depth rendering effect and checks if the effect is ready.
  56630. * @param subMesh The submesh to be used to render the depth map of
  56631. * @param useInstances If multiple world instances should be used
  56632. * @returns if the depth renderer is ready to render the depth map
  56633. */
  56634. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56635. /**
  56636. * Gets the texture which the depth map will be written to.
  56637. * @returns The depth map texture
  56638. */
  56639. getDepthMap(): RenderTargetTexture;
  56640. /**
  56641. * Disposes of the depth renderer.
  56642. */
  56643. dispose(): void;
  56644. }
  56645. }
  56646. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56647. import { Nullable } from "babylonjs/types";
  56648. import { Scene } from "babylonjs/scene";
  56649. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56650. import { Camera } from "babylonjs/Cameras/camera";
  56651. import { ISceneComponent } from "babylonjs/sceneComponent";
  56652. module "babylonjs/scene" {
  56653. interface Scene {
  56654. /** @hidden (Backing field) */
  56655. _depthRenderer: {
  56656. [id: string]: DepthRenderer;
  56657. };
  56658. /**
  56659. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56660. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56661. * @returns the created depth renderer
  56662. */
  56663. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56664. /**
  56665. * Disables a depth renderer for a given camera
  56666. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56667. */
  56668. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56669. }
  56670. }
  56671. /**
  56672. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56673. * in several rendering techniques.
  56674. */
  56675. export class DepthRendererSceneComponent implements ISceneComponent {
  56676. /**
  56677. * The component name helpfull to identify the component in the list of scene components.
  56678. */
  56679. readonly name: string;
  56680. /**
  56681. * The scene the component belongs to.
  56682. */
  56683. scene: Scene;
  56684. /**
  56685. * Creates a new instance of the component for the given scene
  56686. * @param scene Defines the scene to register the component in
  56687. */
  56688. constructor(scene: Scene);
  56689. /**
  56690. * Registers the component in a given scene
  56691. */
  56692. register(): void;
  56693. /**
  56694. * Rebuilds the elements related to this component in case of
  56695. * context lost for instance.
  56696. */
  56697. rebuild(): void;
  56698. /**
  56699. * Disposes the component and the associated ressources
  56700. */
  56701. dispose(): void;
  56702. private _gatherRenderTargets;
  56703. private _gatherActiveCameraRenderTargets;
  56704. }
  56705. }
  56706. declare module "babylonjs/Shaders/outline.fragment" {
  56707. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56708. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56709. /** @hidden */
  56710. export var outlinePixelShader: {
  56711. name: string;
  56712. shader: string;
  56713. };
  56714. }
  56715. declare module "babylonjs/Shaders/outline.vertex" {
  56716. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56717. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56718. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56719. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56720. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56721. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56722. /** @hidden */
  56723. export var outlineVertexShader: {
  56724. name: string;
  56725. shader: string;
  56726. };
  56727. }
  56728. declare module "babylonjs/Rendering/outlineRenderer" {
  56729. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56730. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  56731. import { Scene } from "babylonjs/scene";
  56732. import { ISceneComponent } from "babylonjs/sceneComponent";
  56733. import "babylonjs/Shaders/outline.fragment";
  56734. import "babylonjs/Shaders/outline.vertex";
  56735. module "babylonjs/scene" {
  56736. interface Scene {
  56737. /** @hidden */
  56738. _outlineRenderer: OutlineRenderer;
  56739. /**
  56740. * Gets the outline renderer associated with the scene
  56741. * @returns a OutlineRenderer
  56742. */
  56743. getOutlineRenderer(): OutlineRenderer;
  56744. }
  56745. }
  56746. module "babylonjs/Meshes/abstractMesh" {
  56747. interface AbstractMesh {
  56748. /** @hidden (Backing field) */
  56749. _renderOutline: boolean;
  56750. /**
  56751. * Gets or sets a boolean indicating if the outline must be rendered as well
  56752. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56753. */
  56754. renderOutline: boolean;
  56755. /** @hidden (Backing field) */
  56756. _renderOverlay: boolean;
  56757. /**
  56758. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56759. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56760. */
  56761. renderOverlay: boolean;
  56762. }
  56763. }
  56764. /**
  56765. * This class is responsible to draw bothe outline/overlay of meshes.
  56766. * It should not be used directly but through the available method on mesh.
  56767. */
  56768. export class OutlineRenderer implements ISceneComponent {
  56769. /**
  56770. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  56771. */
  56772. private static _StencilReference;
  56773. /**
  56774. * The name of the component. Each component must have a unique name.
  56775. */
  56776. name: string;
  56777. /**
  56778. * The scene the component belongs to.
  56779. */
  56780. scene: Scene;
  56781. /**
  56782. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56783. */
  56784. zOffset: number;
  56785. private _engine;
  56786. private _effect;
  56787. private _cachedDefines;
  56788. private _savedDepthWrite;
  56789. /**
  56790. * Instantiates a new outline renderer. (There could be only one per scene).
  56791. * @param scene Defines the scene it belongs to
  56792. */
  56793. constructor(scene: Scene);
  56794. /**
  56795. * Register the component to one instance of a scene.
  56796. */
  56797. register(): void;
  56798. /**
  56799. * Rebuilds the elements related to this component in case of
  56800. * context lost for instance.
  56801. */
  56802. rebuild(): void;
  56803. /**
  56804. * Disposes the component and the associated ressources.
  56805. */
  56806. dispose(): void;
  56807. /**
  56808. * Renders the outline in the canvas.
  56809. * @param subMesh Defines the sumesh to render
  56810. * @param batch Defines the batch of meshes in case of instances
  56811. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56812. */
  56813. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56814. /**
  56815. * Returns whether or not the outline renderer is ready for a given submesh.
  56816. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56817. * @param subMesh Defines the submesh to check readyness for
  56818. * @param useInstances Defines wheter wee are trying to render instances or not
  56819. * @returns true if ready otherwise false
  56820. */
  56821. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56822. private _beforeRenderingMesh;
  56823. private _afterRenderingMesh;
  56824. }
  56825. }
  56826. declare module "babylonjs/Rendering/index" {
  56827. export * from "babylonjs/Rendering/boundingBoxRenderer";
  56828. export * from "babylonjs/Rendering/depthRenderer";
  56829. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  56830. export * from "babylonjs/Rendering/edgesRenderer";
  56831. export * from "babylonjs/Rendering/geometryBufferRenderer";
  56832. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  56833. export * from "babylonjs/Rendering/outlineRenderer";
  56834. export * from "babylonjs/Rendering/renderingGroup";
  56835. export * from "babylonjs/Rendering/renderingManager";
  56836. export * from "babylonjs/Rendering/utilityLayerRenderer";
  56837. }
  56838. declare module "babylonjs/Sprites/index" {
  56839. export * from "babylonjs/Sprites/sprite";
  56840. export * from "babylonjs/Sprites/spriteManager";
  56841. export * from "babylonjs/Sprites/spriteSceneComponent";
  56842. }
  56843. declare module "babylonjs/Misc/assetsManager" {
  56844. import { Scene } from "babylonjs/scene";
  56845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56846. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56847. import { Skeleton } from "babylonjs/Bones/skeleton";
  56848. import { Observable } from "babylonjs/Misc/observable";
  56849. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56850. import { Texture } from "babylonjs/Materials/Textures/texture";
  56851. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56852. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  56853. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  56854. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56855. /**
  56856. * Defines the list of states available for a task inside a AssetsManager
  56857. */
  56858. export enum AssetTaskState {
  56859. /**
  56860. * Initialization
  56861. */
  56862. INIT = 0,
  56863. /**
  56864. * Running
  56865. */
  56866. RUNNING = 1,
  56867. /**
  56868. * Done
  56869. */
  56870. DONE = 2,
  56871. /**
  56872. * Error
  56873. */
  56874. ERROR = 3
  56875. }
  56876. /**
  56877. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56878. */
  56879. export abstract class AbstractAssetTask {
  56880. /**
  56881. * Task name
  56882. */ name: string;
  56883. /**
  56884. * Callback called when the task is successful
  56885. */
  56886. onSuccess: (task: any) => void;
  56887. /**
  56888. * Callback called when the task is not successful
  56889. */
  56890. onError: (task: any, message?: string, exception?: any) => void;
  56891. /**
  56892. * Creates a new AssetsManager
  56893. * @param name defines the name of the task
  56894. */
  56895. constructor(
  56896. /**
  56897. * Task name
  56898. */ name: string);
  56899. private _isCompleted;
  56900. private _taskState;
  56901. private _errorObject;
  56902. /**
  56903. * Get if the task is completed
  56904. */
  56905. readonly isCompleted: boolean;
  56906. /**
  56907. * Gets the current state of the task
  56908. */
  56909. readonly taskState: AssetTaskState;
  56910. /**
  56911. * Gets the current error object (if task is in error)
  56912. */
  56913. readonly errorObject: {
  56914. message?: string;
  56915. exception?: any;
  56916. };
  56917. /**
  56918. * Internal only
  56919. * @hidden
  56920. */
  56921. _setErrorObject(message?: string, exception?: any): void;
  56922. /**
  56923. * Execute the current task
  56924. * @param scene defines the scene where you want your assets to be loaded
  56925. * @param onSuccess is a callback called when the task is successfully executed
  56926. * @param onError is a callback called if an error occurs
  56927. */
  56928. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56929. /**
  56930. * Execute the current task
  56931. * @param scene defines the scene where you want your assets to be loaded
  56932. * @param onSuccess is a callback called when the task is successfully executed
  56933. * @param onError is a callback called if an error occurs
  56934. */
  56935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56936. /**
  56937. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56938. * This can be used with failed tasks that have the reason for failure fixed.
  56939. */
  56940. reset(): void;
  56941. private onErrorCallback;
  56942. private onDoneCallback;
  56943. }
  56944. /**
  56945. * Define the interface used by progress events raised during assets loading
  56946. */
  56947. export interface IAssetsProgressEvent {
  56948. /**
  56949. * Defines the number of remaining tasks to process
  56950. */
  56951. remainingCount: number;
  56952. /**
  56953. * Defines the total number of tasks
  56954. */
  56955. totalCount: number;
  56956. /**
  56957. * Defines the task that was just processed
  56958. */
  56959. task: AbstractAssetTask;
  56960. }
  56961. /**
  56962. * Class used to share progress information about assets loading
  56963. */
  56964. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56965. /**
  56966. * Defines the number of remaining tasks to process
  56967. */
  56968. remainingCount: number;
  56969. /**
  56970. * Defines the total number of tasks
  56971. */
  56972. totalCount: number;
  56973. /**
  56974. * Defines the task that was just processed
  56975. */
  56976. task: AbstractAssetTask;
  56977. /**
  56978. * Creates a AssetsProgressEvent
  56979. * @param remainingCount defines the number of remaining tasks to process
  56980. * @param totalCount defines the total number of tasks
  56981. * @param task defines the task that was just processed
  56982. */
  56983. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56984. }
  56985. /**
  56986. * Define a task used by AssetsManager to load meshes
  56987. */
  56988. export class MeshAssetTask extends AbstractAssetTask {
  56989. /**
  56990. * Defines the name of the task
  56991. */
  56992. name: string;
  56993. /**
  56994. * Defines the list of mesh's names you want to load
  56995. */
  56996. meshesNames: any;
  56997. /**
  56998. * Defines the root url to use as a base to load your meshes and associated resources
  56999. */
  57000. rootUrl: string;
  57001. /**
  57002. * Defines the filename of the scene to load from
  57003. */
  57004. sceneFilename: string;
  57005. /**
  57006. * Gets the list of loaded meshes
  57007. */
  57008. loadedMeshes: Array<AbstractMesh>;
  57009. /**
  57010. * Gets the list of loaded particle systems
  57011. */
  57012. loadedParticleSystems: Array<IParticleSystem>;
  57013. /**
  57014. * Gets the list of loaded skeletons
  57015. */
  57016. loadedSkeletons: Array<Skeleton>;
  57017. /**
  57018. * Gets the list of loaded animation groups
  57019. */
  57020. loadedAnimationGroups: Array<AnimationGroup>;
  57021. /**
  57022. * Callback called when the task is successful
  57023. */
  57024. onSuccess: (task: MeshAssetTask) => void;
  57025. /**
  57026. * Callback called when the task is successful
  57027. */
  57028. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57029. /**
  57030. * Creates a new MeshAssetTask
  57031. * @param name defines the name of the task
  57032. * @param meshesNames defines the list of mesh's names you want to load
  57033. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57034. * @param sceneFilename defines the filename of the scene to load from
  57035. */
  57036. constructor(
  57037. /**
  57038. * Defines the name of the task
  57039. */
  57040. name: string,
  57041. /**
  57042. * Defines the list of mesh's names you want to load
  57043. */
  57044. meshesNames: any,
  57045. /**
  57046. * Defines the root url to use as a base to load your meshes and associated resources
  57047. */
  57048. rootUrl: string,
  57049. /**
  57050. * Defines the filename of the scene to load from
  57051. */
  57052. sceneFilename: string);
  57053. /**
  57054. * Execute the current task
  57055. * @param scene defines the scene where you want your assets to be loaded
  57056. * @param onSuccess is a callback called when the task is successfully executed
  57057. * @param onError is a callback called if an error occurs
  57058. */
  57059. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57060. }
  57061. /**
  57062. * Define a task used by AssetsManager to load text content
  57063. */
  57064. export class TextFileAssetTask extends AbstractAssetTask {
  57065. /**
  57066. * Defines the name of the task
  57067. */
  57068. name: string;
  57069. /**
  57070. * Defines the location of the file to load
  57071. */
  57072. url: string;
  57073. /**
  57074. * Gets the loaded text string
  57075. */
  57076. text: string;
  57077. /**
  57078. * Callback called when the task is successful
  57079. */
  57080. onSuccess: (task: TextFileAssetTask) => void;
  57081. /**
  57082. * Callback called when the task is successful
  57083. */
  57084. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57085. /**
  57086. * Creates a new TextFileAssetTask object
  57087. * @param name defines the name of the task
  57088. * @param url defines the location of the file to load
  57089. */
  57090. constructor(
  57091. /**
  57092. * Defines the name of the task
  57093. */
  57094. name: string,
  57095. /**
  57096. * Defines the location of the file to load
  57097. */
  57098. url: string);
  57099. /**
  57100. * Execute the current task
  57101. * @param scene defines the scene where you want your assets to be loaded
  57102. * @param onSuccess is a callback called when the task is successfully executed
  57103. * @param onError is a callback called if an error occurs
  57104. */
  57105. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57106. }
  57107. /**
  57108. * Define a task used by AssetsManager to load binary data
  57109. */
  57110. export class BinaryFileAssetTask extends AbstractAssetTask {
  57111. /**
  57112. * Defines the name of the task
  57113. */
  57114. name: string;
  57115. /**
  57116. * Defines the location of the file to load
  57117. */
  57118. url: string;
  57119. /**
  57120. * Gets the lodaded data (as an array buffer)
  57121. */
  57122. data: ArrayBuffer;
  57123. /**
  57124. * Callback called when the task is successful
  57125. */
  57126. onSuccess: (task: BinaryFileAssetTask) => void;
  57127. /**
  57128. * Callback called when the task is successful
  57129. */
  57130. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57131. /**
  57132. * Creates a new BinaryFileAssetTask object
  57133. * @param name defines the name of the new task
  57134. * @param url defines the location of the file to load
  57135. */
  57136. constructor(
  57137. /**
  57138. * Defines the name of the task
  57139. */
  57140. name: string,
  57141. /**
  57142. * Defines the location of the file to load
  57143. */
  57144. url: string);
  57145. /**
  57146. * Execute the current task
  57147. * @param scene defines the scene where you want your assets to be loaded
  57148. * @param onSuccess is a callback called when the task is successfully executed
  57149. * @param onError is a callback called if an error occurs
  57150. */
  57151. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57152. }
  57153. /**
  57154. * Define a task used by AssetsManager to load images
  57155. */
  57156. export class ImageAssetTask extends AbstractAssetTask {
  57157. /**
  57158. * Defines the name of the task
  57159. */
  57160. name: string;
  57161. /**
  57162. * Defines the location of the image to load
  57163. */
  57164. url: string;
  57165. /**
  57166. * Gets the loaded images
  57167. */
  57168. image: HTMLImageElement;
  57169. /**
  57170. * Callback called when the task is successful
  57171. */
  57172. onSuccess: (task: ImageAssetTask) => void;
  57173. /**
  57174. * Callback called when the task is successful
  57175. */
  57176. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57177. /**
  57178. * Creates a new ImageAssetTask
  57179. * @param name defines the name of the task
  57180. * @param url defines the location of the image to load
  57181. */
  57182. constructor(
  57183. /**
  57184. * Defines the name of the task
  57185. */
  57186. name: string,
  57187. /**
  57188. * Defines the location of the image to load
  57189. */
  57190. url: string);
  57191. /**
  57192. * Execute the current task
  57193. * @param scene defines the scene where you want your assets to be loaded
  57194. * @param onSuccess is a callback called when the task is successfully executed
  57195. * @param onError is a callback called if an error occurs
  57196. */
  57197. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57198. }
  57199. /**
  57200. * Defines the interface used by texture loading tasks
  57201. */
  57202. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57203. /**
  57204. * Gets the loaded texture
  57205. */
  57206. texture: TEX;
  57207. }
  57208. /**
  57209. * Define a task used by AssetsManager to load 2D textures
  57210. */
  57211. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57212. /**
  57213. * Defines the name of the task
  57214. */
  57215. name: string;
  57216. /**
  57217. * Defines the location of the file to load
  57218. */
  57219. url: string;
  57220. /**
  57221. * Defines if mipmap should not be generated (default is false)
  57222. */
  57223. noMipmap?: boolean | undefined;
  57224. /**
  57225. * Defines if texture must be inverted on Y axis (default is false)
  57226. */
  57227. invertY?: boolean | undefined;
  57228. /**
  57229. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57230. */
  57231. samplingMode: number;
  57232. /**
  57233. * Gets the loaded texture
  57234. */
  57235. texture: Texture;
  57236. /**
  57237. * Callback called when the task is successful
  57238. */
  57239. onSuccess: (task: TextureAssetTask) => void;
  57240. /**
  57241. * Callback called when the task is successful
  57242. */
  57243. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57244. /**
  57245. * Creates a new TextureAssetTask object
  57246. * @param name defines the name of the task
  57247. * @param url defines the location of the file to load
  57248. * @param noMipmap defines if mipmap should not be generated (default is false)
  57249. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57250. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57251. */
  57252. constructor(
  57253. /**
  57254. * Defines the name of the task
  57255. */
  57256. name: string,
  57257. /**
  57258. * Defines the location of the file to load
  57259. */
  57260. url: string,
  57261. /**
  57262. * Defines if mipmap should not be generated (default is false)
  57263. */
  57264. noMipmap?: boolean | undefined,
  57265. /**
  57266. * Defines if texture must be inverted on Y axis (default is false)
  57267. */
  57268. invertY?: boolean | undefined,
  57269. /**
  57270. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57271. */
  57272. samplingMode?: number);
  57273. /**
  57274. * Execute the current task
  57275. * @param scene defines the scene where you want your assets to be loaded
  57276. * @param onSuccess is a callback called when the task is successfully executed
  57277. * @param onError is a callback called if an error occurs
  57278. */
  57279. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57280. }
  57281. /**
  57282. * Define a task used by AssetsManager to load cube textures
  57283. */
  57284. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57285. /**
  57286. * Defines the name of the task
  57287. */
  57288. name: string;
  57289. /**
  57290. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57291. */
  57292. url: string;
  57293. /**
  57294. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57295. */
  57296. extensions?: string[] | undefined;
  57297. /**
  57298. * Defines if mipmaps should not be generated (default is false)
  57299. */
  57300. noMipmap?: boolean | undefined;
  57301. /**
  57302. * Defines the explicit list of files (undefined by default)
  57303. */
  57304. files?: string[] | undefined;
  57305. /**
  57306. * Gets the loaded texture
  57307. */
  57308. texture: CubeTexture;
  57309. /**
  57310. * Callback called when the task is successful
  57311. */
  57312. onSuccess: (task: CubeTextureAssetTask) => void;
  57313. /**
  57314. * Callback called when the task is successful
  57315. */
  57316. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57317. /**
  57318. * Creates a new CubeTextureAssetTask
  57319. * @param name defines the name of the task
  57320. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57321. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57322. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57323. * @param files defines the explicit list of files (undefined by default)
  57324. */
  57325. constructor(
  57326. /**
  57327. * Defines the name of the task
  57328. */
  57329. name: string,
  57330. /**
  57331. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57332. */
  57333. url: string,
  57334. /**
  57335. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57336. */
  57337. extensions?: string[] | undefined,
  57338. /**
  57339. * Defines if mipmaps should not be generated (default is false)
  57340. */
  57341. noMipmap?: boolean | undefined,
  57342. /**
  57343. * Defines the explicit list of files (undefined by default)
  57344. */
  57345. files?: string[] | undefined);
  57346. /**
  57347. * Execute the current task
  57348. * @param scene defines the scene where you want your assets to be loaded
  57349. * @param onSuccess is a callback called when the task is successfully executed
  57350. * @param onError is a callback called if an error occurs
  57351. */
  57352. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57353. }
  57354. /**
  57355. * Define a task used by AssetsManager to load HDR cube textures
  57356. */
  57357. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57358. /**
  57359. * Defines the name of the task
  57360. */
  57361. name: string;
  57362. /**
  57363. * Defines the location of the file to load
  57364. */
  57365. url: string;
  57366. /**
  57367. * Defines the desired size (the more it increases the longer the generation will be)
  57368. */
  57369. size: number;
  57370. /**
  57371. * Defines if mipmaps should not be generated (default is false)
  57372. */
  57373. noMipmap: boolean;
  57374. /**
  57375. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57376. */
  57377. generateHarmonics: boolean;
  57378. /**
  57379. * 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)
  57380. */
  57381. gammaSpace: boolean;
  57382. /**
  57383. * Internal Use Only
  57384. */
  57385. reserved: boolean;
  57386. /**
  57387. * Gets the loaded texture
  57388. */
  57389. texture: HDRCubeTexture;
  57390. /**
  57391. * Callback called when the task is successful
  57392. */
  57393. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57394. /**
  57395. * Callback called when the task is successful
  57396. */
  57397. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57398. /**
  57399. * Creates a new HDRCubeTextureAssetTask object
  57400. * @param name defines the name of the task
  57401. * @param url defines the location of the file to load
  57402. * @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.
  57403. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57404. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57405. * @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)
  57406. * @param reserved Internal use only
  57407. */
  57408. constructor(
  57409. /**
  57410. * Defines the name of the task
  57411. */
  57412. name: string,
  57413. /**
  57414. * Defines the location of the file to load
  57415. */
  57416. url: string,
  57417. /**
  57418. * Defines the desired size (the more it increases the longer the generation will be)
  57419. */
  57420. size: number,
  57421. /**
  57422. * Defines if mipmaps should not be generated (default is false)
  57423. */
  57424. noMipmap?: boolean,
  57425. /**
  57426. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57427. */
  57428. generateHarmonics?: boolean,
  57429. /**
  57430. * 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)
  57431. */
  57432. gammaSpace?: boolean,
  57433. /**
  57434. * Internal Use Only
  57435. */
  57436. reserved?: boolean);
  57437. /**
  57438. * Execute the current task
  57439. * @param scene defines the scene where you want your assets to be loaded
  57440. * @param onSuccess is a callback called when the task is successfully executed
  57441. * @param onError is a callback called if an error occurs
  57442. */
  57443. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57444. }
  57445. /**
  57446. * Define a task used by AssetsManager to load Equirectangular cube textures
  57447. */
  57448. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57449. /**
  57450. * Defines the name of the task
  57451. */
  57452. name: string;
  57453. /**
  57454. * Defines the location of the file to load
  57455. */
  57456. url: string;
  57457. /**
  57458. * Defines the desired size (the more it increases the longer the generation will be)
  57459. */
  57460. size: number;
  57461. /**
  57462. * Defines if mipmaps should not be generated (default is false)
  57463. */
  57464. noMipmap: boolean;
  57465. /**
  57466. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57467. * but the standard material would require them in Gamma space) (default is true)
  57468. */
  57469. gammaSpace: boolean;
  57470. /**
  57471. * Gets the loaded texture
  57472. */
  57473. texture: EquiRectangularCubeTexture;
  57474. /**
  57475. * Callback called when the task is successful
  57476. */
  57477. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57478. /**
  57479. * Callback called when the task is successful
  57480. */
  57481. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57482. /**
  57483. * Creates a new EquiRectangularCubeTextureAssetTask object
  57484. * @param name defines the name of the task
  57485. * @param url defines the location of the file to load
  57486. * @param size defines the desired size (the more it increases the longer the generation will be)
  57487. * If the size is omitted this implies you are using a preprocessed cubemap.
  57488. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57489. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57490. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57491. * (default is true)
  57492. */
  57493. constructor(
  57494. /**
  57495. * Defines the name of the task
  57496. */
  57497. name: string,
  57498. /**
  57499. * Defines the location of the file to load
  57500. */
  57501. url: string,
  57502. /**
  57503. * Defines the desired size (the more it increases the longer the generation will be)
  57504. */
  57505. size: number,
  57506. /**
  57507. * Defines if mipmaps should not be generated (default is false)
  57508. */
  57509. noMipmap?: boolean,
  57510. /**
  57511. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57512. * but the standard material would require them in Gamma space) (default is true)
  57513. */
  57514. gammaSpace?: boolean);
  57515. /**
  57516. * Execute the current task
  57517. * @param scene defines the scene where you want your assets to be loaded
  57518. * @param onSuccess is a callback called when the task is successfully executed
  57519. * @param onError is a callback called if an error occurs
  57520. */
  57521. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57522. }
  57523. /**
  57524. * This class can be used to easily import assets into a scene
  57525. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57526. */
  57527. export class AssetsManager {
  57528. private _scene;
  57529. private _isLoading;
  57530. protected _tasks: AbstractAssetTask[];
  57531. protected _waitingTasksCount: number;
  57532. protected _totalTasksCount: number;
  57533. /**
  57534. * Callback called when all tasks are processed
  57535. */
  57536. onFinish: (tasks: AbstractAssetTask[]) => void;
  57537. /**
  57538. * Callback called when a task is successful
  57539. */
  57540. onTaskSuccess: (task: AbstractAssetTask) => void;
  57541. /**
  57542. * Callback called when a task had an error
  57543. */
  57544. onTaskError: (task: AbstractAssetTask) => void;
  57545. /**
  57546. * Callback called when a task is done (whatever the result is)
  57547. */
  57548. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57549. /**
  57550. * Observable called when all tasks are processed
  57551. */
  57552. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57553. /**
  57554. * Observable called when a task had an error
  57555. */
  57556. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57557. /**
  57558. * Observable called when all tasks were executed
  57559. */
  57560. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57561. /**
  57562. * Observable called when a task is done (whatever the result is)
  57563. */
  57564. onProgressObservable: Observable<IAssetsProgressEvent>;
  57565. /**
  57566. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57567. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57568. */
  57569. useDefaultLoadingScreen: boolean;
  57570. /**
  57571. * Creates a new AssetsManager
  57572. * @param scene defines the scene to work on
  57573. */
  57574. constructor(scene: Scene);
  57575. /**
  57576. * Add a MeshAssetTask to the list of active tasks
  57577. * @param taskName defines the name of the new task
  57578. * @param meshesNames defines the name of meshes to load
  57579. * @param rootUrl defines the root url to use to locate files
  57580. * @param sceneFilename defines the filename of the scene file
  57581. * @returns a new MeshAssetTask object
  57582. */
  57583. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57584. /**
  57585. * Add a TextFileAssetTask to the list of active tasks
  57586. * @param taskName defines the name of the new task
  57587. * @param url defines the url of the file to load
  57588. * @returns a new TextFileAssetTask object
  57589. */
  57590. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57591. /**
  57592. * Add a BinaryFileAssetTask to the list of active tasks
  57593. * @param taskName defines the name of the new task
  57594. * @param url defines the url of the file to load
  57595. * @returns a new BinaryFileAssetTask object
  57596. */
  57597. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57598. /**
  57599. * Add a ImageAssetTask to the list of active tasks
  57600. * @param taskName defines the name of the new task
  57601. * @param url defines the url of the file to load
  57602. * @returns a new ImageAssetTask object
  57603. */
  57604. addImageTask(taskName: string, url: string): ImageAssetTask;
  57605. /**
  57606. * Add a TextureAssetTask to the list of active tasks
  57607. * @param taskName defines the name of the new task
  57608. * @param url defines the url of the file to load
  57609. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57610. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57611. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57612. * @returns a new TextureAssetTask object
  57613. */
  57614. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57615. /**
  57616. * Add a CubeTextureAssetTask to the list of active tasks
  57617. * @param taskName defines the name of the new task
  57618. * @param url defines the url of the file to load
  57619. * @param extensions defines the extension to use to load the cube map (can be null)
  57620. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57621. * @param files defines the list of files to load (can be null)
  57622. * @returns a new CubeTextureAssetTask object
  57623. */
  57624. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57625. /**
  57626. *
  57627. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57628. * @param taskName defines the name of the new task
  57629. * @param url defines the url of the file to load
  57630. * @param size defines the size you want for the cubemap (can be null)
  57631. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57632. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57633. * @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)
  57634. * @param reserved Internal use only
  57635. * @returns a new HDRCubeTextureAssetTask object
  57636. */
  57637. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57638. /**
  57639. *
  57640. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57641. * @param taskName defines the name of the new task
  57642. * @param url defines the url of the file to load
  57643. * @param size defines the size you want for the cubemap (can be null)
  57644. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57645. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57646. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57647. * @returns a new EquiRectangularCubeTextureAssetTask object
  57648. */
  57649. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57650. /**
  57651. * Remove a task from the assets manager.
  57652. * @param task the task to remove
  57653. */
  57654. removeTask(task: AbstractAssetTask): void;
  57655. private _decreaseWaitingTasksCount;
  57656. private _runTask;
  57657. /**
  57658. * Reset the AssetsManager and remove all tasks
  57659. * @return the current instance of the AssetsManager
  57660. */
  57661. reset(): AssetsManager;
  57662. /**
  57663. * Start the loading process
  57664. * @return the current instance of the AssetsManager
  57665. */
  57666. load(): AssetsManager;
  57667. /**
  57668. * Start the loading process as an async operation
  57669. * @return a promise returning the list of failed tasks
  57670. */
  57671. loadAsync(): Promise<void>;
  57672. }
  57673. }
  57674. declare module "babylonjs/Misc/deferred" {
  57675. /**
  57676. * Wrapper class for promise with external resolve and reject.
  57677. */
  57678. export class Deferred<T> {
  57679. /**
  57680. * The promise associated with this deferred object.
  57681. */
  57682. readonly promise: Promise<T>;
  57683. private _resolve;
  57684. private _reject;
  57685. /**
  57686. * The resolve method of the promise associated with this deferred object.
  57687. */
  57688. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57689. /**
  57690. * The reject method of the promise associated with this deferred object.
  57691. */
  57692. readonly reject: (reason?: any) => void;
  57693. /**
  57694. * Constructor for this deferred object.
  57695. */
  57696. constructor();
  57697. }
  57698. }
  57699. declare module "babylonjs/Misc/meshExploder" {
  57700. import { Mesh } from "babylonjs/Meshes/mesh";
  57701. /**
  57702. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57703. */
  57704. export class MeshExploder {
  57705. private _centerMesh;
  57706. private _meshes;
  57707. private _meshesOrigins;
  57708. private _toCenterVectors;
  57709. private _scaledDirection;
  57710. private _newPosition;
  57711. private _centerPosition;
  57712. /**
  57713. * Explodes meshes from a center mesh.
  57714. * @param meshes The meshes to explode.
  57715. * @param centerMesh The mesh to be center of explosion.
  57716. */
  57717. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57718. private _setCenterMesh;
  57719. /**
  57720. * Get class name
  57721. * @returns "MeshExploder"
  57722. */
  57723. getClassName(): string;
  57724. /**
  57725. * "Exploded meshes"
  57726. * @returns Array of meshes with the centerMesh at index 0.
  57727. */
  57728. getMeshes(): Array<Mesh>;
  57729. /**
  57730. * Explodes meshes giving a specific direction
  57731. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57732. */
  57733. explode(direction?: number): void;
  57734. }
  57735. }
  57736. declare module "babylonjs/Misc/filesInput" {
  57737. import { Engine } from "babylonjs/Engines/engine";
  57738. import { Scene } from "babylonjs/scene";
  57739. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  57740. /**
  57741. * Class used to help managing file picking and drag'n'drop
  57742. */
  57743. export class FilesInput {
  57744. /**
  57745. * List of files ready to be loaded
  57746. */
  57747. static readonly FilesToLoad: {
  57748. [key: string]: File;
  57749. };
  57750. /**
  57751. * Callback called when a file is processed
  57752. */
  57753. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57754. private _engine;
  57755. private _currentScene;
  57756. private _sceneLoadedCallback;
  57757. private _progressCallback;
  57758. private _additionalRenderLoopLogicCallback;
  57759. private _textureLoadingCallback;
  57760. private _startingProcessingFilesCallback;
  57761. private _onReloadCallback;
  57762. private _errorCallback;
  57763. private _elementToMonitor;
  57764. private _sceneFileToLoad;
  57765. private _filesToLoad;
  57766. /**
  57767. * Creates a new FilesInput
  57768. * @param engine defines the rendering engine
  57769. * @param scene defines the hosting scene
  57770. * @param sceneLoadedCallback callback called when scene is loaded
  57771. * @param progressCallback callback called to track progress
  57772. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57773. * @param textureLoadingCallback callback called when a texture is loading
  57774. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57775. * @param onReloadCallback callback called when a reload is requested
  57776. * @param errorCallback callback call if an error occurs
  57777. */
  57778. 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);
  57779. private _dragEnterHandler;
  57780. private _dragOverHandler;
  57781. private _dropHandler;
  57782. /**
  57783. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57784. * @param elementToMonitor defines the DOM element to track
  57785. */
  57786. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57787. /**
  57788. * Release all associated resources
  57789. */
  57790. dispose(): void;
  57791. private renderFunction;
  57792. private drag;
  57793. private drop;
  57794. private _traverseFolder;
  57795. private _processFiles;
  57796. /**
  57797. * Load files from a drop event
  57798. * @param event defines the drop event to use as source
  57799. */
  57800. loadFiles(event: any): void;
  57801. private _processReload;
  57802. /**
  57803. * Reload the current scene from the loaded files
  57804. */
  57805. reload(): void;
  57806. }
  57807. }
  57808. declare module "babylonjs/Misc/HighDynamicRange/index" {
  57809. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  57810. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  57811. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57812. }
  57813. declare module "babylonjs/Misc/sceneOptimizer" {
  57814. import { Scene, IDisposable } from "babylonjs/scene";
  57815. import { Observable } from "babylonjs/Misc/observable";
  57816. /**
  57817. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57818. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57819. */
  57820. export class SceneOptimization {
  57821. /**
  57822. * Defines the priority of this optimization (0 by default which means first in the list)
  57823. */
  57824. priority: number;
  57825. /**
  57826. * Gets a string describing the action executed by the current optimization
  57827. * @returns description string
  57828. */
  57829. getDescription(): string;
  57830. /**
  57831. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57832. * @param scene defines the current scene where to apply this optimization
  57833. * @param optimizer defines the current optimizer
  57834. * @returns true if everything that can be done was applied
  57835. */
  57836. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57837. /**
  57838. * Creates the SceneOptimization object
  57839. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57840. * @param desc defines the description associated with the optimization
  57841. */
  57842. constructor(
  57843. /**
  57844. * Defines the priority of this optimization (0 by default which means first in the list)
  57845. */
  57846. priority?: number);
  57847. }
  57848. /**
  57849. * Defines an optimization used to reduce the size of render target textures
  57850. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57851. */
  57852. export class TextureOptimization extends SceneOptimization {
  57853. /**
  57854. * Defines the priority of this optimization (0 by default which means first in the list)
  57855. */
  57856. priority: number;
  57857. /**
  57858. * 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
  57859. */
  57860. maximumSize: number;
  57861. /**
  57862. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57863. */
  57864. step: number;
  57865. /**
  57866. * Gets a string describing the action executed by the current optimization
  57867. * @returns description string
  57868. */
  57869. getDescription(): string;
  57870. /**
  57871. * Creates the TextureOptimization object
  57872. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57873. * @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
  57874. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57875. */
  57876. constructor(
  57877. /**
  57878. * Defines the priority of this optimization (0 by default which means first in the list)
  57879. */
  57880. priority?: number,
  57881. /**
  57882. * 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
  57883. */
  57884. maximumSize?: number,
  57885. /**
  57886. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57887. */
  57888. step?: number);
  57889. /**
  57890. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57891. * @param scene defines the current scene where to apply this optimization
  57892. * @param optimizer defines the current optimizer
  57893. * @returns true if everything that can be done was applied
  57894. */
  57895. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57896. }
  57897. /**
  57898. * Defines an optimization used to increase or decrease the rendering resolution
  57899. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57900. */
  57901. export class HardwareScalingOptimization extends SceneOptimization {
  57902. /**
  57903. * Defines the priority of this optimization (0 by default which means first in the list)
  57904. */
  57905. priority: number;
  57906. /**
  57907. * Defines the maximum scale to use (2 by default)
  57908. */
  57909. maximumScale: number;
  57910. /**
  57911. * Defines the step to use between two passes (0.5 by default)
  57912. */
  57913. step: number;
  57914. private _currentScale;
  57915. private _directionOffset;
  57916. /**
  57917. * Gets a string describing the action executed by the current optimization
  57918. * @return description string
  57919. */
  57920. getDescription(): string;
  57921. /**
  57922. * Creates the HardwareScalingOptimization object
  57923. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57924. * @param maximumScale defines the maximum scale to use (2 by default)
  57925. * @param step defines the step to use between two passes (0.5 by default)
  57926. */
  57927. constructor(
  57928. /**
  57929. * Defines the priority of this optimization (0 by default which means first in the list)
  57930. */
  57931. priority?: number,
  57932. /**
  57933. * Defines the maximum scale to use (2 by default)
  57934. */
  57935. maximumScale?: number,
  57936. /**
  57937. * Defines the step to use between two passes (0.5 by default)
  57938. */
  57939. step?: number);
  57940. /**
  57941. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57942. * @param scene defines the current scene where to apply this optimization
  57943. * @param optimizer defines the current optimizer
  57944. * @returns true if everything that can be done was applied
  57945. */
  57946. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57947. }
  57948. /**
  57949. * Defines an optimization used to remove shadows
  57950. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57951. */
  57952. export class ShadowsOptimization extends SceneOptimization {
  57953. /**
  57954. * Gets a string describing the action executed by the current optimization
  57955. * @return description string
  57956. */
  57957. getDescription(): string;
  57958. /**
  57959. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57960. * @param scene defines the current scene where to apply this optimization
  57961. * @param optimizer defines the current optimizer
  57962. * @returns true if everything that can be done was applied
  57963. */
  57964. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57965. }
  57966. /**
  57967. * Defines an optimization used to turn post-processes off
  57968. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57969. */
  57970. export class PostProcessesOptimization extends SceneOptimization {
  57971. /**
  57972. * Gets a string describing the action executed by the current optimization
  57973. * @return description string
  57974. */
  57975. getDescription(): string;
  57976. /**
  57977. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57978. * @param scene defines the current scene where to apply this optimization
  57979. * @param optimizer defines the current optimizer
  57980. * @returns true if everything that can be done was applied
  57981. */
  57982. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57983. }
  57984. /**
  57985. * Defines an optimization used to turn lens flares off
  57986. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57987. */
  57988. export class LensFlaresOptimization extends SceneOptimization {
  57989. /**
  57990. * Gets a string describing the action executed by the current optimization
  57991. * @return description string
  57992. */
  57993. getDescription(): string;
  57994. /**
  57995. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57996. * @param scene defines the current scene where to apply this optimization
  57997. * @param optimizer defines the current optimizer
  57998. * @returns true if everything that can be done was applied
  57999. */
  58000. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58001. }
  58002. /**
  58003. * Defines an optimization based on user defined callback.
  58004. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58005. */
  58006. export class CustomOptimization extends SceneOptimization {
  58007. /**
  58008. * Callback called to apply the custom optimization.
  58009. */
  58010. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58011. /**
  58012. * Callback called to get custom description
  58013. */
  58014. onGetDescription: () => string;
  58015. /**
  58016. * Gets a string describing the action executed by the current optimization
  58017. * @returns description string
  58018. */
  58019. getDescription(): string;
  58020. /**
  58021. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58022. * @param scene defines the current scene where to apply this optimization
  58023. * @param optimizer defines the current optimizer
  58024. * @returns true if everything that can be done was applied
  58025. */
  58026. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58027. }
  58028. /**
  58029. * Defines an optimization used to turn particles off
  58030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58031. */
  58032. export class ParticlesOptimization extends SceneOptimization {
  58033. /**
  58034. * Gets a string describing the action executed by the current optimization
  58035. * @return description string
  58036. */
  58037. getDescription(): string;
  58038. /**
  58039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58040. * @param scene defines the current scene where to apply this optimization
  58041. * @param optimizer defines the current optimizer
  58042. * @returns true if everything that can be done was applied
  58043. */
  58044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58045. }
  58046. /**
  58047. * Defines an optimization used to turn render targets off
  58048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58049. */
  58050. export class RenderTargetsOptimization extends SceneOptimization {
  58051. /**
  58052. * Gets a string describing the action executed by the current optimization
  58053. * @return description string
  58054. */
  58055. getDescription(): string;
  58056. /**
  58057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58058. * @param scene defines the current scene where to apply this optimization
  58059. * @param optimizer defines the current optimizer
  58060. * @returns true if everything that can be done was applied
  58061. */
  58062. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58063. }
  58064. /**
  58065. * Defines an optimization used to merge meshes with compatible materials
  58066. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58067. */
  58068. export class MergeMeshesOptimization extends SceneOptimization {
  58069. private static _UpdateSelectionTree;
  58070. /**
  58071. * Gets or sets a boolean which defines if optimization octree has to be updated
  58072. */
  58073. /**
  58074. * Gets or sets a boolean which defines if optimization octree has to be updated
  58075. */
  58076. static UpdateSelectionTree: boolean;
  58077. /**
  58078. * Gets a string describing the action executed by the current optimization
  58079. * @return description string
  58080. */
  58081. getDescription(): string;
  58082. private _canBeMerged;
  58083. /**
  58084. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58085. * @param scene defines the current scene where to apply this optimization
  58086. * @param optimizer defines the current optimizer
  58087. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58088. * @returns true if everything that can be done was applied
  58089. */
  58090. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58091. }
  58092. /**
  58093. * Defines a list of options used by SceneOptimizer
  58094. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58095. */
  58096. export class SceneOptimizerOptions {
  58097. /**
  58098. * Defines the target frame rate to reach (60 by default)
  58099. */
  58100. targetFrameRate: number;
  58101. /**
  58102. * Defines the interval between two checkes (2000ms by default)
  58103. */
  58104. trackerDuration: number;
  58105. /**
  58106. * Gets the list of optimizations to apply
  58107. */
  58108. optimizations: SceneOptimization[];
  58109. /**
  58110. * Creates a new list of options used by SceneOptimizer
  58111. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58112. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58113. */
  58114. constructor(
  58115. /**
  58116. * Defines the target frame rate to reach (60 by default)
  58117. */
  58118. targetFrameRate?: number,
  58119. /**
  58120. * Defines the interval between two checkes (2000ms by default)
  58121. */
  58122. trackerDuration?: number);
  58123. /**
  58124. * Add a new optimization
  58125. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58126. * @returns the current SceneOptimizerOptions
  58127. */
  58128. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58129. /**
  58130. * Add a new custom optimization
  58131. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58132. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58133. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58134. * @returns the current SceneOptimizerOptions
  58135. */
  58136. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58137. /**
  58138. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58139. * @param targetFrameRate defines the target frame rate (60 by default)
  58140. * @returns a SceneOptimizerOptions object
  58141. */
  58142. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58143. /**
  58144. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58145. * @param targetFrameRate defines the target frame rate (60 by default)
  58146. * @returns a SceneOptimizerOptions object
  58147. */
  58148. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58149. /**
  58150. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58151. * @param targetFrameRate defines the target frame rate (60 by default)
  58152. * @returns a SceneOptimizerOptions object
  58153. */
  58154. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58155. }
  58156. /**
  58157. * Class used to run optimizations in order to reach a target frame rate
  58158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58159. */
  58160. export class SceneOptimizer implements IDisposable {
  58161. private _isRunning;
  58162. private _options;
  58163. private _scene;
  58164. private _currentPriorityLevel;
  58165. private _targetFrameRate;
  58166. private _trackerDuration;
  58167. private _currentFrameRate;
  58168. private _sceneDisposeObserver;
  58169. private _improvementMode;
  58170. /**
  58171. * Defines an observable called when the optimizer reaches the target frame rate
  58172. */
  58173. onSuccessObservable: Observable<SceneOptimizer>;
  58174. /**
  58175. * Defines an observable called when the optimizer enables an optimization
  58176. */
  58177. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58178. /**
  58179. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58180. */
  58181. onFailureObservable: Observable<SceneOptimizer>;
  58182. /**
  58183. * Gets a boolean indicating if the optimizer is in improvement mode
  58184. */
  58185. readonly isInImprovementMode: boolean;
  58186. /**
  58187. * Gets the current priority level (0 at start)
  58188. */
  58189. readonly currentPriorityLevel: number;
  58190. /**
  58191. * Gets the current frame rate checked by the SceneOptimizer
  58192. */
  58193. readonly currentFrameRate: number;
  58194. /**
  58195. * Gets or sets the current target frame rate (60 by default)
  58196. */
  58197. /**
  58198. * Gets or sets the current target frame rate (60 by default)
  58199. */
  58200. targetFrameRate: number;
  58201. /**
  58202. * Gets or sets the current interval between two checks (every 2000ms by default)
  58203. */
  58204. /**
  58205. * Gets or sets the current interval between two checks (every 2000ms by default)
  58206. */
  58207. trackerDuration: number;
  58208. /**
  58209. * Gets the list of active optimizations
  58210. */
  58211. readonly optimizations: SceneOptimization[];
  58212. /**
  58213. * Creates a new SceneOptimizer
  58214. * @param scene defines the scene to work on
  58215. * @param options defines the options to use with the SceneOptimizer
  58216. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58217. * @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)
  58218. */
  58219. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58220. /**
  58221. * Stops the current optimizer
  58222. */
  58223. stop(): void;
  58224. /**
  58225. * Reset the optimizer to initial step (current priority level = 0)
  58226. */
  58227. reset(): void;
  58228. /**
  58229. * Start the optimizer. By default it will try to reach a specific framerate
  58230. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58231. */
  58232. start(): void;
  58233. private _checkCurrentState;
  58234. /**
  58235. * Release all resources
  58236. */
  58237. dispose(): void;
  58238. /**
  58239. * Helper function to create a SceneOptimizer with one single line of code
  58240. * @param scene defines the scene to work on
  58241. * @param options defines the options to use with the SceneOptimizer
  58242. * @param onSuccess defines a callback to call on success
  58243. * @param onFailure defines a callback to call on failure
  58244. * @returns the new SceneOptimizer object
  58245. */
  58246. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58247. }
  58248. }
  58249. declare module "babylonjs/Misc/sceneSerializer" {
  58250. import { Scene } from "babylonjs/scene";
  58251. /**
  58252. * Class used to serialize a scene into a string
  58253. */
  58254. export class SceneSerializer {
  58255. /**
  58256. * Clear cache used by a previous serialization
  58257. */
  58258. static ClearCache(): void;
  58259. /**
  58260. * Serialize a scene into a JSON compatible object
  58261. * @param scene defines the scene to serialize
  58262. * @returns a JSON compatible object
  58263. */
  58264. static Serialize(scene: Scene): any;
  58265. /**
  58266. * Serialize a mesh into a JSON compatible object
  58267. * @param toSerialize defines the mesh to serialize
  58268. * @param withParents defines if parents must be serialized as well
  58269. * @param withChildren defines if children must be serialized as well
  58270. * @returns a JSON compatible object
  58271. */
  58272. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58273. }
  58274. }
  58275. declare module "babylonjs/Misc/textureTools" {
  58276. import { Texture } from "babylonjs/Materials/Textures/texture";
  58277. /**
  58278. * Class used to host texture specific utilities
  58279. */
  58280. export class TextureTools {
  58281. /**
  58282. * Uses the GPU to create a copy texture rescaled at a given size
  58283. * @param texture Texture to copy from
  58284. * @param width defines the desired width
  58285. * @param height defines the desired height
  58286. * @param useBilinearMode defines if bilinear mode has to be used
  58287. * @return the generated texture
  58288. */
  58289. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58290. }
  58291. }
  58292. declare module "babylonjs/Misc/videoRecorder" {
  58293. import { Nullable } from "babylonjs/types";
  58294. import { Engine } from "babylonjs/Engines/engine";
  58295. /**
  58296. * This represents the different options avilable for the video capture.
  58297. */
  58298. export interface VideoRecorderOptions {
  58299. /** Defines the mime type of the video */
  58300. mimeType: string;
  58301. /** Defines the video the video should be recorded at */
  58302. fps: number;
  58303. /** Defines the chunk size for the recording data */
  58304. recordChunckSize: number;
  58305. /** The audio tracks to attach to the record */
  58306. audioTracks?: MediaStreamTrack[];
  58307. }
  58308. /**
  58309. * This can helps recording videos from BabylonJS.
  58310. * This is based on the available WebRTC functionalities of the browser.
  58311. *
  58312. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58313. */
  58314. export class VideoRecorder {
  58315. private static readonly _defaultOptions;
  58316. /**
  58317. * Returns wehther or not the VideoRecorder is available in your browser.
  58318. * @param engine Defines the Babylon Engine to check the support for
  58319. * @returns true if supported otherwise false
  58320. */
  58321. static IsSupported(engine: Engine): boolean;
  58322. private readonly _options;
  58323. private _canvas;
  58324. private _mediaRecorder;
  58325. private _recordedChunks;
  58326. private _fileName;
  58327. private _resolve;
  58328. private _reject;
  58329. /**
  58330. * True wether a recording is already in progress.
  58331. */
  58332. readonly isRecording: boolean;
  58333. /**
  58334. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58335. * a video file.
  58336. * @param engine Defines the BabylonJS Engine you wish to record
  58337. * @param options Defines options that can be used to customized the capture
  58338. */
  58339. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58340. /**
  58341. * Stops the current recording before the default capture timeout passed in the startRecording
  58342. * functions.
  58343. */
  58344. stopRecording(): void;
  58345. /**
  58346. * Starts recording the canvas for a max duration specified in parameters.
  58347. * @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.
  58348. * @param maxDuration Defines the maximum recording time in seconds.
  58349. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58350. * @return a promise callback at the end of the recording with the video data in Blob.
  58351. */
  58352. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58353. /**
  58354. * Releases internal resources used during the recording.
  58355. */
  58356. dispose(): void;
  58357. private _handleDataAvailable;
  58358. private _handleError;
  58359. private _handleStop;
  58360. }
  58361. }
  58362. declare module "babylonjs/Misc/workerPool" {
  58363. import { IDisposable } from "babylonjs/scene";
  58364. /**
  58365. * Helper class to push actions to a pool of workers.
  58366. */
  58367. export class WorkerPool implements IDisposable {
  58368. private _workerInfos;
  58369. private _pendingActions;
  58370. /**
  58371. * Constructor
  58372. * @param workers Array of workers to use for actions
  58373. */
  58374. constructor(workers: Array<Worker>);
  58375. /**
  58376. * Terminates all workers and clears any pending actions.
  58377. */
  58378. dispose(): void;
  58379. /**
  58380. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58381. * pended until a worker has completed its action.
  58382. * @param action The action to perform. Call onComplete when the action is complete.
  58383. */
  58384. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58385. private _execute;
  58386. }
  58387. }
  58388. declare module "babylonjs/Misc/screenshotTools" {
  58389. import { Camera } from "babylonjs/Cameras/camera";
  58390. import { Engine } from "babylonjs/Engines/engine";
  58391. /**
  58392. * Class containing a set of static utilities functions for screenshots
  58393. */
  58394. export class ScreenshotTools {
  58395. /**
  58396. * Captures a screenshot of the current rendering
  58397. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58398. * @param engine defines the rendering engine
  58399. * @param camera defines the source camera
  58400. * @param size This parameter can be set to a single number or to an object with the
  58401. * following (optional) properties: precision, width, height. If a single number is passed,
  58402. * it will be used for both width and height. If an object is passed, the screenshot size
  58403. * will be derived from the parameters. The precision property is a multiplier allowing
  58404. * rendering at a higher or lower resolution
  58405. * @param successCallback defines the callback receives a single parameter which contains the
  58406. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58407. * src parameter of an <img> to display it
  58408. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58409. * Check your browser for supported MIME types
  58410. */
  58411. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58412. /**
  58413. * Generates an image screenshot from the specified camera.
  58414. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58415. * @param engine The engine to use for rendering
  58416. * @param camera The camera to use for rendering
  58417. * @param size This parameter can be set to a single number or to an object with the
  58418. * following (optional) properties: precision, width, height. If a single number is passed,
  58419. * it will be used for both width and height. If an object is passed, the screenshot size
  58420. * will be derived from the parameters. The precision property is a multiplier allowing
  58421. * rendering at a higher or lower resolution
  58422. * @param successCallback The callback receives a single parameter which contains the
  58423. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58424. * src parameter of an <img> to display it
  58425. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58426. * Check your browser for supported MIME types
  58427. * @param samples Texture samples (default: 1)
  58428. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58429. * @param fileName A name for for the downloaded file.
  58430. */
  58431. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58432. }
  58433. }
  58434. declare module "babylonjs/Misc/index" {
  58435. export * from "babylonjs/Misc/andOrNotEvaluator";
  58436. export * from "babylonjs/Misc/assetsManager";
  58437. export * from "babylonjs/Misc/dds";
  58438. export * from "babylonjs/Misc/decorators";
  58439. export * from "babylonjs/Misc/deferred";
  58440. export * from "babylonjs/Misc/environmentTextureTools";
  58441. export * from "babylonjs/Misc/meshExploder";
  58442. export * from "babylonjs/Misc/filesInput";
  58443. export * from "babylonjs/Misc/HighDynamicRange/index";
  58444. export * from "babylonjs/Misc/khronosTextureContainer";
  58445. export * from "babylonjs/Misc/observable";
  58446. export * from "babylonjs/Misc/performanceMonitor";
  58447. export * from "babylonjs/Misc/promise";
  58448. export * from "babylonjs/Misc/sceneOptimizer";
  58449. export * from "babylonjs/Misc/sceneSerializer";
  58450. export * from "babylonjs/Misc/smartArray";
  58451. export * from "babylonjs/Misc/stringDictionary";
  58452. export * from "babylonjs/Misc/tags";
  58453. export * from "babylonjs/Misc/textureTools";
  58454. export * from "babylonjs/Misc/tga";
  58455. export * from "babylonjs/Misc/tools";
  58456. export * from "babylonjs/Misc/videoRecorder";
  58457. export * from "babylonjs/Misc/virtualJoystick";
  58458. export * from "babylonjs/Misc/workerPool";
  58459. export * from "babylonjs/Misc/logger";
  58460. export * from "babylonjs/Misc/typeStore";
  58461. export * from "babylonjs/Misc/filesInputStore";
  58462. export * from "babylonjs/Misc/deepCopier";
  58463. export * from "babylonjs/Misc/pivotTools";
  58464. export * from "babylonjs/Misc/precisionDate";
  58465. export * from "babylonjs/Misc/screenshotTools";
  58466. export * from "babylonjs/Misc/typeStore";
  58467. export * from "babylonjs/Misc/webRequest";
  58468. export * from "babylonjs/Misc/iInspectable";
  58469. }
  58470. declare module "babylonjs/index" {
  58471. export * from "babylonjs/abstractScene";
  58472. export * from "babylonjs/Actions/index";
  58473. export * from "babylonjs/Animations/index";
  58474. export * from "babylonjs/assetContainer";
  58475. export * from "babylonjs/Audio/index";
  58476. export * from "babylonjs/Behaviors/index";
  58477. export * from "babylonjs/Bones/index";
  58478. export * from "babylonjs/Cameras/index";
  58479. export * from "babylonjs/Collisions/index";
  58480. export * from "babylonjs/Culling/index";
  58481. export * from "babylonjs/Debug/index";
  58482. export * from "babylonjs/Engines/index";
  58483. export * from "babylonjs/Events/index";
  58484. export * from "babylonjs/Gamepads/index";
  58485. export * from "babylonjs/Gizmos/index";
  58486. export * from "babylonjs/Helpers/index";
  58487. export * from "babylonjs/Instrumentation/index";
  58488. export * from "babylonjs/Layers/index";
  58489. export * from "babylonjs/LensFlares/index";
  58490. export * from "babylonjs/Lights/index";
  58491. export * from "babylonjs/Loading/index";
  58492. export * from "babylonjs/Materials/index";
  58493. export * from "babylonjs/Maths/index";
  58494. export * from "babylonjs/Meshes/index";
  58495. export * from "babylonjs/Morph/index";
  58496. export * from "babylonjs/node";
  58497. export * from "babylonjs/Offline/index";
  58498. export * from "babylonjs/Particles/index";
  58499. export * from "babylonjs/Physics/index";
  58500. export * from "babylonjs/PostProcesses/index";
  58501. export * from "babylonjs/Probes/index";
  58502. export * from "babylonjs/Rendering/index";
  58503. export * from "babylonjs/scene";
  58504. export * from "babylonjs/sceneComponent";
  58505. export * from "babylonjs/Sprites/index";
  58506. export * from "babylonjs/States/index";
  58507. export * from "babylonjs/Misc/index";
  58508. export * from "babylonjs/types";
  58509. }
  58510. declare module "babylonjs/Animations/pathCursor" {
  58511. import { Path2, Vector3 } from "babylonjs/Maths/math";
  58512. /**
  58513. * A cursor which tracks a point on a path
  58514. */
  58515. export class PathCursor {
  58516. private path;
  58517. /**
  58518. * Stores path cursor callbacks for when an onchange event is triggered
  58519. */
  58520. private _onchange;
  58521. /**
  58522. * The value of the path cursor
  58523. */
  58524. value: number;
  58525. /**
  58526. * The animation array of the path cursor
  58527. */
  58528. animations: Animation[];
  58529. /**
  58530. * Initializes the path cursor
  58531. * @param path The path to track
  58532. */
  58533. constructor(path: Path2);
  58534. /**
  58535. * Gets the cursor point on the path
  58536. * @returns A point on the path cursor at the cursor location
  58537. */
  58538. getPoint(): Vector3;
  58539. /**
  58540. * Moves the cursor ahead by the step amount
  58541. * @param step The amount to move the cursor forward
  58542. * @returns This path cursor
  58543. */
  58544. moveAhead(step?: number): PathCursor;
  58545. /**
  58546. * Moves the cursor behind by the step amount
  58547. * @param step The amount to move the cursor back
  58548. * @returns This path cursor
  58549. */
  58550. moveBack(step?: number): PathCursor;
  58551. /**
  58552. * Moves the cursor by the step amount
  58553. * If the step amount is greater than one, an exception is thrown
  58554. * @param step The amount to move the cursor
  58555. * @returns This path cursor
  58556. */
  58557. move(step: number): PathCursor;
  58558. /**
  58559. * Ensures that the value is limited between zero and one
  58560. * @returns This path cursor
  58561. */
  58562. private ensureLimits;
  58563. /**
  58564. * Runs onchange callbacks on change (used by the animation engine)
  58565. * @returns This path cursor
  58566. */
  58567. private raiseOnChange;
  58568. /**
  58569. * Executes a function on change
  58570. * @param f A path cursor onchange callback
  58571. * @returns This path cursor
  58572. */
  58573. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58574. }
  58575. }
  58576. declare module "babylonjs/Legacy/legacy" {
  58577. import * as Babylon from "babylonjs/index";
  58578. export * from "babylonjs/index";
  58579. }
  58580. declare module "babylonjs/Shaders/blur.fragment" {
  58581. /** @hidden */
  58582. export var blurPixelShader: {
  58583. name: string;
  58584. shader: string;
  58585. };
  58586. }
  58587. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58588. /** @hidden */
  58589. export var bones300Declaration: {
  58590. name: string;
  58591. shader: string;
  58592. };
  58593. }
  58594. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58595. /** @hidden */
  58596. export var instances300Declaration: {
  58597. name: string;
  58598. shader: string;
  58599. };
  58600. }
  58601. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58602. /** @hidden */
  58603. export var pointCloudVertexDeclaration: {
  58604. name: string;
  58605. shader: string;
  58606. };
  58607. }
  58608. // Mixins
  58609. interface Window {
  58610. mozIndexedDB: IDBFactory;
  58611. webkitIndexedDB: IDBFactory;
  58612. msIndexedDB: IDBFactory;
  58613. webkitURL: typeof URL;
  58614. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58615. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58616. WebGLRenderingContext: WebGLRenderingContext;
  58617. MSGesture: MSGesture;
  58618. CANNON: any;
  58619. AudioContext: AudioContext;
  58620. webkitAudioContext: AudioContext;
  58621. PointerEvent: any;
  58622. Math: Math;
  58623. Uint8Array: Uint8ArrayConstructor;
  58624. Float32Array: Float32ArrayConstructor;
  58625. mozURL: typeof URL;
  58626. msURL: typeof URL;
  58627. VRFrameData: any; // WebVR, from specs 1.1
  58628. DracoDecoderModule: any;
  58629. setImmediate(handler: (...args: any[]) => void): number;
  58630. }
  58631. interface HTMLCanvasElement {
  58632. requestPointerLock(): void;
  58633. msRequestPointerLock?(): void;
  58634. mozRequestPointerLock?(): void;
  58635. webkitRequestPointerLock?(): void;
  58636. /** Track wether a record is in progress */
  58637. isRecording: boolean;
  58638. /** Capture Stream method defined by some browsers */
  58639. captureStream(fps?: number): MediaStream;
  58640. }
  58641. interface CanvasRenderingContext2D {
  58642. msImageSmoothingEnabled: boolean;
  58643. }
  58644. interface MouseEvent {
  58645. mozMovementX: number;
  58646. mozMovementY: number;
  58647. webkitMovementX: number;
  58648. webkitMovementY: number;
  58649. msMovementX: number;
  58650. msMovementY: number;
  58651. }
  58652. interface Navigator {
  58653. mozGetVRDevices: (any: any) => any;
  58654. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58655. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58656. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58657. webkitGetGamepads(): Gamepad[];
  58658. msGetGamepads(): Gamepad[];
  58659. webkitGamepads(): Gamepad[];
  58660. }
  58661. interface HTMLVideoElement {
  58662. mozSrcObject: any;
  58663. }
  58664. interface Math {
  58665. fround(x: number): number;
  58666. imul(a: number, b: number): number;
  58667. }
  58668. interface WebGLProgram {
  58669. context?: WebGLRenderingContext;
  58670. vertexShader?: WebGLShader;
  58671. fragmentShader?: WebGLShader;
  58672. isParallelCompiled: boolean;
  58673. onCompiled?: () => void;
  58674. }
  58675. interface WebGLRenderingContext {
  58676. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58677. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58678. vertexAttribDivisor(index: number, divisor: number): void;
  58679. createVertexArray(): any;
  58680. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58681. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58682. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58683. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58684. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58685. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58686. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58687. // Queries
  58688. createQuery(): WebGLQuery;
  58689. deleteQuery(query: WebGLQuery): void;
  58690. beginQuery(target: number, query: WebGLQuery): void;
  58691. endQuery(target: number): void;
  58692. getQueryParameter(query: WebGLQuery, pname: number): any;
  58693. getQuery(target: number, pname: number): any;
  58694. MAX_SAMPLES: number;
  58695. RGBA8: number;
  58696. READ_FRAMEBUFFER: number;
  58697. DRAW_FRAMEBUFFER: number;
  58698. UNIFORM_BUFFER: number;
  58699. HALF_FLOAT_OES: number;
  58700. RGBA16F: number;
  58701. RGBA32F: number;
  58702. R32F: number;
  58703. RG32F: number;
  58704. RGB32F: number;
  58705. R16F: number;
  58706. RG16F: number;
  58707. RGB16F: number;
  58708. RED: number;
  58709. RG: number;
  58710. R8: number;
  58711. RG8: number;
  58712. UNSIGNED_INT_24_8: number;
  58713. DEPTH24_STENCIL8: number;
  58714. /* Multiple Render Targets */
  58715. drawBuffers(buffers: number[]): void;
  58716. readBuffer(src: number): void;
  58717. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58718. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58719. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58720. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58721. // Occlusion Query
  58722. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58723. ANY_SAMPLES_PASSED: number;
  58724. QUERY_RESULT_AVAILABLE: number;
  58725. QUERY_RESULT: number;
  58726. }
  58727. interface WebGLBuffer {
  58728. references: number;
  58729. capacity: number;
  58730. is32Bits: boolean;
  58731. }
  58732. interface WebGLProgram {
  58733. transformFeedback?: WebGLTransformFeedback | null;
  58734. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58735. }
  58736. interface EXT_disjoint_timer_query {
  58737. QUERY_COUNTER_BITS_EXT: number;
  58738. TIME_ELAPSED_EXT: number;
  58739. TIMESTAMP_EXT: number;
  58740. GPU_DISJOINT_EXT: number;
  58741. QUERY_RESULT_EXT: number;
  58742. QUERY_RESULT_AVAILABLE_EXT: number;
  58743. queryCounterEXT(query: WebGLQuery, target: number): void;
  58744. createQueryEXT(): WebGLQuery;
  58745. beginQueryEXT(target: number, query: WebGLQuery): void;
  58746. endQueryEXT(target: number): void;
  58747. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58748. deleteQueryEXT(query: WebGLQuery): void;
  58749. }
  58750. interface WebGLUniformLocation {
  58751. _currentState: any;
  58752. }
  58753. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58754. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58755. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58756. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58757. interface WebGLRenderingContext {
  58758. readonly RASTERIZER_DISCARD: number;
  58759. readonly DEPTH_COMPONENT24: number;
  58760. readonly TEXTURE_3D: number;
  58761. readonly TEXTURE_2D_ARRAY: number;
  58762. readonly TEXTURE_COMPARE_FUNC: number;
  58763. readonly TEXTURE_COMPARE_MODE: number;
  58764. readonly COMPARE_REF_TO_TEXTURE: number;
  58765. readonly TEXTURE_WRAP_R: number;
  58766. readonly HALF_FLOAT: number;
  58767. readonly RGB8: number;
  58768. readonly RED_INTEGER: number;
  58769. readonly RG_INTEGER: number;
  58770. readonly RGB_INTEGER: number;
  58771. readonly RGBA_INTEGER: number;
  58772. readonly R8_SNORM: number;
  58773. readonly RG8_SNORM: number;
  58774. readonly RGB8_SNORM: number;
  58775. readonly RGBA8_SNORM: number;
  58776. readonly R8I: number;
  58777. readonly RG8I: number;
  58778. readonly RGB8I: number;
  58779. readonly RGBA8I: number;
  58780. readonly R8UI: number;
  58781. readonly RG8UI: number;
  58782. readonly RGB8UI: number;
  58783. readonly RGBA8UI: number;
  58784. readonly R16I: number;
  58785. readonly RG16I: number;
  58786. readonly RGB16I: number;
  58787. readonly RGBA16I: number;
  58788. readonly R16UI: number;
  58789. readonly RG16UI: number;
  58790. readonly RGB16UI: number;
  58791. readonly RGBA16UI: number;
  58792. readonly R32I: number;
  58793. readonly RG32I: number;
  58794. readonly RGB32I: number;
  58795. readonly RGBA32I: number;
  58796. readonly R32UI: number;
  58797. readonly RG32UI: number;
  58798. readonly RGB32UI: number;
  58799. readonly RGBA32UI: number;
  58800. readonly RGB10_A2UI: number;
  58801. readonly R11F_G11F_B10F: number;
  58802. readonly RGB9_E5: number;
  58803. readonly RGB10_A2: number;
  58804. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58805. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58806. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58807. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58808. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58809. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58810. 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;
  58811. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58812. readonly TRANSFORM_FEEDBACK: number;
  58813. readonly INTERLEAVED_ATTRIBS: number;
  58814. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58815. createTransformFeedback(): WebGLTransformFeedback;
  58816. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58817. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58818. beginTransformFeedback(primitiveMode: number): void;
  58819. endTransformFeedback(): void;
  58820. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58821. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58822. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58823. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58824. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58825. }
  58826. interface ImageBitmap {
  58827. readonly width: number;
  58828. readonly height: number;
  58829. close(): void;
  58830. }
  58831. interface WebGLQuery extends WebGLObject {
  58832. }
  58833. declare var WebGLQuery: {
  58834. prototype: WebGLQuery;
  58835. new(): WebGLQuery;
  58836. };
  58837. interface WebGLSampler extends WebGLObject {
  58838. }
  58839. declare var WebGLSampler: {
  58840. prototype: WebGLSampler;
  58841. new(): WebGLSampler;
  58842. };
  58843. interface WebGLSync extends WebGLObject {
  58844. }
  58845. declare var WebGLSync: {
  58846. prototype: WebGLSync;
  58847. new(): WebGLSync;
  58848. };
  58849. interface WebGLTransformFeedback extends WebGLObject {
  58850. }
  58851. declare var WebGLTransformFeedback: {
  58852. prototype: WebGLTransformFeedback;
  58853. new(): WebGLTransformFeedback;
  58854. };
  58855. interface WebGLVertexArrayObject extends WebGLObject {
  58856. }
  58857. declare var WebGLVertexArrayObject: {
  58858. prototype: WebGLVertexArrayObject;
  58859. new(): WebGLVertexArrayObject;
  58860. };
  58861. // Type definitions for WebVR API
  58862. // Project: https://w3c.github.io/webvr/
  58863. // Definitions by: six a <https://github.com/lostfictions>
  58864. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58865. interface VRDisplay extends EventTarget {
  58866. /**
  58867. * Dictionary of capabilities describing the VRDisplay.
  58868. */
  58869. readonly capabilities: VRDisplayCapabilities;
  58870. /**
  58871. * z-depth defining the far plane of the eye view frustum
  58872. * enables mapping of values in the render target depth
  58873. * attachment to scene coordinates. Initially set to 10000.0.
  58874. */
  58875. depthFar: number;
  58876. /**
  58877. * z-depth defining the near plane of the eye view frustum
  58878. * enables mapping of values in the render target depth
  58879. * attachment to scene coordinates. Initially set to 0.01.
  58880. */
  58881. depthNear: number;
  58882. /**
  58883. * An identifier for this distinct VRDisplay. Used as an
  58884. * association point in the Gamepad API.
  58885. */
  58886. readonly displayId: number;
  58887. /**
  58888. * A display name, a user-readable name identifying it.
  58889. */
  58890. readonly displayName: string;
  58891. readonly isConnected: boolean;
  58892. readonly isPresenting: boolean;
  58893. /**
  58894. * If this VRDisplay supports room-scale experiences, the optional
  58895. * stage attribute contains details on the room-scale parameters.
  58896. */
  58897. readonly stageParameters: VRStageParameters | null;
  58898. /**
  58899. * Passing the value returned by `requestAnimationFrame` to
  58900. * `cancelAnimationFrame` will unregister the callback.
  58901. * @param handle Define the hanle of the request to cancel
  58902. */
  58903. cancelAnimationFrame(handle: number): void;
  58904. /**
  58905. * Stops presenting to the VRDisplay.
  58906. * @returns a promise to know when it stopped
  58907. */
  58908. exitPresent(): Promise<void>;
  58909. /**
  58910. * Return the current VREyeParameters for the given eye.
  58911. * @param whichEye Define the eye we want the parameter for
  58912. * @returns the eye parameters
  58913. */
  58914. getEyeParameters(whichEye: string): VREyeParameters;
  58915. /**
  58916. * Populates the passed VRFrameData with the information required to render
  58917. * the current frame.
  58918. * @param frameData Define the data structure to populate
  58919. * @returns true if ok otherwise false
  58920. */
  58921. getFrameData(frameData: VRFrameData): boolean;
  58922. /**
  58923. * Get the layers currently being presented.
  58924. * @returns the list of VR layers
  58925. */
  58926. getLayers(): VRLayer[];
  58927. /**
  58928. * Return a VRPose containing the future predicted pose of the VRDisplay
  58929. * when the current frame will be presented. The value returned will not
  58930. * change until JavaScript has returned control to the browser.
  58931. *
  58932. * The VRPose will contain the position, orientation, velocity,
  58933. * and acceleration of each of these properties.
  58934. * @returns the pose object
  58935. */
  58936. getPose(): VRPose;
  58937. /**
  58938. * Return the current instantaneous pose of the VRDisplay, with no
  58939. * prediction applied.
  58940. * @returns the current instantaneous pose
  58941. */
  58942. getImmediatePose(): VRPose;
  58943. /**
  58944. * The callback passed to `requestAnimationFrame` will be called
  58945. * any time a new frame should be rendered. When the VRDisplay is
  58946. * presenting the callback will be called at the native refresh
  58947. * rate of the HMD. When not presenting this function acts
  58948. * identically to how window.requestAnimationFrame acts. Content should
  58949. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58950. * asynchronously from other displays and at differing refresh rates.
  58951. * @param callback Define the eaction to run next frame
  58952. * @returns the request handle it
  58953. */
  58954. requestAnimationFrame(callback: FrameRequestCallback): number;
  58955. /**
  58956. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58957. * Repeat calls while already presenting will update the VRLayers being displayed.
  58958. * @param layers Define the list of layer to present
  58959. * @returns a promise to know when the request has been fulfilled
  58960. */
  58961. requestPresent(layers: VRLayer[]): Promise<void>;
  58962. /**
  58963. * Reset the pose for this display, treating its current position and
  58964. * orientation as the "origin/zero" values. VRPose.position,
  58965. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58966. * updated when calling resetPose(). This should be called in only
  58967. * sitting-space experiences.
  58968. */
  58969. resetPose(): void;
  58970. /**
  58971. * The VRLayer provided to the VRDisplay will be captured and presented
  58972. * in the HMD. Calling this function has the same effect on the source
  58973. * canvas as any other operation that uses its source image, and canvases
  58974. * created without preserveDrawingBuffer set to true will be cleared.
  58975. * @param pose Define the pose to submit
  58976. */
  58977. submitFrame(pose?: VRPose): void;
  58978. }
  58979. declare var VRDisplay: {
  58980. prototype: VRDisplay;
  58981. new(): VRDisplay;
  58982. };
  58983. interface VRLayer {
  58984. leftBounds?: number[] | Float32Array | null;
  58985. rightBounds?: number[] | Float32Array | null;
  58986. source?: HTMLCanvasElement | null;
  58987. }
  58988. interface VRDisplayCapabilities {
  58989. readonly canPresent: boolean;
  58990. readonly hasExternalDisplay: boolean;
  58991. readonly hasOrientation: boolean;
  58992. readonly hasPosition: boolean;
  58993. readonly maxLayers: number;
  58994. }
  58995. interface VREyeParameters {
  58996. /** @deprecated */
  58997. readonly fieldOfView: VRFieldOfView;
  58998. readonly offset: Float32Array;
  58999. readonly renderHeight: number;
  59000. readonly renderWidth: number;
  59001. }
  59002. interface VRFieldOfView {
  59003. readonly downDegrees: number;
  59004. readonly leftDegrees: number;
  59005. readonly rightDegrees: number;
  59006. readonly upDegrees: number;
  59007. }
  59008. interface VRFrameData {
  59009. readonly leftProjectionMatrix: Float32Array;
  59010. readonly leftViewMatrix: Float32Array;
  59011. readonly pose: VRPose;
  59012. readonly rightProjectionMatrix: Float32Array;
  59013. readonly rightViewMatrix: Float32Array;
  59014. readonly timestamp: number;
  59015. }
  59016. interface VRPose {
  59017. readonly angularAcceleration: Float32Array | null;
  59018. readonly angularVelocity: Float32Array | null;
  59019. readonly linearAcceleration: Float32Array | null;
  59020. readonly linearVelocity: Float32Array | null;
  59021. readonly orientation: Float32Array | null;
  59022. readonly position: Float32Array | null;
  59023. readonly timestamp: number;
  59024. }
  59025. interface VRStageParameters {
  59026. sittingToStandingTransform?: Float32Array;
  59027. sizeX?: number;
  59028. sizeY?: number;
  59029. }
  59030. interface Navigator {
  59031. getVRDisplays(): Promise<VRDisplay[]>;
  59032. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59033. }
  59034. interface Window {
  59035. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59036. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59037. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59038. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59039. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59040. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59041. }
  59042. interface Gamepad {
  59043. readonly displayId: number;
  59044. }
  59045. interface XRDevice {
  59046. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59047. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59048. }
  59049. interface XRSession {
  59050. getInputSources(): Array<any>;
  59051. baseLayer: XRWebGLLayer;
  59052. requestFrameOfReference(type: string): Promise<void>;
  59053. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59054. end(): Promise<void>;
  59055. requestAnimationFrame: Function;
  59056. addEventListener: Function;
  59057. }
  59058. interface XRSessionCreationOptions {
  59059. outputContext?: WebGLRenderingContext | null;
  59060. immersive?: boolean;
  59061. environmentIntegration?: boolean;
  59062. }
  59063. interface XRLayer {
  59064. getViewport: Function;
  59065. framebufferWidth: number;
  59066. framebufferHeight: number;
  59067. }
  59068. interface XRView {
  59069. projectionMatrix: Float32Array;
  59070. }
  59071. interface XRFrame {
  59072. getDevicePose: Function;
  59073. getInputPose: Function;
  59074. views: Array<XRView>;
  59075. baseLayer: XRLayer;
  59076. }
  59077. interface XRFrameOfReference {
  59078. }
  59079. interface XRWebGLLayer extends XRLayer {
  59080. framebuffer: WebGLFramebuffer;
  59081. }
  59082. declare var XRWebGLLayer: {
  59083. prototype: XRWebGLLayer;
  59084. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59085. };
  59086. declare module "babylonjs" {
  59087. export * from "babylonjs/Legacy/legacy";
  59088. }
  59089. declare module BABYLON {
  59090. /** Alias type for value that can be null */
  59091. export type Nullable<T> = T | null;
  59092. /**
  59093. * Alias type for number that are floats
  59094. * @ignorenaming
  59095. */
  59096. export type float = number;
  59097. /**
  59098. * Alias type for number that are doubles.
  59099. * @ignorenaming
  59100. */
  59101. export type double = number;
  59102. /**
  59103. * Alias type for number that are integer
  59104. * @ignorenaming
  59105. */
  59106. export type int = number;
  59107. /** Alias type for number array or Float32Array */
  59108. export type FloatArray = number[] | Float32Array;
  59109. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59110. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59111. /**
  59112. * Alias for types that can be used by a Buffer or VertexBuffer.
  59113. */
  59114. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59115. /**
  59116. * Alias type for primitive types
  59117. * @ignorenaming
  59118. */
  59119. type Primitive = undefined | null | boolean | string | number | Function;
  59120. /**
  59121. * Type modifier to make all the properties of an object Readonly
  59122. */
  59123. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59124. /**
  59125. * Type modifier to make all the properties of an object Readonly recursively
  59126. */
  59127. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59128. /** @hidden */
  59129. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59130. }
  59131. /** @hidden */
  59132. /** @hidden */
  59133. type DeepImmutableObject<T> = {
  59134. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59135. };
  59136. }
  59137. declare module BABYLON {
  59138. /**
  59139. * Class containing a set of static utilities functions for arrays.
  59140. */
  59141. export class ArrayTools {
  59142. /**
  59143. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59144. * @param size the number of element to construct and put in the array
  59145. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59146. * @returns a new array filled with new objects
  59147. */
  59148. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59149. }
  59150. }
  59151. declare module BABYLON {
  59152. /**
  59153. * Scalar computation library
  59154. */
  59155. export class Scalar {
  59156. /**
  59157. * Two pi constants convenient for computation.
  59158. */
  59159. static TwoPi: number;
  59160. /**
  59161. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59162. * @param a number
  59163. * @param b number
  59164. * @param epsilon (default = 1.401298E-45)
  59165. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59166. */
  59167. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59168. /**
  59169. * Returns a string : the upper case translation of the number i to hexadecimal.
  59170. * @param i number
  59171. * @returns the upper case translation of the number i to hexadecimal.
  59172. */
  59173. static ToHex(i: number): string;
  59174. /**
  59175. * Returns -1 if value is negative and +1 is value is positive.
  59176. * @param value the value
  59177. * @returns the value itself if it's equal to zero.
  59178. */
  59179. static Sign(value: number): number;
  59180. /**
  59181. * Returns the value itself if it's between min and max.
  59182. * Returns min if the value is lower than min.
  59183. * Returns max if the value is greater than max.
  59184. * @param value the value to clmap
  59185. * @param min the min value to clamp to (default: 0)
  59186. * @param max the max value to clamp to (default: 1)
  59187. * @returns the clamped value
  59188. */
  59189. static Clamp(value: number, min?: number, max?: number): number;
  59190. /**
  59191. * the log2 of value.
  59192. * @param value the value to compute log2 of
  59193. * @returns the log2 of value.
  59194. */
  59195. static Log2(value: number): number;
  59196. /**
  59197. * Loops the value, so that it is never larger than length and never smaller than 0.
  59198. *
  59199. * This is similar to the modulo operator but it works with floating point numbers.
  59200. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59201. * With t = 5 and length = 2.5, the result would be 0.0.
  59202. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59203. * @param value the value
  59204. * @param length the length
  59205. * @returns the looped value
  59206. */
  59207. static Repeat(value: number, length: number): number;
  59208. /**
  59209. * Normalize the value between 0.0 and 1.0 using min and max values
  59210. * @param value value to normalize
  59211. * @param min max to normalize between
  59212. * @param max min to normalize between
  59213. * @returns the normalized value
  59214. */
  59215. static Normalize(value: number, min: number, max: number): number;
  59216. /**
  59217. * Denormalize the value from 0.0 and 1.0 using min and max values
  59218. * @param normalized value to denormalize
  59219. * @param min max to denormalize between
  59220. * @param max min to denormalize between
  59221. * @returns the denormalized value
  59222. */
  59223. static Denormalize(normalized: number, min: number, max: number): number;
  59224. /**
  59225. * Calculates the shortest difference between two given angles given in degrees.
  59226. * @param current current angle in degrees
  59227. * @param target target angle in degrees
  59228. * @returns the delta
  59229. */
  59230. static DeltaAngle(current: number, target: number): number;
  59231. /**
  59232. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  59233. * @param tx value
  59234. * @param length length
  59235. * @returns The returned value will move back and forth between 0 and length
  59236. */
  59237. static PingPong(tx: number, length: number): number;
  59238. /**
  59239. * Interpolates between min and max with smoothing at the limits.
  59240. *
  59241. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  59242. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  59243. * @param from from
  59244. * @param to to
  59245. * @param tx value
  59246. * @returns the smooth stepped value
  59247. */
  59248. static SmoothStep(from: number, to: number, tx: number): number;
  59249. /**
  59250. * Moves a value current towards target.
  59251. *
  59252. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  59253. * Negative values of maxDelta pushes the value away from target.
  59254. * @param current current value
  59255. * @param target target value
  59256. * @param maxDelta max distance to move
  59257. * @returns resulting value
  59258. */
  59259. static MoveTowards(current: number, target: number, maxDelta: number): number;
  59260. /**
  59261. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59262. *
  59263. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  59264. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  59265. * @param current current value
  59266. * @param target target value
  59267. * @param maxDelta max distance to move
  59268. * @returns resulting angle
  59269. */
  59270. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  59271. /**
  59272. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  59273. * @param start start value
  59274. * @param end target value
  59275. * @param amount amount to lerp between
  59276. * @returns the lerped value
  59277. */
  59278. static Lerp(start: number, end: number, amount: number): number;
  59279. /**
  59280. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59281. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  59282. * @param start start value
  59283. * @param end target value
  59284. * @param amount amount to lerp between
  59285. * @returns the lerped value
  59286. */
  59287. static LerpAngle(start: number, end: number, amount: number): number;
  59288. /**
  59289. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  59290. * @param a start value
  59291. * @param b target value
  59292. * @param value value between a and b
  59293. * @returns the inverseLerp value
  59294. */
  59295. static InverseLerp(a: number, b: number, value: number): number;
  59296. /**
  59297. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  59298. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  59299. * @param value1 spline value
  59300. * @param tangent1 spline value
  59301. * @param value2 spline value
  59302. * @param tangent2 spline value
  59303. * @param amount input value
  59304. * @returns hermite result
  59305. */
  59306. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  59307. /**
  59308. * Returns a random float number between and min and max values
  59309. * @param min min value of random
  59310. * @param max max value of random
  59311. * @returns random value
  59312. */
  59313. static RandomRange(min: number, max: number): number;
  59314. /**
  59315. * This function returns percentage of a number in a given range.
  59316. *
  59317. * RangeToPercent(40,20,60) will return 0.5 (50%)
  59318. * RangeToPercent(34,0,100) will return 0.34 (34%)
  59319. * @param number to convert to percentage
  59320. * @param min min range
  59321. * @param max max range
  59322. * @returns the percentage
  59323. */
  59324. static RangeToPercent(number: number, min: number, max: number): number;
  59325. /**
  59326. * This function returns number that corresponds to the percentage in a given range.
  59327. *
  59328. * PercentToRange(0.34,0,100) will return 34.
  59329. * @param percent to convert to number
  59330. * @param min min range
  59331. * @param max max range
  59332. * @returns the number
  59333. */
  59334. static PercentToRange(percent: number, min: number, max: number): number;
  59335. /**
  59336. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  59337. * @param angle The angle to normalize in radian.
  59338. * @return The converted angle.
  59339. */
  59340. static NormalizeRadians(angle: number): number;
  59341. }
  59342. }
  59343. declare module BABYLON {
  59344. /**
  59345. * Constant used to convert a value to gamma space
  59346. * @ignorenaming
  59347. */
  59348. export const ToGammaSpace: number;
  59349. /**
  59350. * Constant used to convert a value to linear space
  59351. * @ignorenaming
  59352. */
  59353. export const ToLinearSpace = 2.2;
  59354. /**
  59355. * Constant used to define the minimal number value in Babylon.js
  59356. * @ignorenaming
  59357. */
  59358. export const Epsilon = 0.001;
  59359. /**
  59360. * Class used to hold a RBG color
  59361. */
  59362. export class Color3 {
  59363. /**
  59364. * Defines the red component (between 0 and 1, default is 0)
  59365. */
  59366. r: number;
  59367. /**
  59368. * Defines the green component (between 0 and 1, default is 0)
  59369. */
  59370. g: number;
  59371. /**
  59372. * Defines the blue component (between 0 and 1, default is 0)
  59373. */
  59374. b: number;
  59375. /**
  59376. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  59377. * @param r defines the red component (between 0 and 1, default is 0)
  59378. * @param g defines the green component (between 0 and 1, default is 0)
  59379. * @param b defines the blue component (between 0 and 1, default is 0)
  59380. */
  59381. constructor(
  59382. /**
  59383. * Defines the red component (between 0 and 1, default is 0)
  59384. */
  59385. r?: number,
  59386. /**
  59387. * Defines the green component (between 0 and 1, default is 0)
  59388. */
  59389. g?: number,
  59390. /**
  59391. * Defines the blue component (between 0 and 1, default is 0)
  59392. */
  59393. b?: number);
  59394. /**
  59395. * Creates a string with the Color3 current values
  59396. * @returns the string representation of the Color3 object
  59397. */
  59398. toString(): string;
  59399. /**
  59400. * Returns the string "Color3"
  59401. * @returns "Color3"
  59402. */
  59403. getClassName(): string;
  59404. /**
  59405. * Compute the Color3 hash code
  59406. * @returns an unique number that can be used to hash Color3 objects
  59407. */
  59408. getHashCode(): number;
  59409. /**
  59410. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  59411. * @param array defines the array where to store the r,g,b components
  59412. * @param index defines an optional index in the target array to define where to start storing values
  59413. * @returns the current Color3 object
  59414. */
  59415. toArray(array: FloatArray, index?: number): Color3;
  59416. /**
  59417. * Returns a new Color4 object from the current Color3 and the given alpha
  59418. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  59419. * @returns a new Color4 object
  59420. */
  59421. toColor4(alpha?: number): Color4;
  59422. /**
  59423. * Returns a new array populated with 3 numeric elements : red, green and blue values
  59424. * @returns the new array
  59425. */
  59426. asArray(): number[];
  59427. /**
  59428. * Returns the luminance value
  59429. * @returns a float value
  59430. */
  59431. toLuminance(): number;
  59432. /**
  59433. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  59434. * @param otherColor defines the second operand
  59435. * @returns the new Color3 object
  59436. */
  59437. multiply(otherColor: DeepImmutable<Color3>): Color3;
  59438. /**
  59439. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  59440. * @param otherColor defines the second operand
  59441. * @param result defines the Color3 object where to store the result
  59442. * @returns the current Color3
  59443. */
  59444. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59445. /**
  59446. * Determines equality between Color3 objects
  59447. * @param otherColor defines the second operand
  59448. * @returns true if the rgb values are equal to the given ones
  59449. */
  59450. equals(otherColor: DeepImmutable<Color3>): boolean;
  59451. /**
  59452. * Determines equality between the current Color3 object and a set of r,b,g values
  59453. * @param r defines the red component to check
  59454. * @param g defines the green component to check
  59455. * @param b defines the blue component to check
  59456. * @returns true if the rgb values are equal to the given ones
  59457. */
  59458. equalsFloats(r: number, g: number, b: number): boolean;
  59459. /**
  59460. * Multiplies in place each rgb value by scale
  59461. * @param scale defines the scaling factor
  59462. * @returns the updated Color3
  59463. */
  59464. scale(scale: number): Color3;
  59465. /**
  59466. * Multiplies the rgb values by scale and stores the result into "result"
  59467. * @param scale defines the scaling factor
  59468. * @param result defines the Color3 object where to store the result
  59469. * @returns the unmodified current Color3
  59470. */
  59471. scaleToRef(scale: number, result: Color3): Color3;
  59472. /**
  59473. * Scale the current Color3 values by a factor and add the result to a given Color3
  59474. * @param scale defines the scale factor
  59475. * @param result defines color to store the result into
  59476. * @returns the unmodified current Color3
  59477. */
  59478. scaleAndAddToRef(scale: number, result: Color3): Color3;
  59479. /**
  59480. * Clamps the rgb values by the min and max values and stores the result into "result"
  59481. * @param min defines minimum clamping value (default is 0)
  59482. * @param max defines maximum clamping value (default is 1)
  59483. * @param result defines color to store the result into
  59484. * @returns the original Color3
  59485. */
  59486. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  59487. /**
  59488. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  59489. * @param otherColor defines the second operand
  59490. * @returns the new Color3
  59491. */
  59492. add(otherColor: DeepImmutable<Color3>): Color3;
  59493. /**
  59494. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  59495. * @param otherColor defines the second operand
  59496. * @param result defines Color3 object to store the result into
  59497. * @returns the unmodified current Color3
  59498. */
  59499. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59500. /**
  59501. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  59502. * @param otherColor defines the second operand
  59503. * @returns the new Color3
  59504. */
  59505. subtract(otherColor: DeepImmutable<Color3>): Color3;
  59506. /**
  59507. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  59508. * @param otherColor defines the second operand
  59509. * @param result defines Color3 object to store the result into
  59510. * @returns the unmodified current Color3
  59511. */
  59512. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59513. /**
  59514. * Copy the current object
  59515. * @returns a new Color3 copied the current one
  59516. */
  59517. clone(): Color3;
  59518. /**
  59519. * Copies the rgb values from the source in the current Color3
  59520. * @param source defines the source Color3 object
  59521. * @returns the updated Color3 object
  59522. */
  59523. copyFrom(source: DeepImmutable<Color3>): Color3;
  59524. /**
  59525. * Updates the Color3 rgb values from the given floats
  59526. * @param r defines the red component to read from
  59527. * @param g defines the green component to read from
  59528. * @param b defines the blue component to read from
  59529. * @returns the current Color3 object
  59530. */
  59531. copyFromFloats(r: number, g: number, b: number): Color3;
  59532. /**
  59533. * Updates the Color3 rgb values from the given floats
  59534. * @param r defines the red component to read from
  59535. * @param g defines the green component to read from
  59536. * @param b defines the blue component to read from
  59537. * @returns the current Color3 object
  59538. */
  59539. set(r: number, g: number, b: number): Color3;
  59540. /**
  59541. * Compute the Color3 hexadecimal code as a string
  59542. * @returns a string containing the hexadecimal representation of the Color3 object
  59543. */
  59544. toHexString(): string;
  59545. /**
  59546. * Computes a new Color3 converted from the current one to linear space
  59547. * @returns a new Color3 object
  59548. */
  59549. toLinearSpace(): Color3;
  59550. /**
  59551. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  59552. * @param convertedColor defines the Color3 object where to store the linear space version
  59553. * @returns the unmodified Color3
  59554. */
  59555. toLinearSpaceToRef(convertedColor: Color3): Color3;
  59556. /**
  59557. * Computes a new Color3 converted from the current one to gamma space
  59558. * @returns a new Color3 object
  59559. */
  59560. toGammaSpace(): Color3;
  59561. /**
  59562. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  59563. * @param convertedColor defines the Color3 object where to store the gamma space version
  59564. * @returns the unmodified Color3
  59565. */
  59566. toGammaSpaceToRef(convertedColor: Color3): Color3;
  59567. private static _BlackReadOnly;
  59568. /**
  59569. * Creates a new Color3 from the string containing valid hexadecimal values
  59570. * @param hex defines a string containing valid hexadecimal values
  59571. * @returns a new Color3 object
  59572. */
  59573. static FromHexString(hex: string): Color3;
  59574. /**
  59575. * Creates a new Vector3 from the starting index of the given array
  59576. * @param array defines the source array
  59577. * @param offset defines an offset in the source array
  59578. * @returns a new Color3 object
  59579. */
  59580. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  59581. /**
  59582. * Creates a new Color3 from integer values (< 256)
  59583. * @param r defines the red component to read from (value between 0 and 255)
  59584. * @param g defines the green component to read from (value between 0 and 255)
  59585. * @param b defines the blue component to read from (value between 0 and 255)
  59586. * @returns a new Color3 object
  59587. */
  59588. static FromInts(r: number, g: number, b: number): Color3;
  59589. /**
  59590. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59591. * @param start defines the start Color3 value
  59592. * @param end defines the end Color3 value
  59593. * @param amount defines the gradient value between start and end
  59594. * @returns a new Color3 object
  59595. */
  59596. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59597. /**
  59598. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59599. * @param left defines the start value
  59600. * @param right defines the end value
  59601. * @param amount defines the gradient factor
  59602. * @param result defines the Color3 object where to store the result
  59603. */
  59604. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59605. /**
  59606. * Returns a Color3 value containing a red color
  59607. * @returns a new Color3 object
  59608. */
  59609. static Red(): Color3;
  59610. /**
  59611. * Returns a Color3 value containing a green color
  59612. * @returns a new Color3 object
  59613. */
  59614. static Green(): Color3;
  59615. /**
  59616. * Returns a Color3 value containing a blue color
  59617. * @returns a new Color3 object
  59618. */
  59619. static Blue(): Color3;
  59620. /**
  59621. * Returns a Color3 value containing a black color
  59622. * @returns a new Color3 object
  59623. */
  59624. static Black(): Color3;
  59625. /**
  59626. * Gets a Color3 value containing a black color that must not be updated
  59627. */
  59628. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59629. /**
  59630. * Returns a Color3 value containing a white color
  59631. * @returns a new Color3 object
  59632. */
  59633. static White(): Color3;
  59634. /**
  59635. * Returns a Color3 value containing a purple color
  59636. * @returns a new Color3 object
  59637. */
  59638. static Purple(): Color3;
  59639. /**
  59640. * Returns a Color3 value containing a magenta color
  59641. * @returns a new Color3 object
  59642. */
  59643. static Magenta(): Color3;
  59644. /**
  59645. * Returns a Color3 value containing a yellow color
  59646. * @returns a new Color3 object
  59647. */
  59648. static Yellow(): Color3;
  59649. /**
  59650. * Returns a Color3 value containing a gray color
  59651. * @returns a new Color3 object
  59652. */
  59653. static Gray(): Color3;
  59654. /**
  59655. * Returns a Color3 value containing a teal color
  59656. * @returns a new Color3 object
  59657. */
  59658. static Teal(): Color3;
  59659. /**
  59660. * Returns a Color3 value containing a random color
  59661. * @returns a new Color3 object
  59662. */
  59663. static Random(): Color3;
  59664. }
  59665. /**
  59666. * Class used to hold a RBGA color
  59667. */
  59668. export class Color4 {
  59669. /**
  59670. * Defines the red component (between 0 and 1, default is 0)
  59671. */
  59672. r: number;
  59673. /**
  59674. * Defines the green component (between 0 and 1, default is 0)
  59675. */
  59676. g: number;
  59677. /**
  59678. * Defines the blue component (between 0 and 1, default is 0)
  59679. */
  59680. b: number;
  59681. /**
  59682. * Defines the alpha component (between 0 and 1, default is 1)
  59683. */
  59684. a: number;
  59685. /**
  59686. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  59687. * @param r defines the red component (between 0 and 1, default is 0)
  59688. * @param g defines the green component (between 0 and 1, default is 0)
  59689. * @param b defines the blue component (between 0 and 1, default is 0)
  59690. * @param a defines the alpha component (between 0 and 1, default is 1)
  59691. */
  59692. constructor(
  59693. /**
  59694. * Defines the red component (between 0 and 1, default is 0)
  59695. */
  59696. r?: number,
  59697. /**
  59698. * Defines the green component (between 0 and 1, default is 0)
  59699. */
  59700. g?: number,
  59701. /**
  59702. * Defines the blue component (between 0 and 1, default is 0)
  59703. */
  59704. b?: number,
  59705. /**
  59706. * Defines the alpha component (between 0 and 1, default is 1)
  59707. */
  59708. a?: number);
  59709. /**
  59710. * Adds in place the given Color4 values to the current Color4 object
  59711. * @param right defines the second operand
  59712. * @returns the current updated Color4 object
  59713. */
  59714. addInPlace(right: DeepImmutable<Color4>): Color4;
  59715. /**
  59716. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  59717. * @returns the new array
  59718. */
  59719. asArray(): number[];
  59720. /**
  59721. * Stores from the starting index in the given array the Color4 successive values
  59722. * @param array defines the array where to store the r,g,b components
  59723. * @param index defines an optional index in the target array to define where to start storing values
  59724. * @returns the current Color4 object
  59725. */
  59726. toArray(array: number[], index?: number): Color4;
  59727. /**
  59728. * Determines equality between Color4 objects
  59729. * @param otherColor defines the second operand
  59730. * @returns true if the rgba values are equal to the given ones
  59731. */
  59732. equals(otherColor: DeepImmutable<Color4>): boolean;
  59733. /**
  59734. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  59735. * @param right defines the second operand
  59736. * @returns a new Color4 object
  59737. */
  59738. add(right: DeepImmutable<Color4>): Color4;
  59739. /**
  59740. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  59741. * @param right defines the second operand
  59742. * @returns a new Color4 object
  59743. */
  59744. subtract(right: DeepImmutable<Color4>): Color4;
  59745. /**
  59746. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  59747. * @param right defines the second operand
  59748. * @param result defines the Color4 object where to store the result
  59749. * @returns the current Color4 object
  59750. */
  59751. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  59752. /**
  59753. * Creates a new Color4 with the current Color4 values multiplied by scale
  59754. * @param scale defines the scaling factor to apply
  59755. * @returns a new Color4 object
  59756. */
  59757. scale(scale: number): Color4;
  59758. /**
  59759. * Multiplies the current Color4 values by scale and stores the result in "result"
  59760. * @param scale defines the scaling factor to apply
  59761. * @param result defines the Color4 object where to store the result
  59762. * @returns the current unmodified Color4
  59763. */
  59764. scaleToRef(scale: number, result: Color4): Color4;
  59765. /**
  59766. * Scale the current Color4 values by a factor and add the result to a given Color4
  59767. * @param scale defines the scale factor
  59768. * @param result defines the Color4 object where to store the result
  59769. * @returns the unmodified current Color4
  59770. */
  59771. scaleAndAddToRef(scale: number, result: Color4): Color4;
  59772. /**
  59773. * Clamps the rgb values by the min and max values and stores the result into "result"
  59774. * @param min defines minimum clamping value (default is 0)
  59775. * @param max defines maximum clamping value (default is 1)
  59776. * @param result defines color to store the result into.
  59777. * @returns the cuurent Color4
  59778. */
  59779. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  59780. /**
  59781. * Multipy an Color4 value by another and return a new Color4 object
  59782. * @param color defines the Color4 value to multiply by
  59783. * @returns a new Color4 object
  59784. */
  59785. multiply(color: Color4): Color4;
  59786. /**
  59787. * Multipy a Color4 value by another and push the result in a reference value
  59788. * @param color defines the Color4 value to multiply by
  59789. * @param result defines the Color4 to fill the result in
  59790. * @returns the result Color4
  59791. */
  59792. multiplyToRef(color: Color4, result: Color4): Color4;
  59793. /**
  59794. * Creates a string with the Color4 current values
  59795. * @returns the string representation of the Color4 object
  59796. */
  59797. toString(): string;
  59798. /**
  59799. * Returns the string "Color4"
  59800. * @returns "Color4"
  59801. */
  59802. getClassName(): string;
  59803. /**
  59804. * Compute the Color4 hash code
  59805. * @returns an unique number that can be used to hash Color4 objects
  59806. */
  59807. getHashCode(): number;
  59808. /**
  59809. * Creates a new Color4 copied from the current one
  59810. * @returns a new Color4 object
  59811. */
  59812. clone(): Color4;
  59813. /**
  59814. * Copies the given Color4 values into the current one
  59815. * @param source defines the source Color4 object
  59816. * @returns the current updated Color4 object
  59817. */
  59818. copyFrom(source: Color4): Color4;
  59819. /**
  59820. * Copies the given float values into the current one
  59821. * @param r defines the red component to read from
  59822. * @param g defines the green component to read from
  59823. * @param b defines the blue component to read from
  59824. * @param a defines the alpha component to read from
  59825. * @returns the current updated Color4 object
  59826. */
  59827. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  59828. /**
  59829. * Copies the given float values into the current one
  59830. * @param r defines the red component to read from
  59831. * @param g defines the green component to read from
  59832. * @param b defines the blue component to read from
  59833. * @param a defines the alpha component to read from
  59834. * @returns the current updated Color4 object
  59835. */
  59836. set(r: number, g: number, b: number, a: number): Color4;
  59837. /**
  59838. * Compute the Color4 hexadecimal code as a string
  59839. * @returns a string containing the hexadecimal representation of the Color4 object
  59840. */
  59841. toHexString(): string;
  59842. /**
  59843. * Computes a new Color4 converted from the current one to linear space
  59844. * @returns a new Color4 object
  59845. */
  59846. toLinearSpace(): Color4;
  59847. /**
  59848. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  59849. * @param convertedColor defines the Color4 object where to store the linear space version
  59850. * @returns the unmodified Color4
  59851. */
  59852. toLinearSpaceToRef(convertedColor: Color4): Color4;
  59853. /**
  59854. * Computes a new Color4 converted from the current one to gamma space
  59855. * @returns a new Color4 object
  59856. */
  59857. toGammaSpace(): Color4;
  59858. /**
  59859. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  59860. * @param convertedColor defines the Color4 object where to store the gamma space version
  59861. * @returns the unmodified Color4
  59862. */
  59863. toGammaSpaceToRef(convertedColor: Color4): Color4;
  59864. /**
  59865. * Creates a new Color4 from the string containing valid hexadecimal values
  59866. * @param hex defines a string containing valid hexadecimal values
  59867. * @returns a new Color4 object
  59868. */
  59869. static FromHexString(hex: string): Color4;
  59870. /**
  59871. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59872. * @param left defines the start value
  59873. * @param right defines the end value
  59874. * @param amount defines the gradient factor
  59875. * @returns a new Color4 object
  59876. */
  59877. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  59878. /**
  59879. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59880. * @param left defines the start value
  59881. * @param right defines the end value
  59882. * @param amount defines the gradient factor
  59883. * @param result defines the Color4 object where to store data
  59884. */
  59885. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  59886. /**
  59887. * Creates a new Color4 from a Color3 and an alpha value
  59888. * @param color3 defines the source Color3 to read from
  59889. * @param alpha defines the alpha component (1.0 by default)
  59890. * @returns a new Color4 object
  59891. */
  59892. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  59893. /**
  59894. * Creates a new Color4 from the starting index element of the given array
  59895. * @param array defines the source array to read from
  59896. * @param offset defines the offset in the source array
  59897. * @returns a new Color4 object
  59898. */
  59899. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  59900. /**
  59901. * Creates a new Color3 from integer values (< 256)
  59902. * @param r defines the red component to read from (value between 0 and 255)
  59903. * @param g defines the green component to read from (value between 0 and 255)
  59904. * @param b defines the blue component to read from (value between 0 and 255)
  59905. * @param a defines the alpha component to read from (value between 0 and 255)
  59906. * @returns a new Color3 object
  59907. */
  59908. static FromInts(r: number, g: number, b: number, a: number): Color4;
  59909. /**
  59910. * Check the content of a given array and convert it to an array containing RGBA data
  59911. * If the original array was already containing count * 4 values then it is returned directly
  59912. * @param colors defines the array to check
  59913. * @param count defines the number of RGBA data to expect
  59914. * @returns an array containing count * 4 values (RGBA)
  59915. */
  59916. static CheckColors4(colors: number[], count: number): number[];
  59917. }
  59918. /**
  59919. * Class representing a vector containing 2 coordinates
  59920. */
  59921. export class Vector2 {
  59922. /** defines the first coordinate */
  59923. x: number;
  59924. /** defines the second coordinate */
  59925. y: number;
  59926. /**
  59927. * Creates a new Vector2 from the given x and y coordinates
  59928. * @param x defines the first coordinate
  59929. * @param y defines the second coordinate
  59930. */
  59931. constructor(
  59932. /** defines the first coordinate */
  59933. x?: number,
  59934. /** defines the second coordinate */
  59935. y?: number);
  59936. /**
  59937. * Gets a string with the Vector2 coordinates
  59938. * @returns a string with the Vector2 coordinates
  59939. */
  59940. toString(): string;
  59941. /**
  59942. * Gets class name
  59943. * @returns the string "Vector2"
  59944. */
  59945. getClassName(): string;
  59946. /**
  59947. * Gets current vector hash code
  59948. * @returns the Vector2 hash code as a number
  59949. */
  59950. getHashCode(): number;
  59951. /**
  59952. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  59953. * @param array defines the source array
  59954. * @param index defines the offset in source array
  59955. * @returns the current Vector2
  59956. */
  59957. toArray(array: FloatArray, index?: number): Vector2;
  59958. /**
  59959. * Copy the current vector to an array
  59960. * @returns a new array with 2 elements: the Vector2 coordinates.
  59961. */
  59962. asArray(): number[];
  59963. /**
  59964. * Sets the Vector2 coordinates with the given Vector2 coordinates
  59965. * @param source defines the source Vector2
  59966. * @returns the current updated Vector2
  59967. */
  59968. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  59969. /**
  59970. * Sets the Vector2 coordinates with the given floats
  59971. * @param x defines the first coordinate
  59972. * @param y defines the second coordinate
  59973. * @returns the current updated Vector2
  59974. */
  59975. copyFromFloats(x: number, y: number): Vector2;
  59976. /**
  59977. * Sets the Vector2 coordinates with the given floats
  59978. * @param x defines the first coordinate
  59979. * @param y defines the second coordinate
  59980. * @returns the current updated Vector2
  59981. */
  59982. set(x: number, y: number): Vector2;
  59983. /**
  59984. * Add another vector with the current one
  59985. * @param otherVector defines the other vector
  59986. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  59987. */
  59988. add(otherVector: DeepImmutable<Vector2>): Vector2;
  59989. /**
  59990. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  59991. * @param otherVector defines the other vector
  59992. * @param result defines the target vector
  59993. * @returns the unmodified current Vector2
  59994. */
  59995. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59996. /**
  59997. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  59998. * @param otherVector defines the other vector
  59999. * @returns the current updated Vector2
  60000. */
  60001. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60002. /**
  60003. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60004. * @param otherVector defines the other vector
  60005. * @returns a new Vector2
  60006. */
  60007. addVector3(otherVector: Vector3): Vector2;
  60008. /**
  60009. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60010. * @param otherVector defines the other vector
  60011. * @returns a new Vector2
  60012. */
  60013. subtract(otherVector: Vector2): Vector2;
  60014. /**
  60015. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60016. * @param otherVector defines the other vector
  60017. * @param result defines the target vector
  60018. * @returns the unmodified current Vector2
  60019. */
  60020. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60021. /**
  60022. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60023. * @param otherVector defines the other vector
  60024. * @returns the current updated Vector2
  60025. */
  60026. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60027. /**
  60028. * Multiplies in place the current Vector2 coordinates by the given ones
  60029. * @param otherVector defines the other vector
  60030. * @returns the current updated Vector2
  60031. */
  60032. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60033. /**
  60034. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60035. * @param otherVector defines the other vector
  60036. * @returns a new Vector2
  60037. */
  60038. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60039. /**
  60040. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60041. * @param otherVector defines the other vector
  60042. * @param result defines the target vector
  60043. * @returns the unmodified current Vector2
  60044. */
  60045. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60046. /**
  60047. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60048. * @param x defines the first coordinate
  60049. * @param y defines the second coordinate
  60050. * @returns a new Vector2
  60051. */
  60052. multiplyByFloats(x: number, y: number): Vector2;
  60053. /**
  60054. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60055. * @param otherVector defines the other vector
  60056. * @returns a new Vector2
  60057. */
  60058. divide(otherVector: Vector2): Vector2;
  60059. /**
  60060. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60061. * @param otherVector defines the other vector
  60062. * @param result defines the target vector
  60063. * @returns the unmodified current Vector2
  60064. */
  60065. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60066. /**
  60067. * Divides the current Vector2 coordinates by the given ones
  60068. * @param otherVector defines the other vector
  60069. * @returns the current updated Vector2
  60070. */
  60071. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60072. /**
  60073. * Gets a new Vector2 with current Vector2 negated coordinates
  60074. * @returns a new Vector2
  60075. */
  60076. negate(): Vector2;
  60077. /**
  60078. * Multiply the Vector2 coordinates by scale
  60079. * @param scale defines the scaling factor
  60080. * @returns the current updated Vector2
  60081. */
  60082. scaleInPlace(scale: number): Vector2;
  60083. /**
  60084. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60085. * @param scale defines the scaling factor
  60086. * @returns a new Vector2
  60087. */
  60088. scale(scale: number): Vector2;
  60089. /**
  60090. * Scale the current Vector2 values by a factor to a given Vector2
  60091. * @param scale defines the scale factor
  60092. * @param result defines the Vector2 object where to store the result
  60093. * @returns the unmodified current Vector2
  60094. */
  60095. scaleToRef(scale: number, result: Vector2): Vector2;
  60096. /**
  60097. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60098. * @param scale defines the scale factor
  60099. * @param result defines the Vector2 object where to store the result
  60100. * @returns the unmodified current Vector2
  60101. */
  60102. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60103. /**
  60104. * Gets a boolean if two vectors are equals
  60105. * @param otherVector defines the other vector
  60106. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60107. */
  60108. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60109. /**
  60110. * Gets a boolean if two vectors are equals (using an epsilon value)
  60111. * @param otherVector defines the other vector
  60112. * @param epsilon defines the minimal distance to consider equality
  60113. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60114. */
  60115. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60116. /**
  60117. * Gets a new Vector2 from current Vector2 floored values
  60118. * @returns a new Vector2
  60119. */
  60120. floor(): Vector2;
  60121. /**
  60122. * Gets a new Vector2 from current Vector2 floored values
  60123. * @returns a new Vector2
  60124. */
  60125. fract(): Vector2;
  60126. /**
  60127. * Gets the length of the vector
  60128. * @returns the vector length (float)
  60129. */
  60130. length(): number;
  60131. /**
  60132. * Gets the vector squared length
  60133. * @returns the vector squared length (float)
  60134. */
  60135. lengthSquared(): number;
  60136. /**
  60137. * Normalize the vector
  60138. * @returns the current updated Vector2
  60139. */
  60140. normalize(): Vector2;
  60141. /**
  60142. * Gets a new Vector2 copied from the Vector2
  60143. * @returns a new Vector2
  60144. */
  60145. clone(): Vector2;
  60146. /**
  60147. * Gets a new Vector2(0, 0)
  60148. * @returns a new Vector2
  60149. */
  60150. static Zero(): Vector2;
  60151. /**
  60152. * Gets a new Vector2(1, 1)
  60153. * @returns a new Vector2
  60154. */
  60155. static One(): Vector2;
  60156. /**
  60157. * Gets a new Vector2 set from the given index element of the given array
  60158. * @param array defines the data source
  60159. * @param offset defines the offset in the data source
  60160. * @returns a new Vector2
  60161. */
  60162. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60163. /**
  60164. * Sets "result" from the given index element of the given array
  60165. * @param array defines the data source
  60166. * @param offset defines the offset in the data source
  60167. * @param result defines the target vector
  60168. */
  60169. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60170. /**
  60171. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60172. * @param value1 defines 1st point of control
  60173. * @param value2 defines 2nd point of control
  60174. * @param value3 defines 3rd point of control
  60175. * @param value4 defines 4th point of control
  60176. * @param amount defines the interpolation factor
  60177. * @returns a new Vector2
  60178. */
  60179. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60180. /**
  60181. * 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".
  60182. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60183. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60184. * @param value defines the value to clamp
  60185. * @param min defines the lower limit
  60186. * @param max defines the upper limit
  60187. * @returns a new Vector2
  60188. */
  60189. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60190. /**
  60191. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60192. * @param value1 defines the 1st control point
  60193. * @param tangent1 defines the outgoing tangent
  60194. * @param value2 defines the 2nd control point
  60195. * @param tangent2 defines the incoming tangent
  60196. * @param amount defines the interpolation factor
  60197. * @returns a new Vector2
  60198. */
  60199. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60200. /**
  60201. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60202. * @param start defines the start vector
  60203. * @param end defines the end vector
  60204. * @param amount defines the interpolation factor
  60205. * @returns a new Vector2
  60206. */
  60207. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60208. /**
  60209. * Gets the dot product of the vector "left" and the vector "right"
  60210. * @param left defines first vector
  60211. * @param right defines second vector
  60212. * @returns the dot product (float)
  60213. */
  60214. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60215. /**
  60216. * Returns a new Vector2 equal to the normalized given vector
  60217. * @param vector defines the vector to normalize
  60218. * @returns a new Vector2
  60219. */
  60220. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  60221. /**
  60222. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  60223. * @param left defines 1st vector
  60224. * @param right defines 2nd vector
  60225. * @returns a new Vector2
  60226. */
  60227. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60228. /**
  60229. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  60230. * @param left defines 1st vector
  60231. * @param right defines 2nd vector
  60232. * @returns a new Vector2
  60233. */
  60234. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60235. /**
  60236. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  60237. * @param vector defines the vector to transform
  60238. * @param transformation defines the matrix to apply
  60239. * @returns a new Vector2
  60240. */
  60241. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  60242. /**
  60243. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  60244. * @param vector defines the vector to transform
  60245. * @param transformation defines the matrix to apply
  60246. * @param result defines the target vector
  60247. */
  60248. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  60249. /**
  60250. * Determines if a given vector is included in a triangle
  60251. * @param p defines the vector to test
  60252. * @param p0 defines 1st triangle point
  60253. * @param p1 defines 2nd triangle point
  60254. * @param p2 defines 3rd triangle point
  60255. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  60256. */
  60257. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  60258. /**
  60259. * Gets the distance between the vectors "value1" and "value2"
  60260. * @param value1 defines first vector
  60261. * @param value2 defines second vector
  60262. * @returns the distance between vectors
  60263. */
  60264. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60265. /**
  60266. * Returns the squared distance between the vectors "value1" and "value2"
  60267. * @param value1 defines first vector
  60268. * @param value2 defines second vector
  60269. * @returns the squared distance between vectors
  60270. */
  60271. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60272. /**
  60273. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  60274. * @param value1 defines first vector
  60275. * @param value2 defines second vector
  60276. * @returns a new Vector2
  60277. */
  60278. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  60279. /**
  60280. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  60281. * @param p defines the middle point
  60282. * @param segA defines one point of the segment
  60283. * @param segB defines the other point of the segment
  60284. * @returns the shortest distance
  60285. */
  60286. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  60287. }
  60288. /**
  60289. * Classed used to store (x,y,z) vector representation
  60290. * A Vector3 is the main object used in 3D geometry
  60291. * It can represent etiher the coordinates of a point the space, either a direction
  60292. * Reminder: js uses a left handed forward facing system
  60293. */
  60294. export class Vector3 {
  60295. /**
  60296. * Defines the first coordinates (on X axis)
  60297. */
  60298. x: number;
  60299. /**
  60300. * Defines the second coordinates (on Y axis)
  60301. */
  60302. y: number;
  60303. /**
  60304. * Defines the third coordinates (on Z axis)
  60305. */
  60306. z: number;
  60307. private static _UpReadOnly;
  60308. /**
  60309. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  60310. * @param x defines the first coordinates (on X axis)
  60311. * @param y defines the second coordinates (on Y axis)
  60312. * @param z defines the third coordinates (on Z axis)
  60313. */
  60314. constructor(
  60315. /**
  60316. * Defines the first coordinates (on X axis)
  60317. */
  60318. x?: number,
  60319. /**
  60320. * Defines the second coordinates (on Y axis)
  60321. */
  60322. y?: number,
  60323. /**
  60324. * Defines the third coordinates (on Z axis)
  60325. */
  60326. z?: number);
  60327. /**
  60328. * Creates a string representation of the Vector3
  60329. * @returns a string with the Vector3 coordinates.
  60330. */
  60331. toString(): string;
  60332. /**
  60333. * Gets the class name
  60334. * @returns the string "Vector3"
  60335. */
  60336. getClassName(): string;
  60337. /**
  60338. * Creates the Vector3 hash code
  60339. * @returns a number which tends to be unique between Vector3 instances
  60340. */
  60341. getHashCode(): number;
  60342. /**
  60343. * Creates an array containing three elements : the coordinates of the Vector3
  60344. * @returns a new array of numbers
  60345. */
  60346. asArray(): number[];
  60347. /**
  60348. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  60349. * @param array defines the destination array
  60350. * @param index defines the offset in the destination array
  60351. * @returns the current Vector3
  60352. */
  60353. toArray(array: FloatArray, index?: number): Vector3;
  60354. /**
  60355. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  60356. * @returns a new Quaternion object, computed from the Vector3 coordinates
  60357. */
  60358. toQuaternion(): Quaternion;
  60359. /**
  60360. * Adds the given vector to the current Vector3
  60361. * @param otherVector defines the second operand
  60362. * @returns the current updated Vector3
  60363. */
  60364. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60365. /**
  60366. * Adds the given coordinates to the current Vector3
  60367. * @param x defines the x coordinate of the operand
  60368. * @param y defines the y coordinate of the operand
  60369. * @param z defines the z coordinate of the operand
  60370. * @returns the current updated Vector3
  60371. */
  60372. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60373. /**
  60374. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  60375. * @param otherVector defines the second operand
  60376. * @returns the resulting Vector3
  60377. */
  60378. add(otherVector: DeepImmutable<Vector3>): Vector3;
  60379. /**
  60380. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  60381. * @param otherVector defines the second operand
  60382. * @param result defines the Vector3 object where to store the result
  60383. * @returns the current Vector3
  60384. */
  60385. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60386. /**
  60387. * Subtract the given vector from the current Vector3
  60388. * @param otherVector defines the second operand
  60389. * @returns the current updated Vector3
  60390. */
  60391. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60392. /**
  60393. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  60394. * @param otherVector defines the second operand
  60395. * @returns the resulting Vector3
  60396. */
  60397. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  60398. /**
  60399. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  60400. * @param otherVector defines the second operand
  60401. * @param result defines the Vector3 object where to store the result
  60402. * @returns the current Vector3
  60403. */
  60404. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60405. /**
  60406. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  60407. * @param x defines the x coordinate of the operand
  60408. * @param y defines the y coordinate of the operand
  60409. * @param z defines the z coordinate of the operand
  60410. * @returns the resulting Vector3
  60411. */
  60412. subtractFromFloats(x: number, y: number, z: number): Vector3;
  60413. /**
  60414. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  60415. * @param x defines the x coordinate of the operand
  60416. * @param y defines the y coordinate of the operand
  60417. * @param z defines the z coordinate of the operand
  60418. * @param result defines the Vector3 object where to store the result
  60419. * @returns the current Vector3
  60420. */
  60421. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  60422. /**
  60423. * Gets a new Vector3 set with the current Vector3 negated coordinates
  60424. * @returns a new Vector3
  60425. */
  60426. negate(): Vector3;
  60427. /**
  60428. * Multiplies the Vector3 coordinates by the float "scale"
  60429. * @param scale defines the multiplier factor
  60430. * @returns the current updated Vector3
  60431. */
  60432. scaleInPlace(scale: number): Vector3;
  60433. /**
  60434. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  60435. * @param scale defines the multiplier factor
  60436. * @returns a new Vector3
  60437. */
  60438. scale(scale: number): Vector3;
  60439. /**
  60440. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  60441. * @param scale defines the multiplier factor
  60442. * @param result defines the Vector3 object where to store the result
  60443. * @returns the current Vector3
  60444. */
  60445. scaleToRef(scale: number, result: Vector3): Vector3;
  60446. /**
  60447. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  60448. * @param scale defines the scale factor
  60449. * @param result defines the Vector3 object where to store the result
  60450. * @returns the unmodified current Vector3
  60451. */
  60452. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  60453. /**
  60454. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  60455. * @param otherVector defines the second operand
  60456. * @returns true if both vectors are equals
  60457. */
  60458. equals(otherVector: DeepImmutable<Vector3>): boolean;
  60459. /**
  60460. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  60461. * @param otherVector defines the second operand
  60462. * @param epsilon defines the minimal distance to define values as equals
  60463. * @returns true if both vectors are distant less than epsilon
  60464. */
  60465. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  60466. /**
  60467. * Returns true if the current Vector3 coordinates equals the given floats
  60468. * @param x defines the x coordinate of the operand
  60469. * @param y defines the y coordinate of the operand
  60470. * @param z defines the z coordinate of the operand
  60471. * @returns true if both vectors are equals
  60472. */
  60473. equalsToFloats(x: number, y: number, z: number): boolean;
  60474. /**
  60475. * Multiplies the current Vector3 coordinates by the given ones
  60476. * @param otherVector defines the second operand
  60477. * @returns the current updated Vector3
  60478. */
  60479. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60480. /**
  60481. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  60482. * @param otherVector defines the second operand
  60483. * @returns the new Vector3
  60484. */
  60485. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  60486. /**
  60487. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  60488. * @param otherVector defines the second operand
  60489. * @param result defines the Vector3 object where to store the result
  60490. * @returns the current Vector3
  60491. */
  60492. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60493. /**
  60494. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  60495. * @param x defines the x coordinate of the operand
  60496. * @param y defines the y coordinate of the operand
  60497. * @param z defines the z coordinate of the operand
  60498. * @returns the new Vector3
  60499. */
  60500. multiplyByFloats(x: number, y: number, z: number): Vector3;
  60501. /**
  60502. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  60503. * @param otherVector defines the second operand
  60504. * @returns the new Vector3
  60505. */
  60506. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  60507. /**
  60508. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  60509. * @param otherVector defines the second operand
  60510. * @param result defines the Vector3 object where to store the result
  60511. * @returns the current Vector3
  60512. */
  60513. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60514. /**
  60515. * Divides the current Vector3 coordinates by the given ones.
  60516. * @param otherVector defines the second operand
  60517. * @returns the current updated Vector3
  60518. */
  60519. divideInPlace(otherVector: Vector3): Vector3;
  60520. /**
  60521. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  60522. * @param other defines the second operand
  60523. * @returns the current updated Vector3
  60524. */
  60525. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60526. /**
  60527. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  60528. * @param other defines the second operand
  60529. * @returns the current updated Vector3
  60530. */
  60531. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60532. /**
  60533. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  60534. * @param x defines the x coordinate of the operand
  60535. * @param y defines the y coordinate of the operand
  60536. * @param z defines the z coordinate of the operand
  60537. * @returns the current updated Vector3
  60538. */
  60539. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60540. /**
  60541. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  60542. * @param x defines the x coordinate of the operand
  60543. * @param y defines the y coordinate of the operand
  60544. * @param z defines the z coordinate of the operand
  60545. * @returns the current updated Vector3
  60546. */
  60547. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60548. /**
  60549. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  60550. * Check if is non uniform within a certain amount of decimal places to account for this
  60551. * @param epsilon the amount the values can differ
  60552. * @returns if the the vector is non uniform to a certain number of decimal places
  60553. */
  60554. isNonUniformWithinEpsilon(epsilon: number): boolean;
  60555. /**
  60556. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  60557. */
  60558. readonly isNonUniform: boolean;
  60559. /**
  60560. * Gets a new Vector3 from current Vector3 floored values
  60561. * @returns a new Vector3
  60562. */
  60563. floor(): Vector3;
  60564. /**
  60565. * Gets a new Vector3 from current Vector3 floored values
  60566. * @returns a new Vector3
  60567. */
  60568. fract(): Vector3;
  60569. /**
  60570. * Gets the length of the Vector3
  60571. * @returns the length of the Vecto3
  60572. */
  60573. length(): number;
  60574. /**
  60575. * Gets the squared length of the Vector3
  60576. * @returns squared length of the Vector3
  60577. */
  60578. lengthSquared(): number;
  60579. /**
  60580. * Normalize the current Vector3.
  60581. * Please note that this is an in place operation.
  60582. * @returns the current updated Vector3
  60583. */
  60584. normalize(): Vector3;
  60585. /**
  60586. * Reorders the x y z properties of the vector in place
  60587. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60588. * @returns the current updated vector
  60589. */
  60590. reorderInPlace(order: string): this;
  60591. /**
  60592. * Rotates the vector around 0,0,0 by a quaternion
  60593. * @param quaternion the rotation quaternion
  60594. * @param result vector to store the result
  60595. * @returns the resulting vector
  60596. */
  60597. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60598. /**
  60599. * Rotates a vector around a given point
  60600. * @param quaternion the rotation quaternion
  60601. * @param point the point to rotate around
  60602. * @param result vector to store the result
  60603. * @returns the resulting vector
  60604. */
  60605. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60606. /**
  60607. * Normalize the current Vector3 with the given input length.
  60608. * Please note that this is an in place operation.
  60609. * @param len the length of the vector
  60610. * @returns the current updated Vector3
  60611. */
  60612. normalizeFromLength(len: number): Vector3;
  60613. /**
  60614. * Normalize the current Vector3 to a new vector
  60615. * @returns the new Vector3
  60616. */
  60617. normalizeToNew(): Vector3;
  60618. /**
  60619. * Normalize the current Vector3 to the reference
  60620. * @param reference define the Vector3 to update
  60621. * @returns the updated Vector3
  60622. */
  60623. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60624. /**
  60625. * Creates a new Vector3 copied from the current Vector3
  60626. * @returns the new Vector3
  60627. */
  60628. clone(): Vector3;
  60629. /**
  60630. * Copies the given vector coordinates to the current Vector3 ones
  60631. * @param source defines the source Vector3
  60632. * @returns the current updated Vector3
  60633. */
  60634. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60635. /**
  60636. * Copies the given floats to the current Vector3 coordinates
  60637. * @param x defines the x coordinate of the operand
  60638. * @param y defines the y coordinate of the operand
  60639. * @param z defines the z coordinate of the operand
  60640. * @returns the current updated Vector3
  60641. */
  60642. copyFromFloats(x: number, y: number, z: number): Vector3;
  60643. /**
  60644. * Copies the given floats to the current Vector3 coordinates
  60645. * @param x defines the x coordinate of the operand
  60646. * @param y defines the y coordinate of the operand
  60647. * @param z defines the z coordinate of the operand
  60648. * @returns the current updated Vector3
  60649. */
  60650. set(x: number, y: number, z: number): Vector3;
  60651. /**
  60652. * Copies the given float to the current Vector3 coordinates
  60653. * @param v defines the x, y and z coordinates of the operand
  60654. * @returns the current updated Vector3
  60655. */
  60656. setAll(v: number): Vector3;
  60657. /**
  60658. * Get the clip factor between two vectors
  60659. * @param vector0 defines the first operand
  60660. * @param vector1 defines the second operand
  60661. * @param axis defines the axis to use
  60662. * @param size defines the size along the axis
  60663. * @returns the clip factor
  60664. */
  60665. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60666. /**
  60667. * Get angle between two vectors
  60668. * @param vector0 angle between vector0 and vector1
  60669. * @param vector1 angle between vector0 and vector1
  60670. * @param normal direction of the normal
  60671. * @return the angle between vector0 and vector1
  60672. */
  60673. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  60674. /**
  60675. * Returns a new Vector3 set from the index "offset" of the given array
  60676. * @param array defines the source array
  60677. * @param offset defines the offset in the source array
  60678. * @returns the new Vector3
  60679. */
  60680. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  60681. /**
  60682. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  60683. * This function is deprecated. Use FromArray instead
  60684. * @param array defines the source array
  60685. * @param offset defines the offset in the source array
  60686. * @returns the new Vector3
  60687. */
  60688. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  60689. /**
  60690. * Sets the given vector "result" with the element values from the index "offset" of the given array
  60691. * @param array defines the source array
  60692. * @param offset defines the offset in the source array
  60693. * @param result defines the Vector3 where to store the result
  60694. */
  60695. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  60696. /**
  60697. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  60698. * This function is deprecated. Use FromArrayToRef instead.
  60699. * @param array defines the source array
  60700. * @param offset defines the offset in the source array
  60701. * @param result defines the Vector3 where to store the result
  60702. */
  60703. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  60704. /**
  60705. * Sets the given vector "result" with the given floats.
  60706. * @param x defines the x coordinate of the source
  60707. * @param y defines the y coordinate of the source
  60708. * @param z defines the z coordinate of the source
  60709. * @param result defines the Vector3 where to store the result
  60710. */
  60711. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  60712. /**
  60713. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  60714. * @returns a new empty Vector3
  60715. */
  60716. static Zero(): Vector3;
  60717. /**
  60718. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  60719. * @returns a new unit Vector3
  60720. */
  60721. static One(): Vector3;
  60722. /**
  60723. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  60724. * @returns a new up Vector3
  60725. */
  60726. static Up(): Vector3;
  60727. /**
  60728. * Gets a up Vector3 that must not be updated
  60729. */
  60730. static readonly UpReadOnly: DeepImmutable<Vector3>;
  60731. /**
  60732. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  60733. * @returns a new down Vector3
  60734. */
  60735. static Down(): Vector3;
  60736. /**
  60737. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  60738. * @returns a new forward Vector3
  60739. */
  60740. static Forward(): Vector3;
  60741. /**
  60742. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  60743. * @returns a new forward Vector3
  60744. */
  60745. static Backward(): Vector3;
  60746. /**
  60747. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  60748. * @returns a new right Vector3
  60749. */
  60750. static Right(): Vector3;
  60751. /**
  60752. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  60753. * @returns a new left Vector3
  60754. */
  60755. static Left(): Vector3;
  60756. /**
  60757. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  60758. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60759. * @param vector defines the Vector3 to transform
  60760. * @param transformation defines the transformation matrix
  60761. * @returns the transformed Vector3
  60762. */
  60763. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60764. /**
  60765. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  60766. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60767. * @param vector defines the Vector3 to transform
  60768. * @param transformation defines the transformation matrix
  60769. * @param result defines the Vector3 where to store the result
  60770. */
  60771. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60772. /**
  60773. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  60774. * This method computes tranformed coordinates only, not transformed direction vectors
  60775. * @param x define the x coordinate of the source vector
  60776. * @param y define the y coordinate of the source vector
  60777. * @param z define the z coordinate of the source vector
  60778. * @param transformation defines the transformation matrix
  60779. * @param result defines the Vector3 where to store the result
  60780. */
  60781. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60782. /**
  60783. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  60784. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60785. * @param vector defines the Vector3 to transform
  60786. * @param transformation defines the transformation matrix
  60787. * @returns the new Vector3
  60788. */
  60789. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60790. /**
  60791. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  60792. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60793. * @param vector defines the Vector3 to transform
  60794. * @param transformation defines the transformation matrix
  60795. * @param result defines the Vector3 where to store the result
  60796. */
  60797. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60798. /**
  60799. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  60800. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60801. * @param x define the x coordinate of the source vector
  60802. * @param y define the y coordinate of the source vector
  60803. * @param z define the z coordinate of the source vector
  60804. * @param transformation defines the transformation matrix
  60805. * @param result defines the Vector3 where to store the result
  60806. */
  60807. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60808. /**
  60809. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  60810. * @param value1 defines the first control point
  60811. * @param value2 defines the second control point
  60812. * @param value3 defines the third control point
  60813. * @param value4 defines the fourth control point
  60814. * @param amount defines the amount on the spline to use
  60815. * @returns the new Vector3
  60816. */
  60817. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  60818. /**
  60819. * 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"
  60820. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60821. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60822. * @param value defines the current value
  60823. * @param min defines the lower range value
  60824. * @param max defines the upper range value
  60825. * @returns the new Vector3
  60826. */
  60827. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  60828. /**
  60829. * 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"
  60830. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60831. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60832. * @param value defines the current value
  60833. * @param min defines the lower range value
  60834. * @param max defines the upper range value
  60835. * @param result defines the Vector3 where to store the result
  60836. */
  60837. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  60838. /**
  60839. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  60840. * @param value1 defines the first control point
  60841. * @param tangent1 defines the first tangent vector
  60842. * @param value2 defines the second control point
  60843. * @param tangent2 defines the second tangent vector
  60844. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  60845. * @returns the new Vector3
  60846. */
  60847. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  60848. /**
  60849. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  60850. * @param start defines the start value
  60851. * @param end defines the end value
  60852. * @param amount max defines amount between both (between 0 and 1)
  60853. * @returns the new Vector3
  60854. */
  60855. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  60856. /**
  60857. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  60858. * @param start defines the start value
  60859. * @param end defines the end value
  60860. * @param amount max defines amount between both (between 0 and 1)
  60861. * @param result defines the Vector3 where to store the result
  60862. */
  60863. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  60864. /**
  60865. * Returns the dot product (float) between the vectors "left" and "right"
  60866. * @param left defines the left operand
  60867. * @param right defines the right operand
  60868. * @returns the dot product
  60869. */
  60870. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  60871. /**
  60872. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  60873. * The cross product is then orthogonal to both "left" and "right"
  60874. * @param left defines the left operand
  60875. * @param right defines the right operand
  60876. * @returns the cross product
  60877. */
  60878. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60879. /**
  60880. * Sets the given vector "result" with the cross product of "left" and "right"
  60881. * The cross product is then orthogonal to both "left" and "right"
  60882. * @param left defines the left operand
  60883. * @param right defines the right operand
  60884. * @param result defines the Vector3 where to store the result
  60885. */
  60886. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  60887. /**
  60888. * Returns a new Vector3 as the normalization of the given vector
  60889. * @param vector defines the Vector3 to normalize
  60890. * @returns the new Vector3
  60891. */
  60892. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  60893. /**
  60894. * Sets the given vector "result" with the normalization of the given first vector
  60895. * @param vector defines the Vector3 to normalize
  60896. * @param result defines the Vector3 where to store the result
  60897. */
  60898. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  60899. /**
  60900. * Project a Vector3 onto screen space
  60901. * @param vector defines the Vector3 to project
  60902. * @param world defines the world matrix to use
  60903. * @param transform defines the transform (view x projection) matrix to use
  60904. * @param viewport defines the screen viewport to use
  60905. * @returns the new Vector3
  60906. */
  60907. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  60908. /** @hidden */
  60909. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  60910. /**
  60911. * Unproject from screen space to object space
  60912. * @param source defines the screen space Vector3 to use
  60913. * @param viewportWidth defines the current width of the viewport
  60914. * @param viewportHeight defines the current height of the viewport
  60915. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60916. * @param transform defines the transform (view x projection) matrix to use
  60917. * @returns the new Vector3
  60918. */
  60919. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  60920. /**
  60921. * Unproject from screen space to object space
  60922. * @param source defines the screen space Vector3 to use
  60923. * @param viewportWidth defines the current width of the viewport
  60924. * @param viewportHeight defines the current height of the viewport
  60925. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60926. * @param view defines the view matrix to use
  60927. * @param projection defines the projection matrix to use
  60928. * @returns the new Vector3
  60929. */
  60930. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  60931. /**
  60932. * Unproject from screen space to object space
  60933. * @param source defines the screen space Vector3 to use
  60934. * @param viewportWidth defines the current width of the viewport
  60935. * @param viewportHeight defines the current height of the viewport
  60936. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60937. * @param view defines the view matrix to use
  60938. * @param projection defines the projection matrix to use
  60939. * @param result defines the Vector3 where to store the result
  60940. */
  60941. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60942. /**
  60943. * Unproject from screen space to object space
  60944. * @param sourceX defines the screen space x coordinate to use
  60945. * @param sourceY defines the screen space y coordinate to use
  60946. * @param sourceZ defines the screen space z coordinate to use
  60947. * @param viewportWidth defines the current width of the viewport
  60948. * @param viewportHeight defines the current height of the viewport
  60949. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60950. * @param view defines the view matrix to use
  60951. * @param projection defines the projection matrix to use
  60952. * @param result defines the Vector3 where to store the result
  60953. */
  60954. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60955. /**
  60956. * Gets the minimal coordinate values between two Vector3
  60957. * @param left defines the first operand
  60958. * @param right defines the second operand
  60959. * @returns the new Vector3
  60960. */
  60961. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60962. /**
  60963. * Gets the maximal coordinate values between two Vector3
  60964. * @param left defines the first operand
  60965. * @param right defines the second operand
  60966. * @returns the new Vector3
  60967. */
  60968. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60969. /**
  60970. * Returns the distance between the vectors "value1" and "value2"
  60971. * @param value1 defines the first operand
  60972. * @param value2 defines the second operand
  60973. * @returns the distance
  60974. */
  60975. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60976. /**
  60977. * Returns the squared distance between the vectors "value1" and "value2"
  60978. * @param value1 defines the first operand
  60979. * @param value2 defines the second operand
  60980. * @returns the squared distance
  60981. */
  60982. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60983. /**
  60984. * Returns a new Vector3 located at the center between "value1" and "value2"
  60985. * @param value1 defines the first operand
  60986. * @param value2 defines the second operand
  60987. * @returns the new Vector3
  60988. */
  60989. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  60990. /**
  60991. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  60992. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  60993. * to something in order to rotate it from its local system to the given target system
  60994. * Note: axis1, axis2 and axis3 are normalized during this operation
  60995. * @param axis1 defines the first axis
  60996. * @param axis2 defines the second axis
  60997. * @param axis3 defines the third axis
  60998. * @returns a new Vector3
  60999. */
  61000. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61001. /**
  61002. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61003. * @param axis1 defines the first axis
  61004. * @param axis2 defines the second axis
  61005. * @param axis3 defines the third axis
  61006. * @param ref defines the Vector3 where to store the result
  61007. */
  61008. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61009. }
  61010. /**
  61011. * Vector4 class created for EulerAngle class conversion to Quaternion
  61012. */
  61013. export class Vector4 {
  61014. /** x value of the vector */
  61015. x: number;
  61016. /** y value of the vector */
  61017. y: number;
  61018. /** z value of the vector */
  61019. z: number;
  61020. /** w value of the vector */
  61021. w: number;
  61022. /**
  61023. * Creates a Vector4 object from the given floats.
  61024. * @param x x value of the vector
  61025. * @param y y value of the vector
  61026. * @param z z value of the vector
  61027. * @param w w value of the vector
  61028. */
  61029. constructor(
  61030. /** x value of the vector */
  61031. x: number,
  61032. /** y value of the vector */
  61033. y: number,
  61034. /** z value of the vector */
  61035. z: number,
  61036. /** w value of the vector */
  61037. w: number);
  61038. /**
  61039. * Returns the string with the Vector4 coordinates.
  61040. * @returns a string containing all the vector values
  61041. */
  61042. toString(): string;
  61043. /**
  61044. * Returns the string "Vector4".
  61045. * @returns "Vector4"
  61046. */
  61047. getClassName(): string;
  61048. /**
  61049. * Returns the Vector4 hash code.
  61050. * @returns a unique hash code
  61051. */
  61052. getHashCode(): number;
  61053. /**
  61054. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61055. * @returns the resulting array
  61056. */
  61057. asArray(): number[];
  61058. /**
  61059. * Populates the given array from the given index with the Vector4 coordinates.
  61060. * @param array array to populate
  61061. * @param index index of the array to start at (default: 0)
  61062. * @returns the Vector4.
  61063. */
  61064. toArray(array: FloatArray, index?: number): Vector4;
  61065. /**
  61066. * Adds the given vector to the current Vector4.
  61067. * @param otherVector the vector to add
  61068. * @returns the updated Vector4.
  61069. */
  61070. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61071. /**
  61072. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61073. * @param otherVector the vector to add
  61074. * @returns the resulting vector
  61075. */
  61076. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61077. /**
  61078. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61079. * @param otherVector the vector to add
  61080. * @param result the vector to store the result
  61081. * @returns the current Vector4.
  61082. */
  61083. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61084. /**
  61085. * Subtract in place the given vector from the current Vector4.
  61086. * @param otherVector the vector to subtract
  61087. * @returns the updated Vector4.
  61088. */
  61089. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61090. /**
  61091. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61092. * @param otherVector the vector to add
  61093. * @returns the new vector with the result
  61094. */
  61095. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61096. /**
  61097. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61098. * @param otherVector the vector to subtract
  61099. * @param result the vector to store the result
  61100. * @returns the current Vector4.
  61101. */
  61102. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61103. /**
  61104. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61105. */
  61106. /**
  61107. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61108. * @param x value to subtract
  61109. * @param y value to subtract
  61110. * @param z value to subtract
  61111. * @param w value to subtract
  61112. * @returns new vector containing the result
  61113. */
  61114. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61115. /**
  61116. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61117. * @param x value to subtract
  61118. * @param y value to subtract
  61119. * @param z value to subtract
  61120. * @param w value to subtract
  61121. * @param result the vector to store the result in
  61122. * @returns the current Vector4.
  61123. */
  61124. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61125. /**
  61126. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61127. * @returns a new vector with the negated values
  61128. */
  61129. negate(): Vector4;
  61130. /**
  61131. * Multiplies the current Vector4 coordinates by scale (float).
  61132. * @param scale the number to scale with
  61133. * @returns the updated Vector4.
  61134. */
  61135. scaleInPlace(scale: number): Vector4;
  61136. /**
  61137. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61138. * @param scale the number to scale with
  61139. * @returns a new vector with the result
  61140. */
  61141. scale(scale: number): Vector4;
  61142. /**
  61143. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61144. * @param scale the number to scale with
  61145. * @param result a vector to store the result in
  61146. * @returns the current Vector4.
  61147. */
  61148. scaleToRef(scale: number, result: Vector4): Vector4;
  61149. /**
  61150. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61151. * @param scale defines the scale factor
  61152. * @param result defines the Vector4 object where to store the result
  61153. * @returns the unmodified current Vector4
  61154. */
  61155. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61156. /**
  61157. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61158. * @param otherVector the vector to compare against
  61159. * @returns true if they are equal
  61160. */
  61161. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61162. /**
  61163. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61164. * @param otherVector vector to compare against
  61165. * @param epsilon (Default: very small number)
  61166. * @returns true if they are equal
  61167. */
  61168. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61169. /**
  61170. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61171. * @param x x value to compare against
  61172. * @param y y value to compare against
  61173. * @param z z value to compare against
  61174. * @param w w value to compare against
  61175. * @returns true if equal
  61176. */
  61177. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61178. /**
  61179. * Multiplies in place the current Vector4 by the given one.
  61180. * @param otherVector vector to multiple with
  61181. * @returns the updated Vector4.
  61182. */
  61183. multiplyInPlace(otherVector: Vector4): Vector4;
  61184. /**
  61185. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61186. * @param otherVector vector to multiple with
  61187. * @returns resulting new vector
  61188. */
  61189. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61190. /**
  61191. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61192. * @param otherVector vector to multiple with
  61193. * @param result vector to store the result
  61194. * @returns the current Vector4.
  61195. */
  61196. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61197. /**
  61198. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61199. * @param x x value multiply with
  61200. * @param y y value multiply with
  61201. * @param z z value multiply with
  61202. * @param w w value multiply with
  61203. * @returns resulting new vector
  61204. */
  61205. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61206. /**
  61207. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61208. * @param otherVector vector to devide with
  61209. * @returns resulting new vector
  61210. */
  61211. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61212. /**
  61213. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61214. * @param otherVector vector to devide with
  61215. * @param result vector to store the result
  61216. * @returns the current Vector4.
  61217. */
  61218. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61219. /**
  61220. * Divides the current Vector3 coordinates by the given ones.
  61221. * @param otherVector vector to devide with
  61222. * @returns the updated Vector3.
  61223. */
  61224. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61225. /**
  61226. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  61227. * @param other defines the second operand
  61228. * @returns the current updated Vector4
  61229. */
  61230. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61231. /**
  61232. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  61233. * @param other defines the second operand
  61234. * @returns the current updated Vector4
  61235. */
  61236. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61237. /**
  61238. * Gets a new Vector4 from current Vector4 floored values
  61239. * @returns a new Vector4
  61240. */
  61241. floor(): Vector4;
  61242. /**
  61243. * Gets a new Vector4 from current Vector3 floored values
  61244. * @returns a new Vector4
  61245. */
  61246. fract(): Vector4;
  61247. /**
  61248. * Returns the Vector4 length (float).
  61249. * @returns the length
  61250. */
  61251. length(): number;
  61252. /**
  61253. * Returns the Vector4 squared length (float).
  61254. * @returns the length squared
  61255. */
  61256. lengthSquared(): number;
  61257. /**
  61258. * Normalizes in place the Vector4.
  61259. * @returns the updated Vector4.
  61260. */
  61261. normalize(): Vector4;
  61262. /**
  61263. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  61264. * @returns this converted to a new vector3
  61265. */
  61266. toVector3(): Vector3;
  61267. /**
  61268. * Returns a new Vector4 copied from the current one.
  61269. * @returns the new cloned vector
  61270. */
  61271. clone(): Vector4;
  61272. /**
  61273. * Updates the current Vector4 with the given one coordinates.
  61274. * @param source the source vector to copy from
  61275. * @returns the updated Vector4.
  61276. */
  61277. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  61278. /**
  61279. * Updates the current Vector4 coordinates with the given floats.
  61280. * @param x float to copy from
  61281. * @param y float to copy from
  61282. * @param z float to copy from
  61283. * @param w float to copy from
  61284. * @returns the updated Vector4.
  61285. */
  61286. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61287. /**
  61288. * Updates the current Vector4 coordinates with the given floats.
  61289. * @param x float to set from
  61290. * @param y float to set from
  61291. * @param z float to set from
  61292. * @param w float to set from
  61293. * @returns the updated Vector4.
  61294. */
  61295. set(x: number, y: number, z: number, w: number): Vector4;
  61296. /**
  61297. * Copies the given float to the current Vector3 coordinates
  61298. * @param v defines the x, y, z and w coordinates of the operand
  61299. * @returns the current updated Vector3
  61300. */
  61301. setAll(v: number): Vector4;
  61302. /**
  61303. * Returns a new Vector4 set from the starting index of the given array.
  61304. * @param array the array to pull values from
  61305. * @param offset the offset into the array to start at
  61306. * @returns the new vector
  61307. */
  61308. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  61309. /**
  61310. * Updates the given vector "result" from the starting index of the given array.
  61311. * @param array the array to pull values from
  61312. * @param offset the offset into the array to start at
  61313. * @param result the vector to store the result in
  61314. */
  61315. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  61316. /**
  61317. * Updates the given vector "result" from the starting index of the given Float32Array.
  61318. * @param array the array to pull values from
  61319. * @param offset the offset into the array to start at
  61320. * @param result the vector to store the result in
  61321. */
  61322. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  61323. /**
  61324. * Updates the given vector "result" coordinates from the given floats.
  61325. * @param x float to set from
  61326. * @param y float to set from
  61327. * @param z float to set from
  61328. * @param w float to set from
  61329. * @param result the vector to the floats in
  61330. */
  61331. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  61332. /**
  61333. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  61334. * @returns the new vector
  61335. */
  61336. static Zero(): Vector4;
  61337. /**
  61338. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  61339. * @returns the new vector
  61340. */
  61341. static One(): Vector4;
  61342. /**
  61343. * Returns a new normalized Vector4 from the given one.
  61344. * @param vector the vector to normalize
  61345. * @returns the vector
  61346. */
  61347. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  61348. /**
  61349. * Updates the given vector "result" from the normalization of the given one.
  61350. * @param vector the vector to normalize
  61351. * @param result the vector to store the result in
  61352. */
  61353. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  61354. /**
  61355. * Returns a vector with the minimum values from the left and right vectors
  61356. * @param left left vector to minimize
  61357. * @param right right vector to minimize
  61358. * @returns a new vector with the minimum of the left and right vector values
  61359. */
  61360. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61361. /**
  61362. * Returns a vector with the maximum values from the left and right vectors
  61363. * @param left left vector to maximize
  61364. * @param right right vector to maximize
  61365. * @returns a new vector with the maximum of the left and right vector values
  61366. */
  61367. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61368. /**
  61369. * Returns the distance (float) between the vectors "value1" and "value2".
  61370. * @param value1 value to calulate the distance between
  61371. * @param value2 value to calulate the distance between
  61372. * @return the distance between the two vectors
  61373. */
  61374. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61375. /**
  61376. * Returns the squared distance (float) between the vectors "value1" and "value2".
  61377. * @param value1 value to calulate the distance between
  61378. * @param value2 value to calulate the distance between
  61379. * @return the distance between the two vectors squared
  61380. */
  61381. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61382. /**
  61383. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  61384. * @param value1 value to calulate the center between
  61385. * @param value2 value to calulate the center between
  61386. * @return the center between the two vectors
  61387. */
  61388. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  61389. /**
  61390. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  61391. * This methods computes transformed normalized direction vectors only.
  61392. * @param vector the vector to transform
  61393. * @param transformation the transformation matrix to apply
  61394. * @returns the new vector
  61395. */
  61396. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  61397. /**
  61398. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  61399. * This methods computes transformed normalized direction vectors only.
  61400. * @param vector the vector to transform
  61401. * @param transformation the transformation matrix to apply
  61402. * @param result the vector to store the result in
  61403. */
  61404. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61405. /**
  61406. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  61407. * This methods computes transformed normalized direction vectors only.
  61408. * @param x value to transform
  61409. * @param y value to transform
  61410. * @param z value to transform
  61411. * @param w value to transform
  61412. * @param transformation the transformation matrix to apply
  61413. * @param result the vector to store the results in
  61414. */
  61415. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61416. /**
  61417. * Creates a new Vector4 from a Vector3
  61418. * @param source defines the source data
  61419. * @param w defines the 4th component (default is 0)
  61420. * @returns a new Vector4
  61421. */
  61422. static FromVector3(source: Vector3, w?: number): Vector4;
  61423. }
  61424. /**
  61425. * Interface for the size containing width and height
  61426. */
  61427. export interface ISize {
  61428. /**
  61429. * Width
  61430. */
  61431. width: number;
  61432. /**
  61433. * Heighht
  61434. */
  61435. height: number;
  61436. }
  61437. /**
  61438. * Size containing widht and height
  61439. */
  61440. export class Size implements ISize {
  61441. /**
  61442. * Width
  61443. */
  61444. width: number;
  61445. /**
  61446. * Height
  61447. */
  61448. height: number;
  61449. /**
  61450. * Creates a Size object from the given width and height (floats).
  61451. * @param width width of the new size
  61452. * @param height height of the new size
  61453. */
  61454. constructor(width: number, height: number);
  61455. /**
  61456. * Returns a string with the Size width and height
  61457. * @returns a string with the Size width and height
  61458. */
  61459. toString(): string;
  61460. /**
  61461. * "Size"
  61462. * @returns the string "Size"
  61463. */
  61464. getClassName(): string;
  61465. /**
  61466. * Returns the Size hash code.
  61467. * @returns a hash code for a unique width and height
  61468. */
  61469. getHashCode(): number;
  61470. /**
  61471. * Updates the current size from the given one.
  61472. * @param src the given size
  61473. */
  61474. copyFrom(src: Size): void;
  61475. /**
  61476. * Updates in place the current Size from the given floats.
  61477. * @param width width of the new size
  61478. * @param height height of the new size
  61479. * @returns the updated Size.
  61480. */
  61481. copyFromFloats(width: number, height: number): Size;
  61482. /**
  61483. * Updates in place the current Size from the given floats.
  61484. * @param width width to set
  61485. * @param height height to set
  61486. * @returns the updated Size.
  61487. */
  61488. set(width: number, height: number): Size;
  61489. /**
  61490. * Multiplies the width and height by numbers
  61491. * @param w factor to multiple the width by
  61492. * @param h factor to multiple the height by
  61493. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  61494. */
  61495. multiplyByFloats(w: number, h: number): Size;
  61496. /**
  61497. * Clones the size
  61498. * @returns a new Size copied from the given one.
  61499. */
  61500. clone(): Size;
  61501. /**
  61502. * True if the current Size and the given one width and height are strictly equal.
  61503. * @param other the other size to compare against
  61504. * @returns True if the current Size and the given one width and height are strictly equal.
  61505. */
  61506. equals(other: Size): boolean;
  61507. /**
  61508. * The surface of the Size : width * height (float).
  61509. */
  61510. readonly surface: number;
  61511. /**
  61512. * Create a new size of zero
  61513. * @returns a new Size set to (0.0, 0.0)
  61514. */
  61515. static Zero(): Size;
  61516. /**
  61517. * Sums the width and height of two sizes
  61518. * @param otherSize size to add to this size
  61519. * @returns a new Size set as the addition result of the current Size and the given one.
  61520. */
  61521. add(otherSize: Size): Size;
  61522. /**
  61523. * Subtracts the width and height of two
  61524. * @param otherSize size to subtract to this size
  61525. * @returns a new Size set as the subtraction result of the given one from the current Size.
  61526. */
  61527. subtract(otherSize: Size): Size;
  61528. /**
  61529. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  61530. * @param start starting size to lerp between
  61531. * @param end end size to lerp between
  61532. * @param amount amount to lerp between the start and end values
  61533. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  61534. */
  61535. static Lerp(start: Size, end: Size, amount: number): Size;
  61536. }
  61537. /**
  61538. * Class used to store quaternion data
  61539. * @see https://en.wikipedia.org/wiki/Quaternion
  61540. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  61541. */
  61542. export class Quaternion {
  61543. /** defines the first component (0 by default) */
  61544. x: number;
  61545. /** defines the second component (0 by default) */
  61546. y: number;
  61547. /** defines the third component (0 by default) */
  61548. z: number;
  61549. /** defines the fourth component (1.0 by default) */
  61550. w: number;
  61551. /**
  61552. * Creates a new Quaternion from the given floats
  61553. * @param x defines the first component (0 by default)
  61554. * @param y defines the second component (0 by default)
  61555. * @param z defines the third component (0 by default)
  61556. * @param w defines the fourth component (1.0 by default)
  61557. */
  61558. constructor(
  61559. /** defines the first component (0 by default) */
  61560. x?: number,
  61561. /** defines the second component (0 by default) */
  61562. y?: number,
  61563. /** defines the third component (0 by default) */
  61564. z?: number,
  61565. /** defines the fourth component (1.0 by default) */
  61566. w?: number);
  61567. /**
  61568. * Gets a string representation for the current quaternion
  61569. * @returns a string with the Quaternion coordinates
  61570. */
  61571. toString(): string;
  61572. /**
  61573. * Gets the class name of the quaternion
  61574. * @returns the string "Quaternion"
  61575. */
  61576. getClassName(): string;
  61577. /**
  61578. * Gets a hash code for this quaternion
  61579. * @returns the quaternion hash code
  61580. */
  61581. getHashCode(): number;
  61582. /**
  61583. * Copy the quaternion to an array
  61584. * @returns a new array populated with 4 elements from the quaternion coordinates
  61585. */
  61586. asArray(): number[];
  61587. /**
  61588. * Check if two quaternions are equals
  61589. * @param otherQuaternion defines the second operand
  61590. * @return true if the current quaternion and the given one coordinates are strictly equals
  61591. */
  61592. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61593. /**
  61594. * Clone the current quaternion
  61595. * @returns a new quaternion copied from the current one
  61596. */
  61597. clone(): Quaternion;
  61598. /**
  61599. * Copy a quaternion to the current one
  61600. * @param other defines the other quaternion
  61601. * @returns the updated current quaternion
  61602. */
  61603. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61604. /**
  61605. * Updates the current quaternion with the given float coordinates
  61606. * @param x defines the x coordinate
  61607. * @param y defines the y coordinate
  61608. * @param z defines the z coordinate
  61609. * @param w defines the w coordinate
  61610. * @returns the updated current quaternion
  61611. */
  61612. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61613. /**
  61614. * Updates the current quaternion from the given float coordinates
  61615. * @param x defines the x coordinate
  61616. * @param y defines the y coordinate
  61617. * @param z defines the z coordinate
  61618. * @param w defines the w coordinate
  61619. * @returns the updated current quaternion
  61620. */
  61621. set(x: number, y: number, z: number, w: number): Quaternion;
  61622. /**
  61623. * Adds two quaternions
  61624. * @param other defines the second operand
  61625. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61626. */
  61627. add(other: DeepImmutable<Quaternion>): Quaternion;
  61628. /**
  61629. * Add a quaternion to the current one
  61630. * @param other defines the quaternion to add
  61631. * @returns the current quaternion
  61632. */
  61633. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61634. /**
  61635. * Subtract two quaternions
  61636. * @param other defines the second operand
  61637. * @returns a new quaternion as the subtraction result of the given one from the current one
  61638. */
  61639. subtract(other: Quaternion): Quaternion;
  61640. /**
  61641. * Multiplies the current quaternion by a scale factor
  61642. * @param value defines the scale factor
  61643. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61644. */
  61645. scale(value: number): Quaternion;
  61646. /**
  61647. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61648. * @param scale defines the scale factor
  61649. * @param result defines the Quaternion object where to store the result
  61650. * @returns the unmodified current quaternion
  61651. */
  61652. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61653. /**
  61654. * Multiplies in place the current quaternion by a scale factor
  61655. * @param value defines the scale factor
  61656. * @returns the current modified quaternion
  61657. */
  61658. scaleInPlace(value: number): Quaternion;
  61659. /**
  61660. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61661. * @param scale defines the scale factor
  61662. * @param result defines the Quaternion object where to store the result
  61663. * @returns the unmodified current quaternion
  61664. */
  61665. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61666. /**
  61667. * Multiplies two quaternions
  61668. * @param q1 defines the second operand
  61669. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61670. */
  61671. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  61672. /**
  61673. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  61674. * @param q1 defines the second operand
  61675. * @param result defines the target quaternion
  61676. * @returns the current quaternion
  61677. */
  61678. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  61679. /**
  61680. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  61681. * @param q1 defines the second operand
  61682. * @returns the currentupdated quaternion
  61683. */
  61684. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  61685. /**
  61686. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  61687. * @param ref defines the target quaternion
  61688. * @returns the current quaternion
  61689. */
  61690. conjugateToRef(ref: Quaternion): Quaternion;
  61691. /**
  61692. * Conjugates in place (1-q) the current quaternion
  61693. * @returns the current updated quaternion
  61694. */
  61695. conjugateInPlace(): Quaternion;
  61696. /**
  61697. * Conjugates in place (1-q) the current quaternion
  61698. * @returns a new quaternion
  61699. */
  61700. conjugate(): Quaternion;
  61701. /**
  61702. * Gets length of current quaternion
  61703. * @returns the quaternion length (float)
  61704. */
  61705. length(): number;
  61706. /**
  61707. * Normalize in place the current quaternion
  61708. * @returns the current updated quaternion
  61709. */
  61710. normalize(): Quaternion;
  61711. /**
  61712. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  61713. * @param order is a reserved parameter and is ignore for now
  61714. * @returns a new Vector3 containing the Euler angles
  61715. */
  61716. toEulerAngles(order?: string): Vector3;
  61717. /**
  61718. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  61719. * @param result defines the vector which will be filled with the Euler angles
  61720. * @param order is a reserved parameter and is ignore for now
  61721. * @returns the current unchanged quaternion
  61722. */
  61723. toEulerAnglesToRef(result: Vector3): Quaternion;
  61724. /**
  61725. * Updates the given rotation matrix with the current quaternion values
  61726. * @param result defines the target matrix
  61727. * @returns the current unchanged quaternion
  61728. */
  61729. toRotationMatrix(result: Matrix): Quaternion;
  61730. /**
  61731. * Updates the current quaternion from the given rotation matrix values
  61732. * @param matrix defines the source matrix
  61733. * @returns the current updated quaternion
  61734. */
  61735. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61736. /**
  61737. * Creates a new quaternion from a rotation matrix
  61738. * @param matrix defines the source matrix
  61739. * @returns a new quaternion created from the given rotation matrix values
  61740. */
  61741. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61742. /**
  61743. * Updates the given quaternion with the given rotation matrix values
  61744. * @param matrix defines the source matrix
  61745. * @param result defines the target quaternion
  61746. */
  61747. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  61748. /**
  61749. * Returns the dot product (float) between the quaternions "left" and "right"
  61750. * @param left defines the left operand
  61751. * @param right defines the right operand
  61752. * @returns the dot product
  61753. */
  61754. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  61755. /**
  61756. * Checks if the two quaternions are close to each other
  61757. * @param quat0 defines the first quaternion to check
  61758. * @param quat1 defines the second quaternion to check
  61759. * @returns true if the two quaternions are close to each other
  61760. */
  61761. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  61762. /**
  61763. * Creates an empty quaternion
  61764. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  61765. */
  61766. static Zero(): Quaternion;
  61767. /**
  61768. * Inverse a given quaternion
  61769. * @param q defines the source quaternion
  61770. * @returns a new quaternion as the inverted current quaternion
  61771. */
  61772. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  61773. /**
  61774. * Inverse a given quaternion
  61775. * @param q defines the source quaternion
  61776. * @param result the quaternion the result will be stored in
  61777. * @returns the result quaternion
  61778. */
  61779. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  61780. /**
  61781. * Creates an identity quaternion
  61782. * @returns the identity quaternion
  61783. */
  61784. static Identity(): Quaternion;
  61785. /**
  61786. * Gets a boolean indicating if the given quaternion is identity
  61787. * @param quaternion defines the quaternion to check
  61788. * @returns true if the quaternion is identity
  61789. */
  61790. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  61791. /**
  61792. * Creates a quaternion from a rotation around an axis
  61793. * @param axis defines the axis to use
  61794. * @param angle defines the angle to use
  61795. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  61796. */
  61797. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  61798. /**
  61799. * Creates a rotation around an axis and stores it into the given quaternion
  61800. * @param axis defines the axis to use
  61801. * @param angle defines the angle to use
  61802. * @param result defines the target quaternion
  61803. * @returns the target quaternion
  61804. */
  61805. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  61806. /**
  61807. * Creates a new quaternion from data stored into an array
  61808. * @param array defines the data source
  61809. * @param offset defines the offset in the source array where the data starts
  61810. * @returns a new quaternion
  61811. */
  61812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  61813. /**
  61814. * Create a quaternion from Euler rotation angles
  61815. * @param x Pitch
  61816. * @param y Yaw
  61817. * @param z Roll
  61818. * @returns the new Quaternion
  61819. */
  61820. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  61821. /**
  61822. * Updates a quaternion from Euler rotation angles
  61823. * @param x Pitch
  61824. * @param y Yaw
  61825. * @param z Roll
  61826. * @param result the quaternion to store the result
  61827. * @returns the updated quaternion
  61828. */
  61829. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  61830. /**
  61831. * Create a quaternion from Euler rotation vector
  61832. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61833. * @returns the new Quaternion
  61834. */
  61835. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  61836. /**
  61837. * Updates a quaternion from Euler rotation vector
  61838. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61839. * @param result the quaternion to store the result
  61840. * @returns the updated quaternion
  61841. */
  61842. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  61843. /**
  61844. * Creates a new quaternion from the given Euler float angles (y, x, z)
  61845. * @param yaw defines the rotation around Y axis
  61846. * @param pitch defines the rotation around X axis
  61847. * @param roll defines the rotation around Z axis
  61848. * @returns the new quaternion
  61849. */
  61850. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  61851. /**
  61852. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  61853. * @param yaw defines the rotation around Y axis
  61854. * @param pitch defines the rotation around X axis
  61855. * @param roll defines the rotation around Z axis
  61856. * @param result defines the target quaternion
  61857. */
  61858. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  61859. /**
  61860. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  61861. * @param alpha defines the rotation around first axis
  61862. * @param beta defines the rotation around second axis
  61863. * @param gamma defines the rotation around third axis
  61864. * @returns the new quaternion
  61865. */
  61866. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  61867. /**
  61868. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  61869. * @param alpha defines the rotation around first axis
  61870. * @param beta defines the rotation around second axis
  61871. * @param gamma defines the rotation around third axis
  61872. * @param result defines the target quaternion
  61873. */
  61874. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  61875. /**
  61876. * 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)
  61877. * @param axis1 defines the first axis
  61878. * @param axis2 defines the second axis
  61879. * @param axis3 defines the third axis
  61880. * @returns the new quaternion
  61881. */
  61882. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  61883. /**
  61884. * 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
  61885. * @param axis1 defines the first axis
  61886. * @param axis2 defines the second axis
  61887. * @param axis3 defines the third axis
  61888. * @param ref defines the target quaternion
  61889. */
  61890. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  61891. /**
  61892. * Interpolates between two quaternions
  61893. * @param left defines first quaternion
  61894. * @param right defines second quaternion
  61895. * @param amount defines the gradient to use
  61896. * @returns the new interpolated quaternion
  61897. */
  61898. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61899. /**
  61900. * Interpolates between two quaternions and stores it into a target quaternion
  61901. * @param left defines first quaternion
  61902. * @param right defines second quaternion
  61903. * @param amount defines the gradient to use
  61904. * @param result defines the target quaternion
  61905. */
  61906. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  61907. /**
  61908. * Interpolate between two quaternions using Hermite interpolation
  61909. * @param value1 defines first quaternion
  61910. * @param tangent1 defines the incoming tangent
  61911. * @param value2 defines second quaternion
  61912. * @param tangent2 defines the outgoing tangent
  61913. * @param amount defines the target quaternion
  61914. * @returns the new interpolated quaternion
  61915. */
  61916. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61917. }
  61918. /**
  61919. * Class used to store matrix data (4x4)
  61920. */
  61921. export class Matrix {
  61922. private static _updateFlagSeed;
  61923. private static _identityReadOnly;
  61924. private _isIdentity;
  61925. private _isIdentityDirty;
  61926. private _isIdentity3x2;
  61927. private _isIdentity3x2Dirty;
  61928. /**
  61929. * Gets the update flag of the matrix which is an unique number for the matrix.
  61930. * It will be incremented every time the matrix data change.
  61931. * You can use it to speed the comparison between two versions of the same matrix.
  61932. */
  61933. updateFlag: number;
  61934. private readonly _m;
  61935. /**
  61936. * Gets the internal data of the matrix
  61937. */
  61938. readonly m: DeepImmutable<Float32Array>;
  61939. /** @hidden */
  61940. _markAsUpdated(): void;
  61941. /** @hidden */
  61942. private _updateIdentityStatus;
  61943. /**
  61944. * Creates an empty matrix (filled with zeros)
  61945. */
  61946. constructor();
  61947. /**
  61948. * Check if the current matrix is identity
  61949. * @returns true is the matrix is the identity matrix
  61950. */
  61951. isIdentity(): boolean;
  61952. /**
  61953. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  61954. * @returns true is the matrix is the identity matrix
  61955. */
  61956. isIdentityAs3x2(): boolean;
  61957. /**
  61958. * Gets the determinant of the matrix
  61959. * @returns the matrix determinant
  61960. */
  61961. determinant(): number;
  61962. /**
  61963. * Returns the matrix as a Float32Array
  61964. * @returns the matrix underlying array
  61965. */
  61966. toArray(): DeepImmutable<Float32Array>;
  61967. /**
  61968. * Returns the matrix as a Float32Array
  61969. * @returns the matrix underlying array.
  61970. */
  61971. asArray(): DeepImmutable<Float32Array>;
  61972. /**
  61973. * Inverts the current matrix in place
  61974. * @returns the current inverted matrix
  61975. */
  61976. invert(): Matrix;
  61977. /**
  61978. * Sets all the matrix elements to zero
  61979. * @returns the current matrix
  61980. */
  61981. reset(): Matrix;
  61982. /**
  61983. * Adds the current matrix with a second one
  61984. * @param other defines the matrix to add
  61985. * @returns a new matrix as the addition of the current matrix and the given one
  61986. */
  61987. add(other: DeepImmutable<Matrix>): Matrix;
  61988. /**
  61989. * Sets the given matrix "result" to the addition of the current matrix and the given one
  61990. * @param other defines the matrix to add
  61991. * @param result defines the target matrix
  61992. * @returns the current matrix
  61993. */
  61994. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61995. /**
  61996. * Adds in place the given matrix to the current matrix
  61997. * @param other defines the second operand
  61998. * @returns the current updated matrix
  61999. */
  62000. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62001. /**
  62002. * Sets the given matrix to the current inverted Matrix
  62003. * @param other defines the target matrix
  62004. * @returns the unmodified current matrix
  62005. */
  62006. invertToRef(other: Matrix): Matrix;
  62007. /**
  62008. * add a value at the specified position in the current Matrix
  62009. * @param index the index of the value within the matrix. between 0 and 15.
  62010. * @param value the value to be added
  62011. * @returns the current updated matrix
  62012. */
  62013. addAtIndex(index: number, value: number): Matrix;
  62014. /**
  62015. * mutiply the specified position in the current Matrix by a value
  62016. * @param index the index of the value within the matrix. between 0 and 15.
  62017. * @param value the value to be added
  62018. * @returns the current updated matrix
  62019. */
  62020. multiplyAtIndex(index: number, value: number): Matrix;
  62021. /**
  62022. * Inserts the translation vector (using 3 floats) in the current matrix
  62023. * @param x defines the 1st component of the translation
  62024. * @param y defines the 2nd component of the translation
  62025. * @param z defines the 3rd component of the translation
  62026. * @returns the current updated matrix
  62027. */
  62028. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62029. /**
  62030. * Inserts the translation vector in the current matrix
  62031. * @param vector3 defines the translation to insert
  62032. * @returns the current updated matrix
  62033. */
  62034. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62035. /**
  62036. * Gets the translation value of the current matrix
  62037. * @returns a new Vector3 as the extracted translation from the matrix
  62038. */
  62039. getTranslation(): Vector3;
  62040. /**
  62041. * Fill a Vector3 with the extracted translation from the matrix
  62042. * @param result defines the Vector3 where to store the translation
  62043. * @returns the current matrix
  62044. */
  62045. getTranslationToRef(result: Vector3): Matrix;
  62046. /**
  62047. * Remove rotation and scaling part from the matrix
  62048. * @returns the updated matrix
  62049. */
  62050. removeRotationAndScaling(): Matrix;
  62051. /**
  62052. * Multiply two matrices
  62053. * @param other defines the second operand
  62054. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62055. */
  62056. multiply(other: DeepImmutable<Matrix>): Matrix;
  62057. /**
  62058. * Copy the current matrix from the given one
  62059. * @param other defines the source matrix
  62060. * @returns the current updated matrix
  62061. */
  62062. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62063. /**
  62064. * Populates the given array from the starting index with the current matrix values
  62065. * @param array defines the target array
  62066. * @param offset defines the offset in the target array where to start storing values
  62067. * @returns the current matrix
  62068. */
  62069. copyToArray(array: Float32Array, offset?: number): Matrix;
  62070. /**
  62071. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62072. * @param other defines the second operand
  62073. * @param result defines the matrix where to store the multiplication
  62074. * @returns the current matrix
  62075. */
  62076. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62077. /**
  62078. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62079. * @param other defines the second operand
  62080. * @param result defines the array where to store the multiplication
  62081. * @param offset defines the offset in the target array where to start storing values
  62082. * @returns the current matrix
  62083. */
  62084. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62085. /**
  62086. * Check equality between this matrix and a second one
  62087. * @param value defines the second matrix to compare
  62088. * @returns true is the current matrix and the given one values are strictly equal
  62089. */
  62090. equals(value: DeepImmutable<Matrix>): boolean;
  62091. /**
  62092. * Clone the current matrix
  62093. * @returns a new matrix from the current matrix
  62094. */
  62095. clone(): Matrix;
  62096. /**
  62097. * Returns the name of the current matrix class
  62098. * @returns the string "Matrix"
  62099. */
  62100. getClassName(): string;
  62101. /**
  62102. * Gets the hash code of the current matrix
  62103. * @returns the hash code
  62104. */
  62105. getHashCode(): number;
  62106. /**
  62107. * Decomposes the current Matrix into a translation, rotation and scaling components
  62108. * @param scale defines the scale vector3 given as a reference to update
  62109. * @param rotation defines the rotation quaternion given as a reference to update
  62110. * @param translation defines the translation vector3 given as a reference to update
  62111. * @returns true if operation was successful
  62112. */
  62113. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62114. /**
  62115. * Gets specific row of the matrix
  62116. * @param index defines the number of the row to get
  62117. * @returns the index-th row of the current matrix as a new Vector4
  62118. */
  62119. getRow(index: number): Nullable<Vector4>;
  62120. /**
  62121. * Sets the index-th row of the current matrix to the vector4 values
  62122. * @param index defines the number of the row to set
  62123. * @param row defines the target vector4
  62124. * @returns the updated current matrix
  62125. */
  62126. setRow(index: number, row: Vector4): Matrix;
  62127. /**
  62128. * Compute the transpose of the matrix
  62129. * @returns the new transposed matrix
  62130. */
  62131. transpose(): Matrix;
  62132. /**
  62133. * Compute the transpose of the matrix and store it in a given matrix
  62134. * @param result defines the target matrix
  62135. * @returns the current matrix
  62136. */
  62137. transposeToRef(result: Matrix): Matrix;
  62138. /**
  62139. * Sets the index-th row of the current matrix with the given 4 x float values
  62140. * @param index defines the row index
  62141. * @param x defines the x component to set
  62142. * @param y defines the y component to set
  62143. * @param z defines the z component to set
  62144. * @param w defines the w component to set
  62145. * @returns the updated current matrix
  62146. */
  62147. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62148. /**
  62149. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62150. * @param scale defines the scale factor
  62151. * @returns a new matrix
  62152. */
  62153. scale(scale: number): Matrix;
  62154. /**
  62155. * Scale the current matrix values by a factor to a given result matrix
  62156. * @param scale defines the scale factor
  62157. * @param result defines the matrix to store the result
  62158. * @returns the current matrix
  62159. */
  62160. scaleToRef(scale: number, result: Matrix): Matrix;
  62161. /**
  62162. * Scale the current matrix values by a factor and add the result to a given matrix
  62163. * @param scale defines the scale factor
  62164. * @param result defines the Matrix to store the result
  62165. * @returns the current matrix
  62166. */
  62167. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62168. /**
  62169. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62170. * @param ref matrix to store the result
  62171. */
  62172. toNormalMatrix(ref: Matrix): void;
  62173. /**
  62174. * Gets only rotation part of the current matrix
  62175. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62176. */
  62177. getRotationMatrix(): Matrix;
  62178. /**
  62179. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62180. * @param result defines the target matrix to store data to
  62181. * @returns the current matrix
  62182. */
  62183. getRotationMatrixToRef(result: Matrix): Matrix;
  62184. /**
  62185. * Toggles model matrix from being right handed to left handed in place and vice versa
  62186. */
  62187. toggleModelMatrixHandInPlace(): void;
  62188. /**
  62189. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62190. */
  62191. toggleProjectionMatrixHandInPlace(): void;
  62192. /**
  62193. * Creates a matrix from an array
  62194. * @param array defines the source array
  62195. * @param offset defines an offset in the source array
  62196. * @returns a new Matrix set from the starting index of the given array
  62197. */
  62198. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62199. /**
  62200. * Copy the content of an array into a given matrix
  62201. * @param array defines the source array
  62202. * @param offset defines an offset in the source array
  62203. * @param result defines the target matrix
  62204. */
  62205. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62206. /**
  62207. * Stores an array into a matrix after having multiplied each component by a given factor
  62208. * @param array defines the source array
  62209. * @param offset defines the offset in the source array
  62210. * @param scale defines the scaling factor
  62211. * @param result defines the target matrix
  62212. */
  62213. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  62214. /**
  62215. * Gets an identity matrix that must not be updated
  62216. */
  62217. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  62218. /**
  62219. * Stores a list of values (16) inside a given matrix
  62220. * @param initialM11 defines 1st value of 1st row
  62221. * @param initialM12 defines 2nd value of 1st row
  62222. * @param initialM13 defines 3rd value of 1st row
  62223. * @param initialM14 defines 4th value of 1st row
  62224. * @param initialM21 defines 1st value of 2nd row
  62225. * @param initialM22 defines 2nd value of 2nd row
  62226. * @param initialM23 defines 3rd value of 2nd row
  62227. * @param initialM24 defines 4th value of 2nd row
  62228. * @param initialM31 defines 1st value of 3rd row
  62229. * @param initialM32 defines 2nd value of 3rd row
  62230. * @param initialM33 defines 3rd value of 3rd row
  62231. * @param initialM34 defines 4th value of 3rd row
  62232. * @param initialM41 defines 1st value of 4th row
  62233. * @param initialM42 defines 2nd value of 4th row
  62234. * @param initialM43 defines 3rd value of 4th row
  62235. * @param initialM44 defines 4th value of 4th row
  62236. * @param result defines the target matrix
  62237. */
  62238. 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;
  62239. /**
  62240. * Creates new matrix from a list of values (16)
  62241. * @param initialM11 defines 1st value of 1st row
  62242. * @param initialM12 defines 2nd value of 1st row
  62243. * @param initialM13 defines 3rd value of 1st row
  62244. * @param initialM14 defines 4th value of 1st row
  62245. * @param initialM21 defines 1st value of 2nd row
  62246. * @param initialM22 defines 2nd value of 2nd row
  62247. * @param initialM23 defines 3rd value of 2nd row
  62248. * @param initialM24 defines 4th value of 2nd row
  62249. * @param initialM31 defines 1st value of 3rd row
  62250. * @param initialM32 defines 2nd value of 3rd row
  62251. * @param initialM33 defines 3rd value of 3rd row
  62252. * @param initialM34 defines 4th value of 3rd row
  62253. * @param initialM41 defines 1st value of 4th row
  62254. * @param initialM42 defines 2nd value of 4th row
  62255. * @param initialM43 defines 3rd value of 4th row
  62256. * @param initialM44 defines 4th value of 4th row
  62257. * @returns the new matrix
  62258. */
  62259. 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;
  62260. /**
  62261. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62262. * @param scale defines the scale vector3
  62263. * @param rotation defines the rotation quaternion
  62264. * @param translation defines the translation vector3
  62265. * @returns a new matrix
  62266. */
  62267. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  62268. /**
  62269. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62270. * @param scale defines the scale vector3
  62271. * @param rotation defines the rotation quaternion
  62272. * @param translation defines the translation vector3
  62273. * @param result defines the target matrix
  62274. */
  62275. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  62276. /**
  62277. * Creates a new identity matrix
  62278. * @returns a new identity matrix
  62279. */
  62280. static Identity(): Matrix;
  62281. /**
  62282. * Creates a new identity matrix and stores the result in a given matrix
  62283. * @param result defines the target matrix
  62284. */
  62285. static IdentityToRef(result: Matrix): void;
  62286. /**
  62287. * Creates a new zero matrix
  62288. * @returns a new zero matrix
  62289. */
  62290. static Zero(): Matrix;
  62291. /**
  62292. * Creates a new rotation matrix for "angle" radians around the X axis
  62293. * @param angle defines the angle (in radians) to use
  62294. * @return the new matrix
  62295. */
  62296. static RotationX(angle: number): Matrix;
  62297. /**
  62298. * Creates a new matrix as the invert of a given matrix
  62299. * @param source defines the source matrix
  62300. * @returns the new matrix
  62301. */
  62302. static Invert(source: DeepImmutable<Matrix>): Matrix;
  62303. /**
  62304. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  62305. * @param angle defines the angle (in radians) to use
  62306. * @param result defines the target matrix
  62307. */
  62308. static RotationXToRef(angle: number, result: Matrix): void;
  62309. /**
  62310. * Creates a new rotation matrix for "angle" radians around the Y axis
  62311. * @param angle defines the angle (in radians) to use
  62312. * @return the new matrix
  62313. */
  62314. static RotationY(angle: number): Matrix;
  62315. /**
  62316. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  62317. * @param angle defines the angle (in radians) to use
  62318. * @param result defines the target matrix
  62319. */
  62320. static RotationYToRef(angle: number, result: Matrix): void;
  62321. /**
  62322. * Creates a new rotation matrix for "angle" radians around the Z axis
  62323. * @param angle defines the angle (in radians) to use
  62324. * @return the new matrix
  62325. */
  62326. static RotationZ(angle: number): Matrix;
  62327. /**
  62328. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  62329. * @param angle defines the angle (in radians) to use
  62330. * @param result defines the target matrix
  62331. */
  62332. static RotationZToRef(angle: number, result: Matrix): void;
  62333. /**
  62334. * Creates a new rotation matrix for "angle" radians around the given axis
  62335. * @param axis defines the axis to use
  62336. * @param angle defines the angle (in radians) to use
  62337. * @return the new matrix
  62338. */
  62339. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  62340. /**
  62341. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  62342. * @param axis defines the axis to use
  62343. * @param angle defines the angle (in radians) to use
  62344. * @param result defines the target matrix
  62345. */
  62346. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  62347. /**
  62348. * Creates a rotation matrix
  62349. * @param yaw defines the yaw angle in radians (Y axis)
  62350. * @param pitch defines the pitch angle in radians (X axis)
  62351. * @param roll defines the roll angle in radians (X axis)
  62352. * @returns the new rotation matrix
  62353. */
  62354. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  62355. /**
  62356. * Creates a rotation matrix and stores it in a given matrix
  62357. * @param yaw defines the yaw angle in radians (Y axis)
  62358. * @param pitch defines the pitch angle in radians (X axis)
  62359. * @param roll defines the roll angle in radians (X axis)
  62360. * @param result defines the target matrix
  62361. */
  62362. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  62363. /**
  62364. * Creates a scaling matrix
  62365. * @param x defines the scale factor on X axis
  62366. * @param y defines the scale factor on Y axis
  62367. * @param z defines the scale factor on Z axis
  62368. * @returns the new matrix
  62369. */
  62370. static Scaling(x: number, y: number, z: number): Matrix;
  62371. /**
  62372. * Creates a scaling matrix and stores it in a given matrix
  62373. * @param x defines the scale factor on X axis
  62374. * @param y defines the scale factor on Y axis
  62375. * @param z defines the scale factor on Z axis
  62376. * @param result defines the target matrix
  62377. */
  62378. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  62379. /**
  62380. * Creates a translation matrix
  62381. * @param x defines the translation on X axis
  62382. * @param y defines the translation on Y axis
  62383. * @param z defines the translationon Z axis
  62384. * @returns the new matrix
  62385. */
  62386. static Translation(x: number, y: number, z: number): Matrix;
  62387. /**
  62388. * Creates a translation matrix and stores it in a given matrix
  62389. * @param x defines the translation on X axis
  62390. * @param y defines the translation on Y axis
  62391. * @param z defines the translationon Z axis
  62392. * @param result defines the target matrix
  62393. */
  62394. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  62395. /**
  62396. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62397. * @param startValue defines the start value
  62398. * @param endValue defines the end value
  62399. * @param gradient defines the gradient factor
  62400. * @returns the new matrix
  62401. */
  62402. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62403. /**
  62404. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62405. * @param startValue defines the start value
  62406. * @param endValue defines the end value
  62407. * @param gradient defines the gradient factor
  62408. * @param result defines the Matrix object where to store data
  62409. */
  62410. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62411. /**
  62412. * Builds a new matrix whose values are computed by:
  62413. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62414. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62415. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62416. * @param startValue defines the first matrix
  62417. * @param endValue defines the second matrix
  62418. * @param gradient defines the gradient between the two matrices
  62419. * @returns the new matrix
  62420. */
  62421. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62422. /**
  62423. * Update a matrix to values which are computed by:
  62424. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62425. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62426. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62427. * @param startValue defines the first matrix
  62428. * @param endValue defines the second matrix
  62429. * @param gradient defines the gradient between the two matrices
  62430. * @param result defines the target matrix
  62431. */
  62432. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62433. /**
  62434. * 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"
  62435. * This function works in left handed mode
  62436. * @param eye defines the final position of the entity
  62437. * @param target defines where the entity should look at
  62438. * @param up defines the up vector for the entity
  62439. * @returns the new matrix
  62440. */
  62441. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62442. /**
  62443. * 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".
  62444. * This function works in left handed mode
  62445. * @param eye defines the final position of the entity
  62446. * @param target defines where the entity should look at
  62447. * @param up defines the up vector for the entity
  62448. * @param result defines the target matrix
  62449. */
  62450. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62451. /**
  62452. * 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"
  62453. * This function works in right handed mode
  62454. * @param eye defines the final position of the entity
  62455. * @param target defines where the entity should look at
  62456. * @param up defines the up vector for the entity
  62457. * @returns the new matrix
  62458. */
  62459. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62460. /**
  62461. * 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".
  62462. * This function works in right handed mode
  62463. * @param eye defines the final position of the entity
  62464. * @param target defines where the entity should look at
  62465. * @param up defines the up vector for the entity
  62466. * @param result defines the target matrix
  62467. */
  62468. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62469. /**
  62470. * Create a left-handed orthographic projection matrix
  62471. * @param width defines the viewport width
  62472. * @param height defines the viewport height
  62473. * @param znear defines the near clip plane
  62474. * @param zfar defines the far clip plane
  62475. * @returns a new matrix as a left-handed orthographic projection matrix
  62476. */
  62477. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62478. /**
  62479. * Store a left-handed orthographic projection to a given matrix
  62480. * @param width defines the viewport width
  62481. * @param height defines the viewport height
  62482. * @param znear defines the near clip plane
  62483. * @param zfar defines the far clip plane
  62484. * @param result defines the target matrix
  62485. */
  62486. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  62487. /**
  62488. * Create a left-handed orthographic projection matrix
  62489. * @param left defines the viewport left coordinate
  62490. * @param right defines the viewport right coordinate
  62491. * @param bottom defines the viewport bottom coordinate
  62492. * @param top defines the viewport top coordinate
  62493. * @param znear defines the near clip plane
  62494. * @param zfar defines the far clip plane
  62495. * @returns a new matrix as a left-handed orthographic projection matrix
  62496. */
  62497. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62498. /**
  62499. * Stores a left-handed orthographic projection into a given matrix
  62500. * @param left defines the viewport left coordinate
  62501. * @param right defines the viewport right coordinate
  62502. * @param bottom defines the viewport bottom coordinate
  62503. * @param top defines the viewport top coordinate
  62504. * @param znear defines the near clip plane
  62505. * @param zfar defines the far clip plane
  62506. * @param result defines the target matrix
  62507. */
  62508. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62509. /**
  62510. * Creates a right-handed orthographic projection matrix
  62511. * @param left defines the viewport left coordinate
  62512. * @param right defines the viewport right coordinate
  62513. * @param bottom defines the viewport bottom coordinate
  62514. * @param top defines the viewport top coordinate
  62515. * @param znear defines the near clip plane
  62516. * @param zfar defines the far clip plane
  62517. * @returns a new matrix as a right-handed orthographic projection matrix
  62518. */
  62519. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62520. /**
  62521. * Stores a right-handed orthographic projection into a given matrix
  62522. * @param left defines the viewport left coordinate
  62523. * @param right defines the viewport right coordinate
  62524. * @param bottom defines the viewport bottom coordinate
  62525. * @param top defines the viewport top coordinate
  62526. * @param znear defines the near clip plane
  62527. * @param zfar defines the far clip plane
  62528. * @param result defines the target matrix
  62529. */
  62530. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62531. /**
  62532. * Creates a left-handed perspective projection matrix
  62533. * @param width defines the viewport width
  62534. * @param height defines the viewport height
  62535. * @param znear defines the near clip plane
  62536. * @param zfar defines the far clip plane
  62537. * @returns a new matrix as a left-handed perspective projection matrix
  62538. */
  62539. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62540. /**
  62541. * Creates a left-handed perspective projection matrix
  62542. * @param fov defines the horizontal field of view
  62543. * @param aspect defines the aspect ratio
  62544. * @param znear defines the near clip plane
  62545. * @param zfar defines the far clip plane
  62546. * @returns a new matrix as a left-handed perspective projection matrix
  62547. */
  62548. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62549. /**
  62550. * Stores a left-handed perspective projection into a given matrix
  62551. * @param fov defines the horizontal field of view
  62552. * @param aspect defines the aspect ratio
  62553. * @param znear defines the near clip plane
  62554. * @param zfar defines the far clip plane
  62555. * @param result defines the target matrix
  62556. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62557. */
  62558. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62559. /**
  62560. * Creates a right-handed perspective projection matrix
  62561. * @param fov defines the horizontal field of view
  62562. * @param aspect defines the aspect ratio
  62563. * @param znear defines the near clip plane
  62564. * @param zfar defines the far clip plane
  62565. * @returns a new matrix as a right-handed perspective projection matrix
  62566. */
  62567. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62568. /**
  62569. * Stores a right-handed perspective projection into a given matrix
  62570. * @param fov defines the horizontal field of view
  62571. * @param aspect defines the aspect ratio
  62572. * @param znear defines the near clip plane
  62573. * @param zfar defines the far clip plane
  62574. * @param result defines the target matrix
  62575. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62576. */
  62577. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62578. /**
  62579. * Stores a perspective projection for WebVR info a given matrix
  62580. * @param fov defines the field of view
  62581. * @param znear defines the near clip plane
  62582. * @param zfar defines the far clip plane
  62583. * @param result defines the target matrix
  62584. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62585. */
  62586. static PerspectiveFovWebVRToRef(fov: {
  62587. upDegrees: number;
  62588. downDegrees: number;
  62589. leftDegrees: number;
  62590. rightDegrees: number;
  62591. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62592. /**
  62593. * Computes a complete transformation matrix
  62594. * @param viewport defines the viewport to use
  62595. * @param world defines the world matrix
  62596. * @param view defines the view matrix
  62597. * @param projection defines the projection matrix
  62598. * @param zmin defines the near clip plane
  62599. * @param zmax defines the far clip plane
  62600. * @returns the transformation matrix
  62601. */
  62602. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62603. /**
  62604. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62605. * @param matrix defines the matrix to use
  62606. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62607. */
  62608. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62609. /**
  62610. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62611. * @param matrix defines the matrix to use
  62612. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62613. */
  62614. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62615. /**
  62616. * Compute the transpose of a given matrix
  62617. * @param matrix defines the matrix to transpose
  62618. * @returns the new matrix
  62619. */
  62620. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62621. /**
  62622. * Compute the transpose of a matrix and store it in a target matrix
  62623. * @param matrix defines the matrix to transpose
  62624. * @param result defines the target matrix
  62625. */
  62626. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62627. /**
  62628. * Computes a reflection matrix from a plane
  62629. * @param plane defines the reflection plane
  62630. * @returns a new matrix
  62631. */
  62632. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62633. /**
  62634. * Computes a reflection matrix from a plane
  62635. * @param plane defines the reflection plane
  62636. * @param result defines the target matrix
  62637. */
  62638. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62639. /**
  62640. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62641. * @param xaxis defines the value of the 1st axis
  62642. * @param yaxis defines the value of the 2nd axis
  62643. * @param zaxis defines the value of the 3rd axis
  62644. * @param result defines the target matrix
  62645. */
  62646. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62647. /**
  62648. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62649. * @param quat defines the quaternion to use
  62650. * @param result defines the target matrix
  62651. */
  62652. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62653. }
  62654. /**
  62655. * Represens a plane by the equation ax + by + cz + d = 0
  62656. */
  62657. export class Plane {
  62658. /**
  62659. * Normal of the plane (a,b,c)
  62660. */
  62661. normal: Vector3;
  62662. /**
  62663. * d component of the plane
  62664. */
  62665. d: number;
  62666. /**
  62667. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  62668. * @param a a component of the plane
  62669. * @param b b component of the plane
  62670. * @param c c component of the plane
  62671. * @param d d component of the plane
  62672. */
  62673. constructor(a: number, b: number, c: number, d: number);
  62674. /**
  62675. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  62676. */
  62677. asArray(): number[];
  62678. /**
  62679. * @returns a new plane copied from the current Plane.
  62680. */
  62681. clone(): Plane;
  62682. /**
  62683. * @returns the string "Plane".
  62684. */
  62685. getClassName(): string;
  62686. /**
  62687. * @returns the Plane hash code.
  62688. */
  62689. getHashCode(): number;
  62690. /**
  62691. * Normalize the current Plane in place.
  62692. * @returns the updated Plane.
  62693. */
  62694. normalize(): Plane;
  62695. /**
  62696. * Applies a transformation the plane and returns the result
  62697. * @param transformation the transformation matrix to be applied to the plane
  62698. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  62699. */
  62700. transform(transformation: DeepImmutable<Matrix>): Plane;
  62701. /**
  62702. * Calcualtte the dot product between the point and the plane normal
  62703. * @param point point to calculate the dot product with
  62704. * @returns the dot product (float) of the point coordinates and the plane normal.
  62705. */
  62706. dotCoordinate(point: DeepImmutable<Vector3>): number;
  62707. /**
  62708. * Updates the current Plane from the plane defined by the three given points.
  62709. * @param point1 one of the points used to contruct the plane
  62710. * @param point2 one of the points used to contruct the plane
  62711. * @param point3 one of the points used to contruct the plane
  62712. * @returns the updated Plane.
  62713. */
  62714. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62715. /**
  62716. * Checks if the plane is facing a given direction
  62717. * @param direction the direction to check if the plane is facing
  62718. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  62719. * @returns True is the vector "direction" is the same side than the plane normal.
  62720. */
  62721. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  62722. /**
  62723. * Calculates the distance to a point
  62724. * @param point point to calculate distance to
  62725. * @returns the signed distance (float) from the given point to the Plane.
  62726. */
  62727. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  62728. /**
  62729. * Creates a plane from an array
  62730. * @param array the array to create a plane from
  62731. * @returns a new Plane from the given array.
  62732. */
  62733. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  62734. /**
  62735. * Creates a plane from three points
  62736. * @param point1 point used to create the plane
  62737. * @param point2 point used to create the plane
  62738. * @param point3 point used to create the plane
  62739. * @returns a new Plane defined by the three given points.
  62740. */
  62741. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62742. /**
  62743. * Creates a plane from an origin point and a normal
  62744. * @param origin origin of the plane to be constructed
  62745. * @param normal normal of the plane to be constructed
  62746. * @returns a new Plane the normal vector to this plane at the given origin point.
  62747. * Note : the vector "normal" is updated because normalized.
  62748. */
  62749. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  62750. /**
  62751. * Calculates the distance from a plane and a point
  62752. * @param origin origin of the plane to be constructed
  62753. * @param normal normal of the plane to be constructed
  62754. * @param point point to calculate distance to
  62755. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  62756. */
  62757. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  62758. }
  62759. /**
  62760. * Class used to represent a viewport on screen
  62761. */
  62762. export class Viewport {
  62763. /** viewport left coordinate */
  62764. x: number;
  62765. /** viewport top coordinate */
  62766. y: number;
  62767. /**viewport width */
  62768. width: number;
  62769. /** viewport height */
  62770. height: number;
  62771. /**
  62772. * Creates a Viewport object located at (x, y) and sized (width, height)
  62773. * @param x defines viewport left coordinate
  62774. * @param y defines viewport top coordinate
  62775. * @param width defines the viewport width
  62776. * @param height defines the viewport height
  62777. */
  62778. constructor(
  62779. /** viewport left coordinate */
  62780. x: number,
  62781. /** viewport top coordinate */
  62782. y: number,
  62783. /**viewport width */
  62784. width: number,
  62785. /** viewport height */
  62786. height: number);
  62787. /**
  62788. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  62789. * @param renderWidth defines the rendering width
  62790. * @param renderHeight defines the rendering height
  62791. * @returns a new Viewport
  62792. */
  62793. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  62794. /**
  62795. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  62796. * @param renderWidth defines the rendering width
  62797. * @param renderHeight defines the rendering height
  62798. * @param ref defines the target viewport
  62799. * @returns the current viewport
  62800. */
  62801. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  62802. /**
  62803. * Returns a new Viewport copied from the current one
  62804. * @returns a new Viewport
  62805. */
  62806. clone(): Viewport;
  62807. }
  62808. /**
  62809. * Reprasents a camera frustum
  62810. */
  62811. export class Frustum {
  62812. /**
  62813. * Gets the planes representing the frustum
  62814. * @param transform matrix to be applied to the returned planes
  62815. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  62816. */
  62817. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  62818. /**
  62819. * Gets the near frustum plane transformed by the transform matrix
  62820. * @param transform transformation matrix to be applied to the resulting frustum plane
  62821. * @param frustumPlane the resuling frustum plane
  62822. */
  62823. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62824. /**
  62825. * Gets the far frustum plane transformed by the transform matrix
  62826. * @param transform transformation matrix to be applied to the resulting frustum plane
  62827. * @param frustumPlane the resuling frustum plane
  62828. */
  62829. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62830. /**
  62831. * Gets the left frustum plane transformed by the transform matrix
  62832. * @param transform transformation matrix to be applied to the resulting frustum plane
  62833. * @param frustumPlane the resuling frustum plane
  62834. */
  62835. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62836. /**
  62837. * Gets the right frustum plane transformed by the transform matrix
  62838. * @param transform transformation matrix to be applied to the resulting frustum plane
  62839. * @param frustumPlane the resuling frustum plane
  62840. */
  62841. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62842. /**
  62843. * Gets the top frustum plane transformed by the transform matrix
  62844. * @param transform transformation matrix to be applied to the resulting frustum plane
  62845. * @param frustumPlane the resuling frustum plane
  62846. */
  62847. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62848. /**
  62849. * Gets the bottom frustum plane transformed by the transform matrix
  62850. * @param transform transformation matrix to be applied to the resulting frustum plane
  62851. * @param frustumPlane the resuling frustum plane
  62852. */
  62853. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62854. /**
  62855. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  62856. * @param transform transformation matrix to be applied to the resulting frustum planes
  62857. * @param frustumPlanes the resuling frustum planes
  62858. */
  62859. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  62860. }
  62861. /** Defines supported spaces */
  62862. export enum Space {
  62863. /** Local (object) space */
  62864. LOCAL = 0,
  62865. /** World space */
  62866. WORLD = 1,
  62867. /** Bone space */
  62868. BONE = 2
  62869. }
  62870. /** Defines the 3 main axes */
  62871. export class Axis {
  62872. /** X axis */
  62873. static X: Vector3;
  62874. /** Y axis */
  62875. static Y: Vector3;
  62876. /** Z axis */
  62877. static Z: Vector3;
  62878. }
  62879. /** Class used to represent a Bezier curve */
  62880. export class BezierCurve {
  62881. /**
  62882. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  62883. * @param t defines the time
  62884. * @param x1 defines the left coordinate on X axis
  62885. * @param y1 defines the left coordinate on Y axis
  62886. * @param x2 defines the right coordinate on X axis
  62887. * @param y2 defines the right coordinate on Y axis
  62888. * @returns the interpolated value
  62889. */
  62890. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  62891. }
  62892. /**
  62893. * Defines potential orientation for back face culling
  62894. */
  62895. export enum Orientation {
  62896. /**
  62897. * Clockwise
  62898. */
  62899. CW = 0,
  62900. /** Counter clockwise */
  62901. CCW = 1
  62902. }
  62903. /**
  62904. * Defines angle representation
  62905. */
  62906. export class Angle {
  62907. private _radians;
  62908. /**
  62909. * Creates an Angle object of "radians" radians (float).
  62910. * @param radians the angle in radians
  62911. */
  62912. constructor(radians: number);
  62913. /**
  62914. * Get value in degrees
  62915. * @returns the Angle value in degrees (float)
  62916. */
  62917. degrees(): number;
  62918. /**
  62919. * Get value in radians
  62920. * @returns the Angle value in radians (float)
  62921. */
  62922. radians(): number;
  62923. /**
  62924. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  62925. * @param a defines first vector
  62926. * @param b defines second vector
  62927. * @returns a new Angle
  62928. */
  62929. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  62930. /**
  62931. * Gets a new Angle object from the given float in radians
  62932. * @param radians defines the angle value in radians
  62933. * @returns a new Angle
  62934. */
  62935. static FromRadians(radians: number): Angle;
  62936. /**
  62937. * Gets a new Angle object from the given float in degrees
  62938. * @param degrees defines the angle value in degrees
  62939. * @returns a new Angle
  62940. */
  62941. static FromDegrees(degrees: number): Angle;
  62942. }
  62943. /**
  62944. * This represents an arc in a 2d space.
  62945. */
  62946. export class Arc2 {
  62947. /** Defines the start point of the arc */
  62948. startPoint: Vector2;
  62949. /** Defines the mid point of the arc */
  62950. midPoint: Vector2;
  62951. /** Defines the end point of the arc */
  62952. endPoint: Vector2;
  62953. /**
  62954. * Defines the center point of the arc.
  62955. */
  62956. centerPoint: Vector2;
  62957. /**
  62958. * Defines the radius of the arc.
  62959. */
  62960. radius: number;
  62961. /**
  62962. * Defines the angle of the arc (from mid point to end point).
  62963. */
  62964. angle: Angle;
  62965. /**
  62966. * Defines the start angle of the arc (from start point to middle point).
  62967. */
  62968. startAngle: Angle;
  62969. /**
  62970. * Defines the orientation of the arc (clock wise/counter clock wise).
  62971. */
  62972. orientation: Orientation;
  62973. /**
  62974. * Creates an Arc object from the three given points : start, middle and end.
  62975. * @param startPoint Defines the start point of the arc
  62976. * @param midPoint Defines the midlle point of the arc
  62977. * @param endPoint Defines the end point of the arc
  62978. */
  62979. constructor(
  62980. /** Defines the start point of the arc */
  62981. startPoint: Vector2,
  62982. /** Defines the mid point of the arc */
  62983. midPoint: Vector2,
  62984. /** Defines the end point of the arc */
  62985. endPoint: Vector2);
  62986. }
  62987. /**
  62988. * Represents a 2D path made up of multiple 2D points
  62989. */
  62990. export class Path2 {
  62991. private _points;
  62992. private _length;
  62993. /**
  62994. * If the path start and end point are the same
  62995. */
  62996. closed: boolean;
  62997. /**
  62998. * Creates a Path2 object from the starting 2D coordinates x and y.
  62999. * @param x the starting points x value
  63000. * @param y the starting points y value
  63001. */
  63002. constructor(x: number, y: number);
  63003. /**
  63004. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63005. * @param x the added points x value
  63006. * @param y the added points y value
  63007. * @returns the updated Path2.
  63008. */
  63009. addLineTo(x: number, y: number): Path2;
  63010. /**
  63011. * 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.
  63012. * @param midX middle point x value
  63013. * @param midY middle point y value
  63014. * @param endX end point x value
  63015. * @param endY end point y value
  63016. * @param numberOfSegments (default: 36)
  63017. * @returns the updated Path2.
  63018. */
  63019. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63020. /**
  63021. * Closes the Path2.
  63022. * @returns the Path2.
  63023. */
  63024. close(): Path2;
  63025. /**
  63026. * Gets the sum of the distance between each sequential point in the path
  63027. * @returns the Path2 total length (float).
  63028. */
  63029. length(): number;
  63030. /**
  63031. * Gets the points which construct the path
  63032. * @returns the Path2 internal array of points.
  63033. */
  63034. getPoints(): Vector2[];
  63035. /**
  63036. * Retreives the point at the distance aways from the starting point
  63037. * @param normalizedLengthPosition the length along the path to retreive the point from
  63038. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63039. */
  63040. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63041. /**
  63042. * Creates a new path starting from an x and y position
  63043. * @param x starting x value
  63044. * @param y starting y value
  63045. * @returns a new Path2 starting at the coordinates (x, y).
  63046. */
  63047. static StartingAt(x: number, y: number): Path2;
  63048. }
  63049. /**
  63050. * Represents a 3D path made up of multiple 3D points
  63051. */
  63052. export class Path3D {
  63053. /**
  63054. * an array of Vector3, the curve axis of the Path3D
  63055. */
  63056. path: Vector3[];
  63057. private _curve;
  63058. private _distances;
  63059. private _tangents;
  63060. private _normals;
  63061. private _binormals;
  63062. private _raw;
  63063. /**
  63064. * new Path3D(path, normal, raw)
  63065. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63066. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63067. * @param path an array of Vector3, the curve axis of the Path3D
  63068. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63069. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63070. */
  63071. constructor(
  63072. /**
  63073. * an array of Vector3, the curve axis of the Path3D
  63074. */
  63075. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63076. /**
  63077. * Returns the Path3D array of successive Vector3 designing its curve.
  63078. * @returns the Path3D array of successive Vector3 designing its curve.
  63079. */
  63080. getCurve(): Vector3[];
  63081. /**
  63082. * Returns an array populated with tangent vectors on each Path3D curve point.
  63083. * @returns an array populated with tangent vectors on each Path3D curve point.
  63084. */
  63085. getTangents(): Vector3[];
  63086. /**
  63087. * Returns an array populated with normal vectors on each Path3D curve point.
  63088. * @returns an array populated with normal vectors on each Path3D curve point.
  63089. */
  63090. getNormals(): Vector3[];
  63091. /**
  63092. * Returns an array populated with binormal vectors on each Path3D curve point.
  63093. * @returns an array populated with binormal vectors on each Path3D curve point.
  63094. */
  63095. getBinormals(): Vector3[];
  63096. /**
  63097. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63098. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63099. */
  63100. getDistances(): number[];
  63101. /**
  63102. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63103. * @param path path which all values are copied into the curves points
  63104. * @param firstNormal which should be projected onto the curve
  63105. * @returns the same object updated.
  63106. */
  63107. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63108. private _compute;
  63109. private _getFirstNonNullVector;
  63110. private _getLastNonNullVector;
  63111. private _normalVector;
  63112. }
  63113. /**
  63114. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63115. * A Curve3 is designed from a series of successive Vector3.
  63116. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63117. */
  63118. export class Curve3 {
  63119. private _points;
  63120. private _length;
  63121. /**
  63122. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63123. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63124. * @param v1 (Vector3) the control point
  63125. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63126. * @param nbPoints (integer) the wanted number of points in the curve
  63127. * @returns the created Curve3
  63128. */
  63129. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63130. /**
  63131. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63132. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63133. * @param v1 (Vector3) the first control point
  63134. * @param v2 (Vector3) the second control point
  63135. * @param v3 (Vector3) the end point of the Cubic Bezier
  63136. * @param nbPoints (integer) the wanted number of points in the curve
  63137. * @returns the created Curve3
  63138. */
  63139. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63140. /**
  63141. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63142. * @param p1 (Vector3) the origin point of the Hermite Spline
  63143. * @param t1 (Vector3) the tangent vector at the origin point
  63144. * @param p2 (Vector3) the end point of the Hermite Spline
  63145. * @param t2 (Vector3) the tangent vector at the end point
  63146. * @param nbPoints (integer) the wanted number of points in the curve
  63147. * @returns the created Curve3
  63148. */
  63149. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63150. /**
  63151. * Returns a Curve3 object along a CatmullRom Spline curve :
  63152. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63153. * @param nbPoints (integer) the wanted number of points between each curve control points
  63154. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63155. * @returns the created Curve3
  63156. */
  63157. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63158. /**
  63159. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63160. * A Curve3 is designed from a series of successive Vector3.
  63161. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63162. * @param points points which make up the curve
  63163. */
  63164. constructor(points: Vector3[]);
  63165. /**
  63166. * @returns the Curve3 stored array of successive Vector3
  63167. */
  63168. getPoints(): Vector3[];
  63169. /**
  63170. * @returns the computed length (float) of the curve.
  63171. */
  63172. length(): number;
  63173. /**
  63174. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63175. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63176. * curveA and curveB keep unchanged.
  63177. * @param curve the curve to continue from this curve
  63178. * @returns the newly constructed curve
  63179. */
  63180. continue(curve: DeepImmutable<Curve3>): Curve3;
  63181. private _computeLength;
  63182. }
  63183. /**
  63184. * Contains position and normal vectors for a vertex
  63185. */
  63186. export class PositionNormalVertex {
  63187. /** the position of the vertex (defaut: 0,0,0) */
  63188. position: Vector3;
  63189. /** the normal of the vertex (defaut: 0,1,0) */
  63190. normal: Vector3;
  63191. /**
  63192. * Creates a PositionNormalVertex
  63193. * @param position the position of the vertex (defaut: 0,0,0)
  63194. * @param normal the normal of the vertex (defaut: 0,1,0)
  63195. */
  63196. constructor(
  63197. /** the position of the vertex (defaut: 0,0,0) */
  63198. position?: Vector3,
  63199. /** the normal of the vertex (defaut: 0,1,0) */
  63200. normal?: Vector3);
  63201. /**
  63202. * Clones the PositionNormalVertex
  63203. * @returns the cloned PositionNormalVertex
  63204. */
  63205. clone(): PositionNormalVertex;
  63206. }
  63207. /**
  63208. * Contains position, normal and uv vectors for a vertex
  63209. */
  63210. export class PositionNormalTextureVertex {
  63211. /** the position of the vertex (defaut: 0,0,0) */
  63212. position: Vector3;
  63213. /** the normal of the vertex (defaut: 0,1,0) */
  63214. normal: Vector3;
  63215. /** the uv of the vertex (default: 0,0) */
  63216. uv: Vector2;
  63217. /**
  63218. * Creates a PositionNormalTextureVertex
  63219. * @param position the position of the vertex (defaut: 0,0,0)
  63220. * @param normal the normal of the vertex (defaut: 0,1,0)
  63221. * @param uv the uv of the vertex (default: 0,0)
  63222. */
  63223. constructor(
  63224. /** the position of the vertex (defaut: 0,0,0) */
  63225. position?: Vector3,
  63226. /** the normal of the vertex (defaut: 0,1,0) */
  63227. normal?: Vector3,
  63228. /** the uv of the vertex (default: 0,0) */
  63229. uv?: Vector2);
  63230. /**
  63231. * Clones the PositionNormalTextureVertex
  63232. * @returns the cloned PositionNormalTextureVertex
  63233. */
  63234. clone(): PositionNormalTextureVertex;
  63235. }
  63236. /**
  63237. * @hidden
  63238. */
  63239. export class Tmp {
  63240. static Color3: Color3[];
  63241. static Color4: Color4[];
  63242. static Vector2: Vector2[];
  63243. static Vector3: Vector3[];
  63244. static Vector4: Vector4[];
  63245. static Quaternion: Quaternion[];
  63246. static Matrix: Matrix[];
  63247. }
  63248. }
  63249. declare module BABYLON {
  63250. /**
  63251. * Class used to enable access to offline support
  63252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63253. */
  63254. export interface IOfflineProvider {
  63255. /**
  63256. * Gets a boolean indicating if scene must be saved in the database
  63257. */
  63258. enableSceneOffline: boolean;
  63259. /**
  63260. * Gets a boolean indicating if textures must be saved in the database
  63261. */
  63262. enableTexturesOffline: boolean;
  63263. /**
  63264. * Open the offline support and make it available
  63265. * @param successCallback defines the callback to call on success
  63266. * @param errorCallback defines the callback to call on error
  63267. */
  63268. open(successCallback: () => void, errorCallback: () => void): void;
  63269. /**
  63270. * Loads an image from the offline support
  63271. * @param url defines the url to load from
  63272. * @param image defines the target DOM image
  63273. */
  63274. loadImage(url: string, image: HTMLImageElement): void;
  63275. /**
  63276. * Loads a file from offline support
  63277. * @param url defines the URL to load from
  63278. * @param sceneLoaded defines a callback to call on success
  63279. * @param progressCallBack defines a callback to call when progress changed
  63280. * @param errorCallback defines a callback to call on error
  63281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63282. */
  63283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63284. }
  63285. }
  63286. declare module BABYLON {
  63287. /**
  63288. * A class serves as a medium between the observable and its observers
  63289. */
  63290. export class EventState {
  63291. /**
  63292. * Create a new EventState
  63293. * @param mask defines the mask associated with this state
  63294. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63295. * @param target defines the original target of the state
  63296. * @param currentTarget defines the current target of the state
  63297. */
  63298. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63299. /**
  63300. * Initialize the current event state
  63301. * @param mask defines the mask associated with this state
  63302. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63303. * @param target defines the original target of the state
  63304. * @param currentTarget defines the current target of the state
  63305. * @returns the current event state
  63306. */
  63307. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63308. /**
  63309. * An Observer can set this property to true to prevent subsequent observers of being notified
  63310. */
  63311. skipNextObservers: boolean;
  63312. /**
  63313. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63314. */
  63315. mask: number;
  63316. /**
  63317. * The object that originally notified the event
  63318. */
  63319. target?: any;
  63320. /**
  63321. * The current object in the bubbling phase
  63322. */
  63323. currentTarget?: any;
  63324. /**
  63325. * This will be populated with the return value of the last function that was executed.
  63326. * If it is the first function in the callback chain it will be the event data.
  63327. */
  63328. lastReturnValue?: any;
  63329. }
  63330. /**
  63331. * Represent an Observer registered to a given Observable object.
  63332. */
  63333. export class Observer<T> {
  63334. /**
  63335. * Defines the callback to call when the observer is notified
  63336. */
  63337. callback: (eventData: T, eventState: EventState) => void;
  63338. /**
  63339. * Defines the mask of the observer (used to filter notifications)
  63340. */
  63341. mask: number;
  63342. /**
  63343. * Defines the current scope used to restore the JS context
  63344. */
  63345. scope: any;
  63346. /** @hidden */
  63347. _willBeUnregistered: boolean;
  63348. /**
  63349. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63350. */
  63351. unregisterOnNextCall: boolean;
  63352. /**
  63353. * Creates a new observer
  63354. * @param callback defines the callback to call when the observer is notified
  63355. * @param mask defines the mask of the observer (used to filter notifications)
  63356. * @param scope defines the current scope used to restore the JS context
  63357. */
  63358. constructor(
  63359. /**
  63360. * Defines the callback to call when the observer is notified
  63361. */
  63362. callback: (eventData: T, eventState: EventState) => void,
  63363. /**
  63364. * Defines the mask of the observer (used to filter notifications)
  63365. */
  63366. mask: number,
  63367. /**
  63368. * Defines the current scope used to restore the JS context
  63369. */
  63370. scope?: any);
  63371. }
  63372. /**
  63373. * Represent a list of observers registered to multiple Observables object.
  63374. */
  63375. export class MultiObserver<T> {
  63376. private _observers;
  63377. private _observables;
  63378. /**
  63379. * Release associated resources
  63380. */
  63381. dispose(): void;
  63382. /**
  63383. * Raise a callback when one of the observable will notify
  63384. * @param observables defines a list of observables to watch
  63385. * @param callback defines the callback to call on notification
  63386. * @param mask defines the mask used to filter notifications
  63387. * @param scope defines the current scope used to restore the JS context
  63388. * @returns the new MultiObserver
  63389. */
  63390. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63391. }
  63392. /**
  63393. * The Observable class is a simple implementation of the Observable pattern.
  63394. *
  63395. * 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.
  63396. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63397. * 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).
  63398. * 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.
  63399. */
  63400. export class Observable<T> {
  63401. private _observers;
  63402. private _eventState;
  63403. private _onObserverAdded;
  63404. /**
  63405. * Creates a new observable
  63406. * @param onObserverAdded defines a callback to call when a new observer is added
  63407. */
  63408. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63409. /**
  63410. * Create a new Observer with the specified callback
  63411. * @param callback the callback that will be executed for that Observer
  63412. * @param mask the mask used to filter observers
  63413. * @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.
  63414. * @param scope optional scope for the callback to be called from
  63415. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63416. * @returns the new observer created for the callback
  63417. */
  63418. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63419. /**
  63420. * Create a new Observer with the specified callback and unregisters after the next notification
  63421. * @param callback the callback that will be executed for that Observer
  63422. * @returns the new observer created for the callback
  63423. */
  63424. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63425. /**
  63426. * Remove an Observer from the Observable object
  63427. * @param observer the instance of the Observer to remove
  63428. * @returns false if it doesn't belong to this Observable
  63429. */
  63430. remove(observer: Nullable<Observer<T>>): boolean;
  63431. /**
  63432. * Remove a callback from the Observable object
  63433. * @param callback the callback to remove
  63434. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63435. * @returns false if it doesn't belong to this Observable
  63436. */
  63437. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63438. private _deferUnregister;
  63439. private _remove;
  63440. /**
  63441. * Moves the observable to the top of the observer list making it get called first when notified
  63442. * @param observer the observer to move
  63443. */
  63444. makeObserverTopPriority(observer: Observer<T>): void;
  63445. /**
  63446. * Moves the observable to the bottom of the observer list making it get called last when notified
  63447. * @param observer the observer to move
  63448. */
  63449. makeObserverBottomPriority(observer: Observer<T>): void;
  63450. /**
  63451. * Notify all Observers by calling their respective callback with the given data
  63452. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63453. * @param eventData defines the data to send to all observers
  63454. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63455. * @param target defines the original target of the state
  63456. * @param currentTarget defines the current target of the state
  63457. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63458. */
  63459. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63460. /**
  63461. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63462. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63463. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63464. * and it is crucial that all callbacks will be executed.
  63465. * The order of the callbacks is kept, callbacks are not executed parallel.
  63466. *
  63467. * @param eventData The data to be sent to each callback
  63468. * @param mask is used to filter observers defaults to -1
  63469. * @param target defines the callback target (see EventState)
  63470. * @param currentTarget defines he current object in the bubbling phase
  63471. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63472. */
  63473. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63474. /**
  63475. * Notify a specific observer
  63476. * @param observer defines the observer to notify
  63477. * @param eventData defines the data to be sent to each callback
  63478. * @param mask is used to filter observers defaults to -1
  63479. */
  63480. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63481. /**
  63482. * Gets a boolean indicating if the observable has at least one observer
  63483. * @returns true is the Observable has at least one Observer registered
  63484. */
  63485. hasObservers(): boolean;
  63486. /**
  63487. * Clear the list of observers
  63488. */
  63489. clear(): void;
  63490. /**
  63491. * Clone the current observable
  63492. * @returns a new observable
  63493. */
  63494. clone(): Observable<T>;
  63495. /**
  63496. * Does this observable handles observer registered with a given mask
  63497. * @param mask defines the mask to be tested
  63498. * @return whether or not one observer registered with the given mask is handeled
  63499. **/
  63500. hasSpecificMask(mask?: number): boolean;
  63501. }
  63502. }
  63503. declare module BABYLON {
  63504. /**
  63505. * Class used to help managing file picking and drag'n'drop
  63506. * File Storage
  63507. */
  63508. export class FilesInputStore {
  63509. /**
  63510. * List of files ready to be loaded
  63511. */
  63512. static FilesToLoad: {
  63513. [key: string]: File;
  63514. };
  63515. }
  63516. }
  63517. declare module BABYLON {
  63518. /** Defines the cross module used constants to avoid circular dependncies */
  63519. export class Constants {
  63520. /** Defines that alpha blending is disabled */
  63521. static readonly ALPHA_DISABLE: number;
  63522. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  63523. static readonly ALPHA_ADD: number;
  63524. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  63525. static readonly ALPHA_COMBINE: number;
  63526. /** Defines that alpha blending to DEST - SRC * DEST */
  63527. static readonly ALPHA_SUBTRACT: number;
  63528. /** Defines that alpha blending to SRC * DEST */
  63529. static readonly ALPHA_MULTIPLY: number;
  63530. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  63531. static readonly ALPHA_MAXIMIZED: number;
  63532. /** Defines that alpha blending to SRC + DEST */
  63533. static readonly ALPHA_ONEONE: number;
  63534. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  63535. static readonly ALPHA_PREMULTIPLIED: number;
  63536. /**
  63537. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  63538. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  63539. */
  63540. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  63541. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  63542. static readonly ALPHA_INTERPOLATE: number;
  63543. /**
  63544. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  63545. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  63546. */
  63547. static readonly ALPHA_SCREENMODE: number;
  63548. /** Defines that the ressource is not delayed*/
  63549. static readonly DELAYLOADSTATE_NONE: number;
  63550. /** Defines that the ressource was successfully delay loaded */
  63551. static readonly DELAYLOADSTATE_LOADED: number;
  63552. /** Defines that the ressource is currently delay loading */
  63553. static readonly DELAYLOADSTATE_LOADING: number;
  63554. /** Defines that the ressource is delayed and has not started loading */
  63555. static readonly DELAYLOADSTATE_NOTLOADED: number;
  63556. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  63557. static readonly NEVER: number;
  63558. /** 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 */
  63559. static readonly ALWAYS: number;
  63560. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  63561. static readonly LESS: number;
  63562. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  63563. static readonly EQUAL: number;
  63564. /** 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 */
  63565. static readonly LEQUAL: number;
  63566. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  63567. static readonly GREATER: number;
  63568. /** 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 */
  63569. static readonly GEQUAL: number;
  63570. /** 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 */
  63571. static readonly NOTEQUAL: number;
  63572. /** Passed to stencilOperation to specify that stencil value must be kept */
  63573. static readonly KEEP: number;
  63574. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63575. static readonly REPLACE: number;
  63576. /** Passed to stencilOperation to specify that stencil value must be incremented */
  63577. static readonly INCR: number;
  63578. /** Passed to stencilOperation to specify that stencil value must be decremented */
  63579. static readonly DECR: number;
  63580. /** Passed to stencilOperation to specify that stencil value must be inverted */
  63581. static readonly INVERT: number;
  63582. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  63583. static readonly INCR_WRAP: number;
  63584. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63585. static readonly DECR_WRAP: number;
  63586. /** Texture is not repeating outside of 0..1 UVs */
  63587. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63588. /** Texture is repeating outside of 0..1 UVs */
  63589. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63590. /** Texture is repeating and mirrored */
  63591. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63592. /** ALPHA */
  63593. static readonly TEXTUREFORMAT_ALPHA: number;
  63594. /** LUMINANCE */
  63595. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63596. /** LUMINANCE_ALPHA */
  63597. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63598. /** RGB */
  63599. static readonly TEXTUREFORMAT_RGB: number;
  63600. /** RGBA */
  63601. static readonly TEXTUREFORMAT_RGBA: number;
  63602. /** RED */
  63603. static readonly TEXTUREFORMAT_RED: number;
  63604. /** RED (2nd reference) */
  63605. static readonly TEXTUREFORMAT_R: number;
  63606. /** RG */
  63607. static readonly TEXTUREFORMAT_RG: number;
  63608. /** RED_INTEGER */
  63609. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63610. /** RED_INTEGER (2nd reference) */
  63611. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63612. /** RG_INTEGER */
  63613. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63614. /** RGB_INTEGER */
  63615. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63616. /** RGBA_INTEGER */
  63617. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63618. /** UNSIGNED_BYTE */
  63619. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63620. /** UNSIGNED_BYTE (2nd reference) */
  63621. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63622. /** FLOAT */
  63623. static readonly TEXTURETYPE_FLOAT: number;
  63624. /** HALF_FLOAT */
  63625. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63626. /** BYTE */
  63627. static readonly TEXTURETYPE_BYTE: number;
  63628. /** SHORT */
  63629. static readonly TEXTURETYPE_SHORT: number;
  63630. /** UNSIGNED_SHORT */
  63631. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63632. /** INT */
  63633. static readonly TEXTURETYPE_INT: number;
  63634. /** UNSIGNED_INT */
  63635. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63636. /** UNSIGNED_SHORT_4_4_4_4 */
  63637. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63638. /** UNSIGNED_SHORT_5_5_5_1 */
  63639. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63640. /** UNSIGNED_SHORT_5_6_5 */
  63641. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63642. /** UNSIGNED_INT_2_10_10_10_REV */
  63643. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63644. /** UNSIGNED_INT_24_8 */
  63645. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63646. /** UNSIGNED_INT_10F_11F_11F_REV */
  63647. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63648. /** UNSIGNED_INT_5_9_9_9_REV */
  63649. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63650. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63651. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63652. /** nearest is mag = nearest and min = nearest and mip = linear */
  63653. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63654. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63655. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  63656. /** Trilinear is mag = linear and min = linear and mip = linear */
  63657. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  63658. /** nearest is mag = nearest and min = nearest and mip = linear */
  63659. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  63660. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63661. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  63662. /** Trilinear is mag = linear and min = linear and mip = linear */
  63663. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  63664. /** mag = nearest and min = nearest and mip = nearest */
  63665. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  63666. /** mag = nearest and min = linear and mip = nearest */
  63667. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  63668. /** mag = nearest and min = linear and mip = linear */
  63669. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  63670. /** mag = nearest and min = linear and mip = none */
  63671. static readonly TEXTURE_NEAREST_LINEAR: number;
  63672. /** mag = nearest and min = nearest and mip = none */
  63673. static readonly TEXTURE_NEAREST_NEAREST: number;
  63674. /** mag = linear and min = nearest and mip = nearest */
  63675. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  63676. /** mag = linear and min = nearest and mip = linear */
  63677. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  63678. /** mag = linear and min = linear and mip = none */
  63679. static readonly TEXTURE_LINEAR_LINEAR: number;
  63680. /** mag = linear and min = nearest and mip = none */
  63681. static readonly TEXTURE_LINEAR_NEAREST: number;
  63682. /** Explicit coordinates mode */
  63683. static readonly TEXTURE_EXPLICIT_MODE: number;
  63684. /** Spherical coordinates mode */
  63685. static readonly TEXTURE_SPHERICAL_MODE: number;
  63686. /** Planar coordinates mode */
  63687. static readonly TEXTURE_PLANAR_MODE: number;
  63688. /** Cubic coordinates mode */
  63689. static readonly TEXTURE_CUBIC_MODE: number;
  63690. /** Projection coordinates mode */
  63691. static readonly TEXTURE_PROJECTION_MODE: number;
  63692. /** Skybox coordinates mode */
  63693. static readonly TEXTURE_SKYBOX_MODE: number;
  63694. /** Inverse Cubic coordinates mode */
  63695. static readonly TEXTURE_INVCUBIC_MODE: number;
  63696. /** Equirectangular coordinates mode */
  63697. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  63698. /** Equirectangular Fixed coordinates mode */
  63699. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  63700. /** Equirectangular Fixed Mirrored coordinates mode */
  63701. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  63702. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  63703. static readonly SCALEMODE_FLOOR: number;
  63704. /** Defines that texture rescaling will look for the nearest power of 2 size */
  63705. static readonly SCALEMODE_NEAREST: number;
  63706. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  63707. static readonly SCALEMODE_CEILING: number;
  63708. /**
  63709. * The dirty texture flag value
  63710. */
  63711. static readonly MATERIAL_TextureDirtyFlag: number;
  63712. /**
  63713. * The dirty light flag value
  63714. */
  63715. static readonly MATERIAL_LightDirtyFlag: number;
  63716. /**
  63717. * The dirty fresnel flag value
  63718. */
  63719. static readonly MATERIAL_FresnelDirtyFlag: number;
  63720. /**
  63721. * The dirty attribute flag value
  63722. */
  63723. static readonly MATERIAL_AttributesDirtyFlag: number;
  63724. /**
  63725. * The dirty misc flag value
  63726. */
  63727. static readonly MATERIAL_MiscDirtyFlag: number;
  63728. /**
  63729. * The all dirty flag value
  63730. */
  63731. static readonly MATERIAL_AllDirtyFlag: number;
  63732. /**
  63733. * Returns the triangle fill mode
  63734. */
  63735. static readonly MATERIAL_TriangleFillMode: number;
  63736. /**
  63737. * Returns the wireframe mode
  63738. */
  63739. static readonly MATERIAL_WireFrameFillMode: number;
  63740. /**
  63741. * Returns the point fill mode
  63742. */
  63743. static readonly MATERIAL_PointFillMode: number;
  63744. /**
  63745. * Returns the point list draw mode
  63746. */
  63747. static readonly MATERIAL_PointListDrawMode: number;
  63748. /**
  63749. * Returns the line list draw mode
  63750. */
  63751. static readonly MATERIAL_LineListDrawMode: number;
  63752. /**
  63753. * Returns the line loop draw mode
  63754. */
  63755. static readonly MATERIAL_LineLoopDrawMode: number;
  63756. /**
  63757. * Returns the line strip draw mode
  63758. */
  63759. static readonly MATERIAL_LineStripDrawMode: number;
  63760. /**
  63761. * Returns the triangle strip draw mode
  63762. */
  63763. static readonly MATERIAL_TriangleStripDrawMode: number;
  63764. /**
  63765. * Returns the triangle fan draw mode
  63766. */
  63767. static readonly MATERIAL_TriangleFanDrawMode: number;
  63768. /**
  63769. * Stores the clock-wise side orientation
  63770. */
  63771. static readonly MATERIAL_ClockWiseSideOrientation: number;
  63772. /**
  63773. * Stores the counter clock-wise side orientation
  63774. */
  63775. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  63776. /**
  63777. * Nothing
  63778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63779. */
  63780. static readonly ACTION_NothingTrigger: number;
  63781. /**
  63782. * On pick
  63783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63784. */
  63785. static readonly ACTION_OnPickTrigger: number;
  63786. /**
  63787. * On left pick
  63788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63789. */
  63790. static readonly ACTION_OnLeftPickTrigger: number;
  63791. /**
  63792. * On right pick
  63793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63794. */
  63795. static readonly ACTION_OnRightPickTrigger: number;
  63796. /**
  63797. * On center pick
  63798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63799. */
  63800. static readonly ACTION_OnCenterPickTrigger: number;
  63801. /**
  63802. * On pick down
  63803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63804. */
  63805. static readonly ACTION_OnPickDownTrigger: number;
  63806. /**
  63807. * On double pick
  63808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63809. */
  63810. static readonly ACTION_OnDoublePickTrigger: number;
  63811. /**
  63812. * On pick up
  63813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63814. */
  63815. static readonly ACTION_OnPickUpTrigger: number;
  63816. /**
  63817. * On pick out.
  63818. * This trigger will only be raised if you also declared a OnPickDown
  63819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63820. */
  63821. static readonly ACTION_OnPickOutTrigger: number;
  63822. /**
  63823. * On long press
  63824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63825. */
  63826. static readonly ACTION_OnLongPressTrigger: number;
  63827. /**
  63828. * On pointer over
  63829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63830. */
  63831. static readonly ACTION_OnPointerOverTrigger: number;
  63832. /**
  63833. * On pointer out
  63834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63835. */
  63836. static readonly ACTION_OnPointerOutTrigger: number;
  63837. /**
  63838. * On every frame
  63839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63840. */
  63841. static readonly ACTION_OnEveryFrameTrigger: number;
  63842. /**
  63843. * On intersection enter
  63844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63845. */
  63846. static readonly ACTION_OnIntersectionEnterTrigger: number;
  63847. /**
  63848. * On intersection exit
  63849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63850. */
  63851. static readonly ACTION_OnIntersectionExitTrigger: number;
  63852. /**
  63853. * On key down
  63854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63855. */
  63856. static readonly ACTION_OnKeyDownTrigger: number;
  63857. /**
  63858. * On key up
  63859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63860. */
  63861. static readonly ACTION_OnKeyUpTrigger: number;
  63862. /**
  63863. * Billboard mode will only apply to Y axis
  63864. */
  63865. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  63866. /**
  63867. * Billboard mode will apply to all axes
  63868. */
  63869. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  63870. /**
  63871. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  63872. */
  63873. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  63874. /**
  63875. * Gets or sets base Assets URL
  63876. */
  63877. static readonly PARTICLES_BaseAssetsUrl: string;
  63878. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  63879. * Test order :
  63880. * Is the bounding sphere outside the frustum ?
  63881. * If not, are the bounding box vertices outside the frustum ?
  63882. * It not, then the cullable object is in the frustum.
  63883. */
  63884. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  63885. /** Culling strategy : Bounding Sphere Only.
  63886. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  63887. * It's also less accurate than the standard because some not visible objects can still be selected.
  63888. * Test : is the bounding sphere outside the frustum ?
  63889. * If not, then the cullable object is in the frustum.
  63890. */
  63891. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  63892. /** Culling strategy : Optimistic Inclusion.
  63893. * This in an inclusion test first, then the standard exclusion test.
  63894. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  63895. * 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.
  63896. * Anyway, it's as accurate as the standard strategy.
  63897. * Test :
  63898. * Is the cullable object bounding sphere center in the frustum ?
  63899. * If not, apply the default culling strategy.
  63900. */
  63901. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  63902. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  63903. * This in an inclusion test first, then the bounding sphere only exclusion test.
  63904. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  63905. * 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.
  63906. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  63907. * Test :
  63908. * Is the cullable object bounding sphere center in the frustum ?
  63909. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  63910. */
  63911. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  63912. /**
  63913. * No logging while loading
  63914. */
  63915. static readonly SCENELOADER_NO_LOGGING: number;
  63916. /**
  63917. * Minimal logging while loading
  63918. */
  63919. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  63920. /**
  63921. * Summary logging while loading
  63922. */
  63923. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  63924. /**
  63925. * Detailled logging while loading
  63926. */
  63927. static readonly SCENELOADER_DETAILED_LOGGING: number;
  63928. }
  63929. }
  63930. declare module BABYLON {
  63931. /**
  63932. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  63933. * Babylon.js
  63934. */
  63935. export class DomManagement {
  63936. /**
  63937. * Checks if the window object exists
  63938. * @returns true if the window object exists
  63939. */
  63940. static IsWindowObjectExist(): boolean;
  63941. /**
  63942. * Extracts text content from a DOM element hierarchy
  63943. * @param element defines the root element
  63944. * @returns a string
  63945. */
  63946. static GetDOMTextContent(element: HTMLElement): string;
  63947. }
  63948. }
  63949. declare module BABYLON {
  63950. /**
  63951. * Logger used througouht the application to allow configuration of
  63952. * the log level required for the messages.
  63953. */
  63954. export class Logger {
  63955. /**
  63956. * No log
  63957. */
  63958. static readonly NoneLogLevel: number;
  63959. /**
  63960. * Only message logs
  63961. */
  63962. static readonly MessageLogLevel: number;
  63963. /**
  63964. * Only warning logs
  63965. */
  63966. static readonly WarningLogLevel: number;
  63967. /**
  63968. * Only error logs
  63969. */
  63970. static readonly ErrorLogLevel: number;
  63971. /**
  63972. * All logs
  63973. */
  63974. static readonly AllLogLevel: number;
  63975. private static _LogCache;
  63976. /**
  63977. * Gets a value indicating the number of loading errors
  63978. * @ignorenaming
  63979. */
  63980. static errorsCount: number;
  63981. /**
  63982. * Callback called when a new log is added
  63983. */
  63984. static OnNewCacheEntry: (entry: string) => void;
  63985. private static _AddLogEntry;
  63986. private static _FormatMessage;
  63987. private static _LogDisabled;
  63988. private static _LogEnabled;
  63989. private static _WarnDisabled;
  63990. private static _WarnEnabled;
  63991. private static _ErrorDisabled;
  63992. private static _ErrorEnabled;
  63993. /**
  63994. * Log a message to the console
  63995. */
  63996. static Log: (message: string) => void;
  63997. /**
  63998. * Write a warning message to the console
  63999. */
  64000. static Warn: (message: string) => void;
  64001. /**
  64002. * Write an error message to the console
  64003. */
  64004. static Error: (message: string) => void;
  64005. /**
  64006. * Gets current log cache (list of logs)
  64007. */
  64008. static readonly LogCache: string;
  64009. /**
  64010. * Clears the log cache
  64011. */
  64012. static ClearLogCache(): void;
  64013. /**
  64014. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64015. */
  64016. static LogLevels: number;
  64017. }
  64018. }
  64019. declare module BABYLON {
  64020. /** @hidden */
  64021. export class _TypeStore {
  64022. /** @hidden */
  64023. static RegisteredTypes: {
  64024. [key: string]: Object;
  64025. };
  64026. /** @hidden */
  64027. static GetClass(fqdn: string): any;
  64028. }
  64029. }
  64030. declare module BABYLON {
  64031. /**
  64032. * Class containing a set of static utilities functions for deep copy.
  64033. */
  64034. export class DeepCopier {
  64035. /**
  64036. * Tries to copy an object by duplicating every property
  64037. * @param source defines the source object
  64038. * @param destination defines the target object
  64039. * @param doNotCopyList defines a list of properties to avoid
  64040. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64041. */
  64042. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64043. }
  64044. }
  64045. declare module BABYLON {
  64046. /**
  64047. * Class containing a set of static utilities functions for precision date
  64048. */
  64049. export class PrecisionDate {
  64050. /**
  64051. * Gets either window.performance.now() if supported or Date.now() else
  64052. */
  64053. static readonly Now: number;
  64054. }
  64055. }
  64056. declare module BABYLON {
  64057. /** @hidden */
  64058. export class _DevTools {
  64059. static WarnImport(name: string): string;
  64060. }
  64061. }
  64062. declare module BABYLON {
  64063. /**
  64064. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64065. */
  64066. export class WebRequest {
  64067. private _xhr;
  64068. /**
  64069. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64070. * i.e. when loading files, where the server/service expects an Authorization header
  64071. */
  64072. static CustomRequestHeaders: {
  64073. [key: string]: string;
  64074. };
  64075. /**
  64076. * Add callback functions in this array to update all the requests before they get sent to the network
  64077. */
  64078. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64079. private _injectCustomRequestHeaders;
  64080. /**
  64081. * Gets or sets a function to be called when loading progress changes
  64082. */
  64083. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64084. /**
  64085. * Returns client's state
  64086. */
  64087. readonly readyState: number;
  64088. /**
  64089. * Returns client's status
  64090. */
  64091. readonly status: number;
  64092. /**
  64093. * Returns client's status as a text
  64094. */
  64095. readonly statusText: string;
  64096. /**
  64097. * Returns client's response
  64098. */
  64099. readonly response: any;
  64100. /**
  64101. * Returns client's response url
  64102. */
  64103. readonly responseURL: string;
  64104. /**
  64105. * Returns client's response as text
  64106. */
  64107. readonly responseText: string;
  64108. /**
  64109. * Gets or sets the expected response type
  64110. */
  64111. responseType: XMLHttpRequestResponseType;
  64112. /** @hidden */
  64113. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64114. /** @hidden */
  64115. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64116. /**
  64117. * Cancels any network activity
  64118. */
  64119. abort(): void;
  64120. /**
  64121. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64122. * @param body defines an optional request body
  64123. */
  64124. send(body?: Document | BodyInit | null): void;
  64125. /**
  64126. * Sets the request method, request URL
  64127. * @param method defines the method to use (GET, POST, etc..)
  64128. * @param url defines the url to connect with
  64129. */
  64130. open(method: string, url: string): void;
  64131. }
  64132. }
  64133. declare module BABYLON {
  64134. /**
  64135. * Class used to evalaute queries containing `and` and `or` operators
  64136. */
  64137. export class AndOrNotEvaluator {
  64138. /**
  64139. * Evaluate a query
  64140. * @param query defines the query to evaluate
  64141. * @param evaluateCallback defines the callback used to filter result
  64142. * @returns true if the query matches
  64143. */
  64144. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64145. private static _HandleParenthesisContent;
  64146. private static _SimplifyNegation;
  64147. }
  64148. }
  64149. declare module BABYLON {
  64150. /**
  64151. * Class used to store custom tags
  64152. */
  64153. export class Tags {
  64154. /**
  64155. * Adds support for tags on the given object
  64156. * @param obj defines the object to use
  64157. */
  64158. static EnableFor(obj: any): void;
  64159. /**
  64160. * Removes tags support
  64161. * @param obj defines the object to use
  64162. */
  64163. static DisableFor(obj: any): void;
  64164. /**
  64165. * Gets a boolean indicating if the given object has tags
  64166. * @param obj defines the object to use
  64167. * @returns a boolean
  64168. */
  64169. static HasTags(obj: any): boolean;
  64170. /**
  64171. * Gets the tags available on a given object
  64172. * @param obj defines the object to use
  64173. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64174. * @returns the tags
  64175. */
  64176. static GetTags(obj: any, asString?: boolean): any;
  64177. /**
  64178. * Adds tags to an object
  64179. * @param obj defines the object to use
  64180. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64181. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64182. */
  64183. static AddTagsTo(obj: any, tagsString: string): void;
  64184. /**
  64185. * @hidden
  64186. */
  64187. static _AddTagTo(obj: any, tag: string): void;
  64188. /**
  64189. * Removes specific tags from a specific object
  64190. * @param obj defines the object to use
  64191. * @param tagsString defines the tags to remove
  64192. */
  64193. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64194. /**
  64195. * @hidden
  64196. */
  64197. static _RemoveTagFrom(obj: any, tag: string): void;
  64198. /**
  64199. * Defines if tags hosted on an object match a given query
  64200. * @param obj defines the object to use
  64201. * @param tagsQuery defines the tag query
  64202. * @returns a boolean
  64203. */
  64204. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  64205. }
  64206. }
  64207. declare module BABYLON {
  64208. /**
  64209. * Manages the defines for the Material
  64210. */
  64211. export class MaterialDefines {
  64212. private _keys;
  64213. private _isDirty;
  64214. /** @hidden */
  64215. _renderId: number;
  64216. /** @hidden */
  64217. _areLightsDirty: boolean;
  64218. /** @hidden */
  64219. _areAttributesDirty: boolean;
  64220. /** @hidden */
  64221. _areTexturesDirty: boolean;
  64222. /** @hidden */
  64223. _areFresnelDirty: boolean;
  64224. /** @hidden */
  64225. _areMiscDirty: boolean;
  64226. /** @hidden */
  64227. _areImageProcessingDirty: boolean;
  64228. /** @hidden */
  64229. _normals: boolean;
  64230. /** @hidden */
  64231. _uvs: boolean;
  64232. /** @hidden */
  64233. _needNormals: boolean;
  64234. /** @hidden */
  64235. _needUVs: boolean;
  64236. /**
  64237. * Specifies if the material needs to be re-calculated
  64238. */
  64239. readonly isDirty: boolean;
  64240. /**
  64241. * Marks the material to indicate that it has been re-calculated
  64242. */
  64243. markAsProcessed(): void;
  64244. /**
  64245. * Marks the material to indicate that it needs to be re-calculated
  64246. */
  64247. markAsUnprocessed(): void;
  64248. /**
  64249. * Marks the material to indicate all of its defines need to be re-calculated
  64250. */
  64251. markAllAsDirty(): void;
  64252. /**
  64253. * Marks the material to indicate that image processing needs to be re-calculated
  64254. */
  64255. markAsImageProcessingDirty(): void;
  64256. /**
  64257. * Marks the material to indicate the lights need to be re-calculated
  64258. */
  64259. markAsLightDirty(): void;
  64260. /**
  64261. * Marks the attribute state as changed
  64262. */
  64263. markAsAttributesDirty(): void;
  64264. /**
  64265. * Marks the texture state as changed
  64266. */
  64267. markAsTexturesDirty(): void;
  64268. /**
  64269. * Marks the fresnel state as changed
  64270. */
  64271. markAsFresnelDirty(): void;
  64272. /**
  64273. * Marks the misc state as changed
  64274. */
  64275. markAsMiscDirty(): void;
  64276. /**
  64277. * Rebuilds the material defines
  64278. */
  64279. rebuild(): void;
  64280. /**
  64281. * Specifies if two material defines are equal
  64282. * @param other - A material define instance to compare to
  64283. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64284. */
  64285. isEqual(other: MaterialDefines): boolean;
  64286. /**
  64287. * Clones this instance's defines to another instance
  64288. * @param other - material defines to clone values to
  64289. */
  64290. cloneTo(other: MaterialDefines): void;
  64291. /**
  64292. * Resets the material define values
  64293. */
  64294. reset(): void;
  64295. /**
  64296. * Converts the material define values to a string
  64297. * @returns - String of material define information
  64298. */
  64299. toString(): string;
  64300. }
  64301. }
  64302. declare module BABYLON {
  64303. /**
  64304. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64305. */
  64306. export class PerformanceMonitor {
  64307. private _enabled;
  64308. private _rollingFrameTime;
  64309. private _lastFrameTimeMs;
  64310. /**
  64311. * constructor
  64312. * @param frameSampleSize The number of samples required to saturate the sliding window
  64313. */
  64314. constructor(frameSampleSize?: number);
  64315. /**
  64316. * Samples current frame
  64317. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64318. */
  64319. sampleFrame(timeMs?: number): void;
  64320. /**
  64321. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64322. */
  64323. readonly averageFrameTime: number;
  64324. /**
  64325. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64326. */
  64327. readonly averageFrameTimeVariance: number;
  64328. /**
  64329. * Returns the frame time of the most recent frame
  64330. */
  64331. readonly instantaneousFrameTime: number;
  64332. /**
  64333. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64334. */
  64335. readonly averageFPS: number;
  64336. /**
  64337. * Returns the average framerate in frames per second using the most recent frame time
  64338. */
  64339. readonly instantaneousFPS: number;
  64340. /**
  64341. * Returns true if enough samples have been taken to completely fill the sliding window
  64342. */
  64343. readonly isSaturated: boolean;
  64344. /**
  64345. * Enables contributions to the sliding window sample set
  64346. */
  64347. enable(): void;
  64348. /**
  64349. * Disables contributions to the sliding window sample set
  64350. * Samples will not be interpolated over the disabled period
  64351. */
  64352. disable(): void;
  64353. /**
  64354. * Returns true if sampling is enabled
  64355. */
  64356. readonly isEnabled: boolean;
  64357. /**
  64358. * Resets performance monitor
  64359. */
  64360. reset(): void;
  64361. }
  64362. /**
  64363. * RollingAverage
  64364. *
  64365. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64366. */
  64367. export class RollingAverage {
  64368. /**
  64369. * Current average
  64370. */
  64371. average: number;
  64372. /**
  64373. * Current variance
  64374. */
  64375. variance: number;
  64376. protected _samples: Array<number>;
  64377. protected _sampleCount: number;
  64378. protected _pos: number;
  64379. protected _m2: number;
  64380. /**
  64381. * constructor
  64382. * @param length The number of samples required to saturate the sliding window
  64383. */
  64384. constructor(length: number);
  64385. /**
  64386. * Adds a sample to the sample set
  64387. * @param v The sample value
  64388. */
  64389. add(v: number): void;
  64390. /**
  64391. * Returns previously added values or null if outside of history or outside the sliding window domain
  64392. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64393. * @return Value previously recorded with add() or null if outside of range
  64394. */
  64395. history(i: number): number;
  64396. /**
  64397. * Returns true if enough samples have been taken to completely fill the sliding window
  64398. * @return true if sample-set saturated
  64399. */
  64400. isSaturated(): boolean;
  64401. /**
  64402. * Resets the rolling average (equivalent to 0 samples taken so far)
  64403. */
  64404. reset(): void;
  64405. /**
  64406. * Wraps a value around the sample range boundaries
  64407. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64408. * @return Wrapped position in sample range
  64409. */
  64410. protected _wrapPosition(i: number): number;
  64411. }
  64412. }
  64413. declare module BABYLON {
  64414. /**
  64415. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64416. * The underlying implementation relies on an associative array to ensure the best performances.
  64417. * The value can be anything including 'null' but except 'undefined'
  64418. */
  64419. export class StringDictionary<T> {
  64420. /**
  64421. * This will clear this dictionary and copy the content from the 'source' one.
  64422. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64423. * @param source the dictionary to take the content from and copy to this dictionary
  64424. */
  64425. copyFrom(source: StringDictionary<T>): void;
  64426. /**
  64427. * Get a value based from its key
  64428. * @param key the given key to get the matching value from
  64429. * @return the value if found, otherwise undefined is returned
  64430. */
  64431. get(key: string): T | undefined;
  64432. /**
  64433. * Get a value from its key or add it if it doesn't exist.
  64434. * This method will ensure you that a given key/data will be present in the dictionary.
  64435. * @param key the given key to get the matching value from
  64436. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64437. * The factory will only be invoked if there's no data for the given key.
  64438. * @return the value corresponding to the key.
  64439. */
  64440. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64441. /**
  64442. * Get a value from its key if present in the dictionary otherwise add it
  64443. * @param key the key to get the value from
  64444. * @param val if there's no such key/value pair in the dictionary add it with this value
  64445. * @return the value corresponding to the key
  64446. */
  64447. getOrAdd(key: string, val: T): T;
  64448. /**
  64449. * Check if there's a given key in the dictionary
  64450. * @param key the key to check for
  64451. * @return true if the key is present, false otherwise
  64452. */
  64453. contains(key: string): boolean;
  64454. /**
  64455. * Add a new key and its corresponding value
  64456. * @param key the key to add
  64457. * @param value the value corresponding to the key
  64458. * @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
  64459. */
  64460. add(key: string, value: T): boolean;
  64461. /**
  64462. * Update a specific value associated to a key
  64463. * @param key defines the key to use
  64464. * @param value defines the value to store
  64465. * @returns true if the value was updated (or false if the key was not found)
  64466. */
  64467. set(key: string, value: T): boolean;
  64468. /**
  64469. * Get the element of the given key and remove it from the dictionary
  64470. * @param key defines the key to search
  64471. * @returns the value associated with the key or null if not found
  64472. */
  64473. getAndRemove(key: string): Nullable<T>;
  64474. /**
  64475. * Remove a key/value from the dictionary.
  64476. * @param key the key to remove
  64477. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64478. */
  64479. remove(key: string): boolean;
  64480. /**
  64481. * Clear the whole content of the dictionary
  64482. */
  64483. clear(): void;
  64484. /**
  64485. * Gets the current count
  64486. */
  64487. readonly count: number;
  64488. /**
  64489. * Execute a callback on each key/val of the dictionary.
  64490. * Note that you can remove any element in this dictionary in the callback implementation
  64491. * @param callback the callback to execute on a given key/value pair
  64492. */
  64493. forEach(callback: (key: string, val: T) => void): void;
  64494. /**
  64495. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64496. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64497. * Note that you can remove any element in this dictionary in the callback implementation
  64498. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64499. * @returns the first item
  64500. */
  64501. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64502. private _count;
  64503. private _data;
  64504. }
  64505. }
  64506. declare module BABYLON {
  64507. /**
  64508. * Helper class that provides a small promise polyfill
  64509. */
  64510. export class PromisePolyfill {
  64511. /**
  64512. * Static function used to check if the polyfill is required
  64513. * If this is the case then the function will inject the polyfill to window.Promise
  64514. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  64515. */
  64516. static Apply(force?: boolean): void;
  64517. }
  64518. }
  64519. declare module BABYLON {
  64520. /**
  64521. * Class used to store data that will be store in GPU memory
  64522. */
  64523. export class Buffer {
  64524. private _engine;
  64525. private _buffer;
  64526. /** @hidden */
  64527. _data: Nullable<DataArray>;
  64528. private _updatable;
  64529. private _instanced;
  64530. /**
  64531. * Gets the byte stride.
  64532. */
  64533. readonly byteStride: number;
  64534. /**
  64535. * Constructor
  64536. * @param engine the engine
  64537. * @param data the data to use for this buffer
  64538. * @param updatable whether the data is updatable
  64539. * @param stride the stride (optional)
  64540. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64541. * @param instanced whether the buffer is instanced (optional)
  64542. * @param useBytes set to true if the stride in in bytes (optional)
  64543. */
  64544. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64545. /**
  64546. * Create a new VertexBuffer based on the current buffer
  64547. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64548. * @param offset defines offset in the buffer (0 by default)
  64549. * @param size defines the size in floats of attributes (position is 3 for instance)
  64550. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64551. * @param instanced defines if the vertex buffer contains indexed data
  64552. * @param useBytes defines if the offset and stride are in bytes
  64553. * @returns the new vertex buffer
  64554. */
  64555. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64556. /**
  64557. * Gets a boolean indicating if the Buffer is updatable?
  64558. * @returns true if the buffer is updatable
  64559. */
  64560. isUpdatable(): boolean;
  64561. /**
  64562. * Gets current buffer's data
  64563. * @returns a DataArray or null
  64564. */
  64565. getData(): Nullable<DataArray>;
  64566. /**
  64567. * Gets underlying native buffer
  64568. * @returns underlying native buffer
  64569. */
  64570. getBuffer(): Nullable<WebGLBuffer>;
  64571. /**
  64572. * Gets the stride in float32 units (i.e. byte stride / 4).
  64573. * May not be an integer if the byte stride is not divisible by 4.
  64574. * DEPRECATED. Use byteStride instead.
  64575. * @returns the stride in float32 units
  64576. */
  64577. getStrideSize(): number;
  64578. /**
  64579. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64580. * @param data defines the data to store
  64581. */
  64582. create(data?: Nullable<DataArray>): void;
  64583. /** @hidden */
  64584. _rebuild(): void;
  64585. /**
  64586. * Update current buffer data
  64587. * @param data defines the data to store
  64588. */
  64589. update(data: DataArray): void;
  64590. /**
  64591. * Updates the data directly.
  64592. * @param data the new data
  64593. * @param offset the new offset
  64594. * @param vertexCount the vertex count (optional)
  64595. * @param useBytes set to true if the offset is in bytes
  64596. */
  64597. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64598. /**
  64599. * Release all resources
  64600. */
  64601. dispose(): void;
  64602. }
  64603. /**
  64604. * Specialized buffer used to store vertex data
  64605. */
  64606. export class VertexBuffer {
  64607. /** @hidden */
  64608. _buffer: Buffer;
  64609. private _kind;
  64610. private _size;
  64611. private _ownsBuffer;
  64612. private _instanced;
  64613. private _instanceDivisor;
  64614. /**
  64615. * The byte type.
  64616. */
  64617. static readonly BYTE: number;
  64618. /**
  64619. * The unsigned byte type.
  64620. */
  64621. static readonly UNSIGNED_BYTE: number;
  64622. /**
  64623. * The short type.
  64624. */
  64625. static readonly SHORT: number;
  64626. /**
  64627. * The unsigned short type.
  64628. */
  64629. static readonly UNSIGNED_SHORT: number;
  64630. /**
  64631. * The integer type.
  64632. */
  64633. static readonly INT: number;
  64634. /**
  64635. * The unsigned integer type.
  64636. */
  64637. static readonly UNSIGNED_INT: number;
  64638. /**
  64639. * The float type.
  64640. */
  64641. static readonly FLOAT: number;
  64642. /**
  64643. * Gets or sets the instance divisor when in instanced mode
  64644. */
  64645. instanceDivisor: number;
  64646. /**
  64647. * Gets the byte stride.
  64648. */
  64649. readonly byteStride: number;
  64650. /**
  64651. * Gets the byte offset.
  64652. */
  64653. readonly byteOffset: number;
  64654. /**
  64655. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64656. */
  64657. readonly normalized: boolean;
  64658. /**
  64659. * Gets the data type of each component in the array.
  64660. */
  64661. readonly type: number;
  64662. /**
  64663. * Constructor
  64664. * @param engine the engine
  64665. * @param data the data to use for this vertex buffer
  64666. * @param kind the vertex buffer kind
  64667. * @param updatable whether the data is updatable
  64668. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64669. * @param stride the stride (optional)
  64670. * @param instanced whether the buffer is instanced (optional)
  64671. * @param offset the offset of the data (optional)
  64672. * @param size the number of components (optional)
  64673. * @param type the type of the component (optional)
  64674. * @param normalized whether the data contains normalized data (optional)
  64675. * @param useBytes set to true if stride and offset are in bytes (optional)
  64676. */
  64677. 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);
  64678. /** @hidden */
  64679. _rebuild(): void;
  64680. /**
  64681. * Returns the kind of the VertexBuffer (string)
  64682. * @returns a string
  64683. */
  64684. getKind(): string;
  64685. /**
  64686. * Gets a boolean indicating if the VertexBuffer is updatable?
  64687. * @returns true if the buffer is updatable
  64688. */
  64689. isUpdatable(): boolean;
  64690. /**
  64691. * Gets current buffer's data
  64692. * @returns a DataArray or null
  64693. */
  64694. getData(): Nullable<DataArray>;
  64695. /**
  64696. * Gets underlying native buffer
  64697. * @returns underlying native buffer
  64698. */
  64699. getBuffer(): Nullable<WebGLBuffer>;
  64700. /**
  64701. * Gets the stride in float32 units (i.e. byte stride / 4).
  64702. * May not be an integer if the byte stride is not divisible by 4.
  64703. * DEPRECATED. Use byteStride instead.
  64704. * @returns the stride in float32 units
  64705. */
  64706. getStrideSize(): number;
  64707. /**
  64708. * Returns the offset as a multiple of the type byte length.
  64709. * DEPRECATED. Use byteOffset instead.
  64710. * @returns the offset in bytes
  64711. */
  64712. getOffset(): number;
  64713. /**
  64714. * Returns the number of components per vertex attribute (integer)
  64715. * @returns the size in float
  64716. */
  64717. getSize(): number;
  64718. /**
  64719. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64720. * @returns true if this buffer is instanced
  64721. */
  64722. getIsInstanced(): boolean;
  64723. /**
  64724. * Returns the instancing divisor, zero for non-instanced (integer).
  64725. * @returns a number
  64726. */
  64727. getInstanceDivisor(): number;
  64728. /**
  64729. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64730. * @param data defines the data to store
  64731. */
  64732. create(data?: DataArray): void;
  64733. /**
  64734. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64735. * This function will create a new buffer if the current one is not updatable
  64736. * @param data defines the data to store
  64737. */
  64738. update(data: DataArray): void;
  64739. /**
  64740. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64741. * Returns the directly updated WebGLBuffer.
  64742. * @param data the new data
  64743. * @param offset the new offset
  64744. * @param useBytes set to true if the offset is in bytes
  64745. */
  64746. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64747. /**
  64748. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64749. */
  64750. dispose(): void;
  64751. /**
  64752. * Enumerates each value of this vertex buffer as numbers.
  64753. * @param count the number of values to enumerate
  64754. * @param callback the callback function called for each value
  64755. */
  64756. forEach(count: number, callback: (value: number, index: number) => void): void;
  64757. /**
  64758. * Positions
  64759. */
  64760. static readonly PositionKind: string;
  64761. /**
  64762. * Normals
  64763. */
  64764. static readonly NormalKind: string;
  64765. /**
  64766. * Tangents
  64767. */
  64768. static readonly TangentKind: string;
  64769. /**
  64770. * Texture coordinates
  64771. */
  64772. static readonly UVKind: string;
  64773. /**
  64774. * Texture coordinates 2
  64775. */
  64776. static readonly UV2Kind: string;
  64777. /**
  64778. * Texture coordinates 3
  64779. */
  64780. static readonly UV3Kind: string;
  64781. /**
  64782. * Texture coordinates 4
  64783. */
  64784. static readonly UV4Kind: string;
  64785. /**
  64786. * Texture coordinates 5
  64787. */
  64788. static readonly UV5Kind: string;
  64789. /**
  64790. * Texture coordinates 6
  64791. */
  64792. static readonly UV6Kind: string;
  64793. /**
  64794. * Colors
  64795. */
  64796. static readonly ColorKind: string;
  64797. /**
  64798. * Matrix indices (for bones)
  64799. */
  64800. static readonly MatricesIndicesKind: string;
  64801. /**
  64802. * Matrix weights (for bones)
  64803. */
  64804. static readonly MatricesWeightsKind: string;
  64805. /**
  64806. * Additional matrix indices (for bones)
  64807. */
  64808. static readonly MatricesIndicesExtraKind: string;
  64809. /**
  64810. * Additional matrix weights (for bones)
  64811. */
  64812. static readonly MatricesWeightsExtraKind: string;
  64813. /**
  64814. * Deduces the stride given a kind.
  64815. * @param kind The kind string to deduce
  64816. * @returns The deduced stride
  64817. */
  64818. static DeduceStride(kind: string): number;
  64819. /**
  64820. * Gets the byte length of the given type.
  64821. * @param type the type
  64822. * @returns the number of bytes
  64823. */
  64824. static GetTypeByteLength(type: number): number;
  64825. /**
  64826. * Enumerates each value of the given parameters as numbers.
  64827. * @param data the data to enumerate
  64828. * @param byteOffset the byte offset of the data
  64829. * @param byteStride the byte stride of the data
  64830. * @param componentCount the number of components per element
  64831. * @param componentType the type of the component
  64832. * @param count the total number of components
  64833. * @param normalized whether the data is normalized
  64834. * @param callback the callback function called for each value
  64835. */
  64836. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64837. private static _GetFloatValue;
  64838. }
  64839. }
  64840. declare module BABYLON {
  64841. /**
  64842. * Class representing spherical polynomial coefficients to the 3rd degree
  64843. */
  64844. export class SphericalPolynomial {
  64845. /**
  64846. * The x coefficients of the spherical polynomial
  64847. */
  64848. x: Vector3;
  64849. /**
  64850. * The y coefficients of the spherical polynomial
  64851. */
  64852. y: Vector3;
  64853. /**
  64854. * The z coefficients of the spherical polynomial
  64855. */
  64856. z: Vector3;
  64857. /**
  64858. * The xx coefficients of the spherical polynomial
  64859. */
  64860. xx: Vector3;
  64861. /**
  64862. * The yy coefficients of the spherical polynomial
  64863. */
  64864. yy: Vector3;
  64865. /**
  64866. * The zz coefficients of the spherical polynomial
  64867. */
  64868. zz: Vector3;
  64869. /**
  64870. * The xy coefficients of the spherical polynomial
  64871. */
  64872. xy: Vector3;
  64873. /**
  64874. * The yz coefficients of the spherical polynomial
  64875. */
  64876. yz: Vector3;
  64877. /**
  64878. * The zx coefficients of the spherical polynomial
  64879. */
  64880. zx: Vector3;
  64881. /**
  64882. * Adds an ambient color to the spherical polynomial
  64883. * @param color the color to add
  64884. */
  64885. addAmbient(color: Color3): void;
  64886. /**
  64887. * Scales the spherical polynomial by the given amount
  64888. * @param scale the amount to scale
  64889. */
  64890. scale(scale: number): void;
  64891. /**
  64892. * Gets the spherical polynomial from harmonics
  64893. * @param harmonics the spherical harmonics
  64894. * @returns the spherical polynomial
  64895. */
  64896. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  64897. /**
  64898. * Constructs a spherical polynomial from an array.
  64899. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  64900. * @returns the spherical polynomial
  64901. */
  64902. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  64903. }
  64904. /**
  64905. * Class representing spherical harmonics coefficients to the 3rd degree
  64906. */
  64907. export class SphericalHarmonics {
  64908. /**
  64909. * The l0,0 coefficients of the spherical harmonics
  64910. */
  64911. l00: Vector3;
  64912. /**
  64913. * The l1,-1 coefficients of the spherical harmonics
  64914. */
  64915. l1_1: Vector3;
  64916. /**
  64917. * The l1,0 coefficients of the spherical harmonics
  64918. */
  64919. l10: Vector3;
  64920. /**
  64921. * The l1,1 coefficients of the spherical harmonics
  64922. */
  64923. l11: Vector3;
  64924. /**
  64925. * The l2,-2 coefficients of the spherical harmonics
  64926. */
  64927. l2_2: Vector3;
  64928. /**
  64929. * The l2,-1 coefficients of the spherical harmonics
  64930. */
  64931. l2_1: Vector3;
  64932. /**
  64933. * The l2,0 coefficients of the spherical harmonics
  64934. */
  64935. l20: Vector3;
  64936. /**
  64937. * The l2,1 coefficients of the spherical harmonics
  64938. */
  64939. l21: Vector3;
  64940. /**
  64941. * The l2,2 coefficients of the spherical harmonics
  64942. */
  64943. lL22: Vector3;
  64944. /**
  64945. * Adds a light to the spherical harmonics
  64946. * @param direction the direction of the light
  64947. * @param color the color of the light
  64948. * @param deltaSolidAngle the delta solid angle of the light
  64949. */
  64950. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  64951. /**
  64952. * Scales the spherical harmonics by the given amount
  64953. * @param scale the amount to scale
  64954. */
  64955. scale(scale: number): void;
  64956. /**
  64957. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  64958. *
  64959. * ```
  64960. * E_lm = A_l * L_lm
  64961. * ```
  64962. *
  64963. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  64964. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  64965. * the scaling factors are given in equation 9.
  64966. */
  64967. convertIncidentRadianceToIrradiance(): void;
  64968. /**
  64969. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  64970. *
  64971. * ```
  64972. * L = (1/pi) * E * rho
  64973. * ```
  64974. *
  64975. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  64976. */
  64977. convertIrradianceToLambertianRadiance(): void;
  64978. /**
  64979. * Gets the spherical harmonics from polynomial
  64980. * @param polynomial the spherical polynomial
  64981. * @returns the spherical harmonics
  64982. */
  64983. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  64984. /**
  64985. * Constructs a spherical harmonics from an array.
  64986. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  64987. * @returns the spherical harmonics
  64988. */
  64989. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  64990. }
  64991. }
  64992. declare module BABYLON {
  64993. /**
  64994. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  64995. */
  64996. export interface CubeMapInfo {
  64997. /**
  64998. * The pixel array for the front face.
  64999. * This is stored in format, left to right, up to down format.
  65000. */
  65001. front: Nullable<ArrayBufferView>;
  65002. /**
  65003. * The pixel array for the back face.
  65004. * This is stored in format, left to right, up to down format.
  65005. */
  65006. back: Nullable<ArrayBufferView>;
  65007. /**
  65008. * The pixel array for the left face.
  65009. * This is stored in format, left to right, up to down format.
  65010. */
  65011. left: Nullable<ArrayBufferView>;
  65012. /**
  65013. * The pixel array for the right face.
  65014. * This is stored in format, left to right, up to down format.
  65015. */
  65016. right: Nullable<ArrayBufferView>;
  65017. /**
  65018. * The pixel array for the up face.
  65019. * This is stored in format, left to right, up to down format.
  65020. */
  65021. up: Nullable<ArrayBufferView>;
  65022. /**
  65023. * The pixel array for the down face.
  65024. * This is stored in format, left to right, up to down format.
  65025. */
  65026. down: Nullable<ArrayBufferView>;
  65027. /**
  65028. * The size of the cubemap stored.
  65029. *
  65030. * Each faces will be size * size pixels.
  65031. */
  65032. size: number;
  65033. /**
  65034. * The format of the texture.
  65035. *
  65036. * RGBA, RGB.
  65037. */
  65038. format: number;
  65039. /**
  65040. * The type of the texture data.
  65041. *
  65042. * UNSIGNED_INT, FLOAT.
  65043. */
  65044. type: number;
  65045. /**
  65046. * Specifies whether the texture is in gamma space.
  65047. */
  65048. gammaSpace: boolean;
  65049. }
  65050. /**
  65051. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65052. */
  65053. export class PanoramaToCubeMapTools {
  65054. private static FACE_FRONT;
  65055. private static FACE_BACK;
  65056. private static FACE_RIGHT;
  65057. private static FACE_LEFT;
  65058. private static FACE_DOWN;
  65059. private static FACE_UP;
  65060. /**
  65061. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65062. *
  65063. * @param float32Array The source data.
  65064. * @param inputWidth The width of the input panorama.
  65065. * @param inputHeight The height of the input panorama.
  65066. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65067. * @return The cubemap data
  65068. */
  65069. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65070. private static CreateCubemapTexture;
  65071. private static CalcProjectionSpherical;
  65072. }
  65073. }
  65074. declare module BABYLON {
  65075. /**
  65076. * Helper class dealing with the extraction of spherical polynomial dataArray
  65077. * from a cube map.
  65078. */
  65079. export class CubeMapToSphericalPolynomialTools {
  65080. private static FileFaces;
  65081. /**
  65082. * Converts a texture to the according Spherical Polynomial data.
  65083. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65084. *
  65085. * @param texture The texture to extract the information from.
  65086. * @return The Spherical Polynomial data.
  65087. */
  65088. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65089. /**
  65090. * Converts a cubemap to the according Spherical Polynomial data.
  65091. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65092. *
  65093. * @param cubeInfo The Cube map to extract the information from.
  65094. * @return The Spherical Polynomial data.
  65095. */
  65096. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65097. }
  65098. }
  65099. declare module BABYLON {
  65100. /**
  65101. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65102. * during the life time of the application.
  65103. */
  65104. export class EngineStore {
  65105. /** Gets the list of created engines */
  65106. static Instances: Engine[];
  65107. /**
  65108. * Gets the latest created engine
  65109. */
  65110. static readonly LastCreatedEngine: Nullable<Engine>;
  65111. /**
  65112. * Gets the latest created scene
  65113. */
  65114. static readonly LastCreatedScene: Nullable<Scene>;
  65115. }
  65116. }
  65117. declare module BABYLON {
  65118. /**
  65119. * Define options used to create a render target texture
  65120. */
  65121. export class RenderTargetCreationOptions {
  65122. /**
  65123. * Specifies is mipmaps must be generated
  65124. */
  65125. generateMipMaps?: boolean;
  65126. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65127. generateDepthBuffer?: boolean;
  65128. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65129. generateStencilBuffer?: boolean;
  65130. /** Defines texture type (int by default) */
  65131. type?: number;
  65132. /** Defines sampling mode (trilinear by default) */
  65133. samplingMode?: number;
  65134. /** Defines format (RGBA by default) */
  65135. format?: number;
  65136. }
  65137. }
  65138. declare module BABYLON {
  65139. /**
  65140. * @hidden
  65141. **/
  65142. export class _AlphaState {
  65143. private _isAlphaBlendDirty;
  65144. private _isBlendFunctionParametersDirty;
  65145. private _isBlendEquationParametersDirty;
  65146. private _isBlendConstantsDirty;
  65147. private _alphaBlend;
  65148. private _blendFunctionParameters;
  65149. private _blendEquationParameters;
  65150. private _blendConstants;
  65151. /**
  65152. * Initializes the state.
  65153. */
  65154. constructor();
  65155. readonly isDirty: boolean;
  65156. alphaBlend: boolean;
  65157. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65158. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65159. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65160. reset(): void;
  65161. apply(gl: WebGLRenderingContext): void;
  65162. }
  65163. }
  65164. declare module BABYLON {
  65165. /**
  65166. * @hidden
  65167. **/
  65168. export class _DepthCullingState {
  65169. private _isDepthTestDirty;
  65170. private _isDepthMaskDirty;
  65171. private _isDepthFuncDirty;
  65172. private _isCullFaceDirty;
  65173. private _isCullDirty;
  65174. private _isZOffsetDirty;
  65175. private _isFrontFaceDirty;
  65176. private _depthTest;
  65177. private _depthMask;
  65178. private _depthFunc;
  65179. private _cull;
  65180. private _cullFace;
  65181. private _zOffset;
  65182. private _frontFace;
  65183. /**
  65184. * Initializes the state.
  65185. */
  65186. constructor();
  65187. readonly isDirty: boolean;
  65188. zOffset: number;
  65189. cullFace: Nullable<number>;
  65190. cull: Nullable<boolean>;
  65191. depthFunc: Nullable<number>;
  65192. depthMask: boolean;
  65193. depthTest: boolean;
  65194. frontFace: Nullable<number>;
  65195. reset(): void;
  65196. apply(gl: WebGLRenderingContext): void;
  65197. }
  65198. }
  65199. declare module BABYLON {
  65200. /**
  65201. * @hidden
  65202. **/
  65203. export class _StencilState {
  65204. /** 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 */
  65205. static readonly ALWAYS: number;
  65206. /** Passed to stencilOperation to specify that stencil value must be kept */
  65207. static readonly KEEP: number;
  65208. /** Passed to stencilOperation to specify that stencil value must be replaced */
  65209. static readonly REPLACE: number;
  65210. private _isStencilTestDirty;
  65211. private _isStencilMaskDirty;
  65212. private _isStencilFuncDirty;
  65213. private _isStencilOpDirty;
  65214. private _stencilTest;
  65215. private _stencilMask;
  65216. private _stencilFunc;
  65217. private _stencilFuncRef;
  65218. private _stencilFuncMask;
  65219. private _stencilOpStencilFail;
  65220. private _stencilOpDepthFail;
  65221. private _stencilOpStencilDepthPass;
  65222. readonly isDirty: boolean;
  65223. stencilFunc: number;
  65224. stencilFuncRef: number;
  65225. stencilFuncMask: number;
  65226. stencilOpStencilFail: number;
  65227. stencilOpDepthFail: number;
  65228. stencilOpStencilDepthPass: number;
  65229. stencilMask: number;
  65230. stencilTest: boolean;
  65231. constructor();
  65232. reset(): void;
  65233. apply(gl: WebGLRenderingContext): void;
  65234. }
  65235. }
  65236. declare module BABYLON {
  65237. /**
  65238. * @hidden
  65239. **/
  65240. export class _TimeToken {
  65241. _startTimeQuery: Nullable<WebGLQuery>;
  65242. _endTimeQuery: Nullable<WebGLQuery>;
  65243. _timeElapsedQuery: Nullable<WebGLQuery>;
  65244. _timeElapsedQueryEnded: boolean;
  65245. }
  65246. }
  65247. declare module BABYLON {
  65248. /**
  65249. * Internal interface used to track InternalTexture already bound to the GL context
  65250. */
  65251. export interface IInternalTextureTracker {
  65252. /**
  65253. * Gets or set the previous tracker in the list
  65254. */
  65255. previous: Nullable<IInternalTextureTracker>;
  65256. /**
  65257. * Gets or set the next tracker in the list
  65258. */
  65259. next: Nullable<IInternalTextureTracker>;
  65260. }
  65261. /**
  65262. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  65263. */
  65264. export class DummyInternalTextureTracker {
  65265. /**
  65266. * Gets or set the previous tracker in the list
  65267. */
  65268. previous: Nullable<IInternalTextureTracker>;
  65269. /**
  65270. * Gets or set the next tracker in the list
  65271. */
  65272. next: Nullable<IInternalTextureTracker>;
  65273. }
  65274. }
  65275. declare module BABYLON {
  65276. /**
  65277. * Class used to store data associated with WebGL texture data for the engine
  65278. * This class should not be used directly
  65279. */
  65280. export class InternalTexture implements IInternalTextureTracker {
  65281. /** hidden */
  65282. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  65283. /**
  65284. * The source of the texture data is unknown
  65285. */
  65286. static DATASOURCE_UNKNOWN: number;
  65287. /**
  65288. * Texture data comes from an URL
  65289. */
  65290. static DATASOURCE_URL: number;
  65291. /**
  65292. * Texture data is only used for temporary storage
  65293. */
  65294. static DATASOURCE_TEMP: number;
  65295. /**
  65296. * Texture data comes from raw data (ArrayBuffer)
  65297. */
  65298. static DATASOURCE_RAW: number;
  65299. /**
  65300. * Texture content is dynamic (video or dynamic texture)
  65301. */
  65302. static DATASOURCE_DYNAMIC: number;
  65303. /**
  65304. * Texture content is generated by rendering to it
  65305. */
  65306. static DATASOURCE_RENDERTARGET: number;
  65307. /**
  65308. * Texture content is part of a multi render target process
  65309. */
  65310. static DATASOURCE_MULTIRENDERTARGET: number;
  65311. /**
  65312. * Texture data comes from a cube data file
  65313. */
  65314. static DATASOURCE_CUBE: number;
  65315. /**
  65316. * Texture data comes from a raw cube data
  65317. */
  65318. static DATASOURCE_CUBERAW: number;
  65319. /**
  65320. * Texture data come from a prefiltered cube data file
  65321. */
  65322. static DATASOURCE_CUBEPREFILTERED: number;
  65323. /**
  65324. * Texture content is raw 3D data
  65325. */
  65326. static DATASOURCE_RAW3D: number;
  65327. /**
  65328. * Texture content is a depth texture
  65329. */
  65330. static DATASOURCE_DEPTHTEXTURE: number;
  65331. /**
  65332. * Texture data comes from a raw cube data encoded with RGBD
  65333. */
  65334. static DATASOURCE_CUBERAW_RGBD: number;
  65335. /**
  65336. * Defines if the texture is ready
  65337. */
  65338. isReady: boolean;
  65339. /**
  65340. * Defines if the texture is a cube texture
  65341. */
  65342. isCube: boolean;
  65343. /**
  65344. * Defines if the texture contains 3D data
  65345. */
  65346. is3D: boolean;
  65347. /**
  65348. * Defines if the texture contains multiview data
  65349. */
  65350. isMultiview: boolean;
  65351. /**
  65352. * Gets the URL used to load this texture
  65353. */
  65354. url: string;
  65355. /**
  65356. * Gets the sampling mode of the texture
  65357. */
  65358. samplingMode: number;
  65359. /**
  65360. * Gets a boolean indicating if the texture needs mipmaps generation
  65361. */
  65362. generateMipMaps: boolean;
  65363. /**
  65364. * Gets the number of samples used by the texture (WebGL2+ only)
  65365. */
  65366. samples: number;
  65367. /**
  65368. * Gets the type of the texture (int, float...)
  65369. */
  65370. type: number;
  65371. /**
  65372. * Gets the format of the texture (RGB, RGBA...)
  65373. */
  65374. format: number;
  65375. /**
  65376. * Observable called when the texture is loaded
  65377. */
  65378. onLoadedObservable: Observable<InternalTexture>;
  65379. /**
  65380. * Gets the width of the texture
  65381. */
  65382. width: number;
  65383. /**
  65384. * Gets the height of the texture
  65385. */
  65386. height: number;
  65387. /**
  65388. * Gets the depth of the texture
  65389. */
  65390. depth: number;
  65391. /**
  65392. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  65393. */
  65394. baseWidth: number;
  65395. /**
  65396. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  65397. */
  65398. baseHeight: number;
  65399. /**
  65400. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  65401. */
  65402. baseDepth: number;
  65403. /**
  65404. * Gets a boolean indicating if the texture is inverted on Y axis
  65405. */
  65406. invertY: boolean;
  65407. /**
  65408. * Gets or set the previous tracker in the list
  65409. */
  65410. previous: Nullable<IInternalTextureTracker>;
  65411. /**
  65412. * Gets or set the next tracker in the list
  65413. */
  65414. next: Nullable<IInternalTextureTracker>;
  65415. /** @hidden */
  65416. _invertVScale: boolean;
  65417. /** @hidden */
  65418. _initialSlot: number;
  65419. /** @hidden */
  65420. _designatedSlot: number;
  65421. /** @hidden */
  65422. _dataSource: number;
  65423. /** @hidden */
  65424. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  65425. /** @hidden */
  65426. _bufferView: Nullable<ArrayBufferView>;
  65427. /** @hidden */
  65428. _bufferViewArray: Nullable<ArrayBufferView[]>;
  65429. /** @hidden */
  65430. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  65431. /** @hidden */
  65432. _size: number;
  65433. /** @hidden */
  65434. _extension: string;
  65435. /** @hidden */
  65436. _files: Nullable<string[]>;
  65437. /** @hidden */
  65438. _workingCanvas: HTMLCanvasElement;
  65439. /** @hidden */
  65440. _workingContext: CanvasRenderingContext2D;
  65441. /** @hidden */
  65442. _framebuffer: Nullable<WebGLFramebuffer>;
  65443. /** @hidden */
  65444. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  65445. /** @hidden */
  65446. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  65447. /** @hidden */
  65448. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  65449. /** @hidden */
  65450. _attachments: Nullable<number[]>;
  65451. /** @hidden */
  65452. _cachedCoordinatesMode: Nullable<number>;
  65453. /** @hidden */
  65454. _cachedWrapU: Nullable<number>;
  65455. /** @hidden */
  65456. _cachedWrapV: Nullable<number>;
  65457. /** @hidden */
  65458. _cachedWrapR: Nullable<number>;
  65459. /** @hidden */
  65460. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65461. /** @hidden */
  65462. _isDisabled: boolean;
  65463. /** @hidden */
  65464. _compression: Nullable<string>;
  65465. /** @hidden */
  65466. _generateStencilBuffer: boolean;
  65467. /** @hidden */
  65468. _generateDepthBuffer: boolean;
  65469. /** @hidden */
  65470. _comparisonFunction: number;
  65471. /** @hidden */
  65472. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  65473. /** @hidden */
  65474. _lodGenerationScale: number;
  65475. /** @hidden */
  65476. _lodGenerationOffset: number;
  65477. /** @hidden */
  65478. _colorTextureArray: Nullable<WebGLTexture>;
  65479. /** @hidden */
  65480. _depthStencilTextureArray: Nullable<WebGLTexture>;
  65481. /** @hidden */
  65482. _lodTextureHigh: BaseTexture;
  65483. /** @hidden */
  65484. _lodTextureMid: BaseTexture;
  65485. /** @hidden */
  65486. _lodTextureLow: BaseTexture;
  65487. /** @hidden */
  65488. _isRGBD: boolean;
  65489. /** @hidden */
  65490. _webGLTexture: Nullable<WebGLTexture>;
  65491. /** @hidden */
  65492. _references: number;
  65493. private _engine;
  65494. /**
  65495. * Gets the Engine the texture belongs to.
  65496. * @returns The babylon engine
  65497. */
  65498. getEngine(): Engine;
  65499. /**
  65500. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  65501. */
  65502. readonly dataSource: number;
  65503. /**
  65504. * Creates a new InternalTexture
  65505. * @param engine defines the engine to use
  65506. * @param dataSource defines the type of data that will be used
  65507. * @param delayAllocation if the texture allocation should be delayed (default: false)
  65508. */
  65509. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  65510. /**
  65511. * Increments the number of references (ie. the number of Texture that point to it)
  65512. */
  65513. incrementReferences(): void;
  65514. /**
  65515. * Change the size of the texture (not the size of the content)
  65516. * @param width defines the new width
  65517. * @param height defines the new height
  65518. * @param depth defines the new depth (1 by default)
  65519. */
  65520. updateSize(width: int, height: int, depth?: int): void;
  65521. /** @hidden */
  65522. _rebuild(): void;
  65523. /** @hidden */
  65524. _swapAndDie(target: InternalTexture): void;
  65525. /**
  65526. * Dispose the current allocated resources
  65527. */
  65528. dispose(): void;
  65529. }
  65530. }
  65531. declare module BABYLON {
  65532. /**
  65533. * This represents the main contract an easing function should follow.
  65534. * Easing functions are used throughout the animation system.
  65535. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65536. */
  65537. export interface IEasingFunction {
  65538. /**
  65539. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65540. * of the easing function.
  65541. * The link below provides some of the most common examples of easing functions.
  65542. * @see https://easings.net/
  65543. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65544. * @returns the corresponding value on the curve defined by the easing function
  65545. */
  65546. ease(gradient: number): number;
  65547. }
  65548. /**
  65549. * Base class used for every default easing function.
  65550. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65551. */
  65552. export class EasingFunction implements IEasingFunction {
  65553. /**
  65554. * Interpolation follows the mathematical formula associated with the easing function.
  65555. */
  65556. static readonly EASINGMODE_EASEIN: number;
  65557. /**
  65558. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  65559. */
  65560. static readonly EASINGMODE_EASEOUT: number;
  65561. /**
  65562. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  65563. */
  65564. static readonly EASINGMODE_EASEINOUT: number;
  65565. private _easingMode;
  65566. /**
  65567. * Sets the easing mode of the current function.
  65568. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  65569. */
  65570. setEasingMode(easingMode: number): void;
  65571. /**
  65572. * Gets the current easing mode.
  65573. * @returns the easing mode
  65574. */
  65575. getEasingMode(): number;
  65576. /**
  65577. * @hidden
  65578. */
  65579. easeInCore(gradient: number): number;
  65580. /**
  65581. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65582. * of the easing function.
  65583. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65584. * @returns the corresponding value on the curve defined by the easing function
  65585. */
  65586. ease(gradient: number): number;
  65587. }
  65588. /**
  65589. * Easing function with a circle shape (see link below).
  65590. * @see https://easings.net/#easeInCirc
  65591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65592. */
  65593. export class CircleEase extends EasingFunction implements IEasingFunction {
  65594. /** @hidden */
  65595. easeInCore(gradient: number): number;
  65596. }
  65597. /**
  65598. * Easing function with a ease back shape (see link below).
  65599. * @see https://easings.net/#easeInBack
  65600. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65601. */
  65602. export class BackEase extends EasingFunction implements IEasingFunction {
  65603. /** Defines the amplitude of the function */
  65604. amplitude: number;
  65605. /**
  65606. * Instantiates a back ease easing
  65607. * @see https://easings.net/#easeInBack
  65608. * @param amplitude Defines the amplitude of the function
  65609. */
  65610. constructor(
  65611. /** Defines the amplitude of the function */
  65612. amplitude?: number);
  65613. /** @hidden */
  65614. easeInCore(gradient: number): number;
  65615. }
  65616. /**
  65617. * Easing function with a bouncing shape (see link below).
  65618. * @see https://easings.net/#easeInBounce
  65619. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65620. */
  65621. export class BounceEase extends EasingFunction implements IEasingFunction {
  65622. /** Defines the number of bounces */
  65623. bounces: number;
  65624. /** Defines the amplitude of the bounce */
  65625. bounciness: number;
  65626. /**
  65627. * Instantiates a bounce easing
  65628. * @see https://easings.net/#easeInBounce
  65629. * @param bounces Defines the number of bounces
  65630. * @param bounciness Defines the amplitude of the bounce
  65631. */
  65632. constructor(
  65633. /** Defines the number of bounces */
  65634. bounces?: number,
  65635. /** Defines the amplitude of the bounce */
  65636. bounciness?: number);
  65637. /** @hidden */
  65638. easeInCore(gradient: number): number;
  65639. }
  65640. /**
  65641. * Easing function with a power of 3 shape (see link below).
  65642. * @see https://easings.net/#easeInCubic
  65643. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65644. */
  65645. export class CubicEase extends EasingFunction implements IEasingFunction {
  65646. /** @hidden */
  65647. easeInCore(gradient: number): number;
  65648. }
  65649. /**
  65650. * Easing function with an elastic shape (see link below).
  65651. * @see https://easings.net/#easeInElastic
  65652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65653. */
  65654. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65655. /** Defines the number of oscillations*/
  65656. oscillations: number;
  65657. /** Defines the amplitude of the oscillations*/
  65658. springiness: number;
  65659. /**
  65660. * Instantiates an elastic easing function
  65661. * @see https://easings.net/#easeInElastic
  65662. * @param oscillations Defines the number of oscillations
  65663. * @param springiness Defines the amplitude of the oscillations
  65664. */
  65665. constructor(
  65666. /** Defines the number of oscillations*/
  65667. oscillations?: number,
  65668. /** Defines the amplitude of the oscillations*/
  65669. springiness?: number);
  65670. /** @hidden */
  65671. easeInCore(gradient: number): number;
  65672. }
  65673. /**
  65674. * Easing function with an exponential shape (see link below).
  65675. * @see https://easings.net/#easeInExpo
  65676. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65677. */
  65678. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65679. /** Defines the exponent of the function */
  65680. exponent: number;
  65681. /**
  65682. * Instantiates an exponential easing function
  65683. * @see https://easings.net/#easeInExpo
  65684. * @param exponent Defines the exponent of the function
  65685. */
  65686. constructor(
  65687. /** Defines the exponent of the function */
  65688. exponent?: number);
  65689. /** @hidden */
  65690. easeInCore(gradient: number): number;
  65691. }
  65692. /**
  65693. * Easing function with a power shape (see link below).
  65694. * @see https://easings.net/#easeInQuad
  65695. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65696. */
  65697. export class PowerEase extends EasingFunction implements IEasingFunction {
  65698. /** Defines the power of the function */
  65699. power: number;
  65700. /**
  65701. * Instantiates an power base easing function
  65702. * @see https://easings.net/#easeInQuad
  65703. * @param power Defines the power of the function
  65704. */
  65705. constructor(
  65706. /** Defines the power of the function */
  65707. power?: number);
  65708. /** @hidden */
  65709. easeInCore(gradient: number): number;
  65710. }
  65711. /**
  65712. * Easing function with a power of 2 shape (see link below).
  65713. * @see https://easings.net/#easeInQuad
  65714. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65715. */
  65716. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  65717. /** @hidden */
  65718. easeInCore(gradient: number): number;
  65719. }
  65720. /**
  65721. * Easing function with a power of 4 shape (see link below).
  65722. * @see https://easings.net/#easeInQuart
  65723. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65724. */
  65725. export class QuarticEase extends EasingFunction implements IEasingFunction {
  65726. /** @hidden */
  65727. easeInCore(gradient: number): number;
  65728. }
  65729. /**
  65730. * Easing function with a power of 5 shape (see link below).
  65731. * @see https://easings.net/#easeInQuint
  65732. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65733. */
  65734. export class QuinticEase extends EasingFunction implements IEasingFunction {
  65735. /** @hidden */
  65736. easeInCore(gradient: number): number;
  65737. }
  65738. /**
  65739. * Easing function with a sin shape (see link below).
  65740. * @see https://easings.net/#easeInSine
  65741. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65742. */
  65743. export class SineEase extends EasingFunction implements IEasingFunction {
  65744. /** @hidden */
  65745. easeInCore(gradient: number): number;
  65746. }
  65747. /**
  65748. * Easing function with a bezier shape (see link below).
  65749. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65750. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65751. */
  65752. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  65753. /** Defines the x component of the start tangent in the bezier curve */
  65754. x1: number;
  65755. /** Defines the y component of the start tangent in the bezier curve */
  65756. y1: number;
  65757. /** Defines the x component of the end tangent in the bezier curve */
  65758. x2: number;
  65759. /** Defines the y component of the end tangent in the bezier curve */
  65760. y2: number;
  65761. /**
  65762. * Instantiates a bezier function
  65763. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65764. * @param x1 Defines the x component of the start tangent in the bezier curve
  65765. * @param y1 Defines the y component of the start tangent in the bezier curve
  65766. * @param x2 Defines the x component of the end tangent in the bezier curve
  65767. * @param y2 Defines the y component of the end tangent in the bezier curve
  65768. */
  65769. constructor(
  65770. /** Defines the x component of the start tangent in the bezier curve */
  65771. x1?: number,
  65772. /** Defines the y component of the start tangent in the bezier curve */
  65773. y1?: number,
  65774. /** Defines the x component of the end tangent in the bezier curve */
  65775. x2?: number,
  65776. /** Defines the y component of the end tangent in the bezier curve */
  65777. y2?: number);
  65778. /** @hidden */
  65779. easeInCore(gradient: number): number;
  65780. }
  65781. }
  65782. declare module BABYLON {
  65783. /**
  65784. * Defines an interface which represents an animation key frame
  65785. */
  65786. export interface IAnimationKey {
  65787. /**
  65788. * Frame of the key frame
  65789. */
  65790. frame: number;
  65791. /**
  65792. * Value at the specifies key frame
  65793. */
  65794. value: any;
  65795. /**
  65796. * The input tangent for the cubic hermite spline
  65797. */
  65798. inTangent?: any;
  65799. /**
  65800. * The output tangent for the cubic hermite spline
  65801. */
  65802. outTangent?: any;
  65803. /**
  65804. * The animation interpolation type
  65805. */
  65806. interpolation?: AnimationKeyInterpolation;
  65807. }
  65808. /**
  65809. * Enum for the animation key frame interpolation type
  65810. */
  65811. export enum AnimationKeyInterpolation {
  65812. /**
  65813. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  65814. */
  65815. STEP = 1
  65816. }
  65817. }
  65818. declare module BABYLON {
  65819. /**
  65820. * Represents the range of an animation
  65821. */
  65822. export class AnimationRange {
  65823. /**The name of the animation range**/
  65824. name: string;
  65825. /**The starting frame of the animation */
  65826. from: number;
  65827. /**The ending frame of the animation*/
  65828. to: number;
  65829. /**
  65830. * Initializes the range of an animation
  65831. * @param name The name of the animation range
  65832. * @param from The starting frame of the animation
  65833. * @param to The ending frame of the animation
  65834. */
  65835. constructor(
  65836. /**The name of the animation range**/
  65837. name: string,
  65838. /**The starting frame of the animation */
  65839. from: number,
  65840. /**The ending frame of the animation*/
  65841. to: number);
  65842. /**
  65843. * Makes a copy of the animation range
  65844. * @returns A copy of the animation range
  65845. */
  65846. clone(): AnimationRange;
  65847. }
  65848. }
  65849. declare module BABYLON {
  65850. /**
  65851. * Composed of a frame, and an action function
  65852. */
  65853. export class AnimationEvent {
  65854. /** The frame for which the event is triggered **/
  65855. frame: number;
  65856. /** The event to perform when triggered **/
  65857. action: (currentFrame: number) => void;
  65858. /** Specifies if the event should be triggered only once**/
  65859. onlyOnce?: boolean | undefined;
  65860. /**
  65861. * Specifies if the animation event is done
  65862. */
  65863. isDone: boolean;
  65864. /**
  65865. * Initializes the animation event
  65866. * @param frame The frame for which the event is triggered
  65867. * @param action The event to perform when triggered
  65868. * @param onlyOnce Specifies if the event should be triggered only once
  65869. */
  65870. constructor(
  65871. /** The frame for which the event is triggered **/
  65872. frame: number,
  65873. /** The event to perform when triggered **/
  65874. action: (currentFrame: number) => void,
  65875. /** Specifies if the event should be triggered only once**/
  65876. onlyOnce?: boolean | undefined);
  65877. /** @hidden */
  65878. _clone(): AnimationEvent;
  65879. }
  65880. }
  65881. declare module BABYLON {
  65882. /**
  65883. * Interface used to define a behavior
  65884. */
  65885. export interface Behavior<T> {
  65886. /** gets or sets behavior's name */
  65887. name: string;
  65888. /**
  65889. * Function called when the behavior needs to be initialized (after attaching it to a target)
  65890. */
  65891. init(): void;
  65892. /**
  65893. * Called when the behavior is attached to a target
  65894. * @param target defines the target where the behavior is attached to
  65895. */
  65896. attach(target: T): void;
  65897. /**
  65898. * Called when the behavior is detached from its target
  65899. */
  65900. detach(): void;
  65901. }
  65902. /**
  65903. * Interface implemented by classes supporting behaviors
  65904. */
  65905. export interface IBehaviorAware<T> {
  65906. /**
  65907. * Attach a behavior
  65908. * @param behavior defines the behavior to attach
  65909. * @returns the current host
  65910. */
  65911. addBehavior(behavior: Behavior<T>): T;
  65912. /**
  65913. * Remove a behavior from the current object
  65914. * @param behavior defines the behavior to detach
  65915. * @returns the current host
  65916. */
  65917. removeBehavior(behavior: Behavior<T>): T;
  65918. /**
  65919. * Gets a behavior using its name to search
  65920. * @param name defines the name to search
  65921. * @returns the behavior or null if not found
  65922. */
  65923. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  65924. }
  65925. }
  65926. declare module BABYLON {
  65927. /**
  65928. * @hidden
  65929. */
  65930. export class IntersectionInfo {
  65931. bu: Nullable<number>;
  65932. bv: Nullable<number>;
  65933. distance: number;
  65934. faceId: number;
  65935. subMeshId: number;
  65936. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  65937. }
  65938. }
  65939. declare module BABYLON {
  65940. /**
  65941. * Class used to store bounding sphere information
  65942. */
  65943. export class BoundingSphere {
  65944. /**
  65945. * Gets the center of the bounding sphere in local space
  65946. */
  65947. readonly center: Vector3;
  65948. /**
  65949. * Radius of the bounding sphere in local space
  65950. */
  65951. radius: number;
  65952. /**
  65953. * Gets the center of the bounding sphere in world space
  65954. */
  65955. readonly centerWorld: Vector3;
  65956. /**
  65957. * Radius of the bounding sphere in world space
  65958. */
  65959. radiusWorld: number;
  65960. /**
  65961. * Gets the minimum vector in local space
  65962. */
  65963. readonly minimum: Vector3;
  65964. /**
  65965. * Gets the maximum vector in local space
  65966. */
  65967. readonly maximum: Vector3;
  65968. private _worldMatrix;
  65969. private static readonly TmpVector3;
  65970. /**
  65971. * Creates a new bounding sphere
  65972. * @param min defines the minimum vector (in local space)
  65973. * @param max defines the maximum vector (in local space)
  65974. * @param worldMatrix defines the new world matrix
  65975. */
  65976. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65977. /**
  65978. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  65979. * @param min defines the new minimum vector (in local space)
  65980. * @param max defines the new maximum vector (in local space)
  65981. * @param worldMatrix defines the new world matrix
  65982. */
  65983. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65984. /**
  65985. * Scale the current bounding sphere by applying a scale factor
  65986. * @param factor defines the scale factor to apply
  65987. * @returns the current bounding box
  65988. */
  65989. scale(factor: number): BoundingSphere;
  65990. /**
  65991. * Gets the world matrix of the bounding box
  65992. * @returns a matrix
  65993. */
  65994. getWorldMatrix(): DeepImmutable<Matrix>;
  65995. /** @hidden */
  65996. _update(worldMatrix: DeepImmutable<Matrix>): void;
  65997. /**
  65998. * Tests if the bounding sphere is intersecting the frustum planes
  65999. * @param frustumPlanes defines the frustum planes to test
  66000. * @returns true if there is an intersection
  66001. */
  66002. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66003. /**
  66004. * Tests if the bounding sphere center is in between the frustum planes.
  66005. * Used for optimistic fast inclusion.
  66006. * @param frustumPlanes defines the frustum planes to test
  66007. * @returns true if the sphere center is in between the frustum planes
  66008. */
  66009. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66010. /**
  66011. * Tests if a point is inside the bounding sphere
  66012. * @param point defines the point to test
  66013. * @returns true if the point is inside the bounding sphere
  66014. */
  66015. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66016. /**
  66017. * Checks if two sphere intersct
  66018. * @param sphere0 sphere 0
  66019. * @param sphere1 sphere 1
  66020. * @returns true if the speres intersect
  66021. */
  66022. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66023. }
  66024. }
  66025. declare module BABYLON {
  66026. /**
  66027. * Class used to store bounding box information
  66028. */
  66029. export class BoundingBox implements ICullable {
  66030. /**
  66031. * Gets the 8 vectors representing the bounding box in local space
  66032. */
  66033. readonly vectors: Vector3[];
  66034. /**
  66035. * Gets the center of the bounding box in local space
  66036. */
  66037. readonly center: Vector3;
  66038. /**
  66039. * Gets the center of the bounding box in world space
  66040. */
  66041. readonly centerWorld: Vector3;
  66042. /**
  66043. * Gets the extend size in local space
  66044. */
  66045. readonly extendSize: Vector3;
  66046. /**
  66047. * Gets the extend size in world space
  66048. */
  66049. readonly extendSizeWorld: Vector3;
  66050. /**
  66051. * Gets the OBB (object bounding box) directions
  66052. */
  66053. readonly directions: Vector3[];
  66054. /**
  66055. * Gets the 8 vectors representing the bounding box in world space
  66056. */
  66057. readonly vectorsWorld: Vector3[];
  66058. /**
  66059. * Gets the minimum vector in world space
  66060. */
  66061. readonly minimumWorld: Vector3;
  66062. /**
  66063. * Gets the maximum vector in world space
  66064. */
  66065. readonly maximumWorld: Vector3;
  66066. /**
  66067. * Gets the minimum vector in local space
  66068. */
  66069. readonly minimum: Vector3;
  66070. /**
  66071. * Gets the maximum vector in local space
  66072. */
  66073. readonly maximum: Vector3;
  66074. private _worldMatrix;
  66075. private static readonly TmpVector3;
  66076. /**
  66077. * @hidden
  66078. */
  66079. _tag: number;
  66080. /**
  66081. * Creates a new bounding box
  66082. * @param min defines the minimum vector (in local space)
  66083. * @param max defines the maximum vector (in local space)
  66084. * @param worldMatrix defines the new world matrix
  66085. */
  66086. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66087. /**
  66088. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66089. * @param min defines the new minimum vector (in local space)
  66090. * @param max defines the new maximum vector (in local space)
  66091. * @param worldMatrix defines the new world matrix
  66092. */
  66093. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66094. /**
  66095. * Scale the current bounding box by applying a scale factor
  66096. * @param factor defines the scale factor to apply
  66097. * @returns the current bounding box
  66098. */
  66099. scale(factor: number): BoundingBox;
  66100. /**
  66101. * Gets the world matrix of the bounding box
  66102. * @returns a matrix
  66103. */
  66104. getWorldMatrix(): DeepImmutable<Matrix>;
  66105. /** @hidden */
  66106. _update(world: DeepImmutable<Matrix>): void;
  66107. /**
  66108. * Tests if the bounding box is intersecting the frustum planes
  66109. * @param frustumPlanes defines the frustum planes to test
  66110. * @returns true if there is an intersection
  66111. */
  66112. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66113. /**
  66114. * Tests if the bounding box is entirely inside the frustum planes
  66115. * @param frustumPlanes defines the frustum planes to test
  66116. * @returns true if there is an inclusion
  66117. */
  66118. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66119. /**
  66120. * Tests if a point is inside the bounding box
  66121. * @param point defines the point to test
  66122. * @returns true if the point is inside the bounding box
  66123. */
  66124. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66125. /**
  66126. * Tests if the bounding box intersects with a bounding sphere
  66127. * @param sphere defines the sphere to test
  66128. * @returns true if there is an intersection
  66129. */
  66130. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66131. /**
  66132. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66133. * @param min defines the min vector to use
  66134. * @param max defines the max vector to use
  66135. * @returns true if there is an intersection
  66136. */
  66137. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66138. /**
  66139. * Tests if two bounding boxes are intersections
  66140. * @param box0 defines the first box to test
  66141. * @param box1 defines the second box to test
  66142. * @returns true if there is an intersection
  66143. */
  66144. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66145. /**
  66146. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66147. * @param minPoint defines the minimum vector of the bounding box
  66148. * @param maxPoint defines the maximum vector of the bounding box
  66149. * @param sphereCenter defines the sphere center
  66150. * @param sphereRadius defines the sphere radius
  66151. * @returns true if there is an intersection
  66152. */
  66153. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66154. /**
  66155. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66156. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66157. * @param frustumPlanes defines the frustum planes to test
  66158. * @return true if there is an inclusion
  66159. */
  66160. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66161. /**
  66162. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66163. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66164. * @param frustumPlanes defines the frustum planes to test
  66165. * @return true if there is an intersection
  66166. */
  66167. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66168. }
  66169. }
  66170. declare module BABYLON {
  66171. /** @hidden */
  66172. export class Collider {
  66173. /** Define if a collision was found */
  66174. collisionFound: boolean;
  66175. /**
  66176. * Define last intersection point in local space
  66177. */
  66178. intersectionPoint: Vector3;
  66179. /**
  66180. * Define last collided mesh
  66181. */
  66182. collidedMesh: Nullable<AbstractMesh>;
  66183. private _collisionPoint;
  66184. private _planeIntersectionPoint;
  66185. private _tempVector;
  66186. private _tempVector2;
  66187. private _tempVector3;
  66188. private _tempVector4;
  66189. private _edge;
  66190. private _baseToVertex;
  66191. private _destinationPoint;
  66192. private _slidePlaneNormal;
  66193. private _displacementVector;
  66194. /** @hidden */
  66195. _radius: Vector3;
  66196. /** @hidden */
  66197. _retry: number;
  66198. private _velocity;
  66199. private _basePoint;
  66200. private _epsilon;
  66201. /** @hidden */
  66202. _velocityWorldLength: number;
  66203. /** @hidden */
  66204. _basePointWorld: Vector3;
  66205. private _velocityWorld;
  66206. private _normalizedVelocity;
  66207. /** @hidden */
  66208. _initialVelocity: Vector3;
  66209. /** @hidden */
  66210. _initialPosition: Vector3;
  66211. private _nearestDistance;
  66212. private _collisionMask;
  66213. collisionMask: number;
  66214. /**
  66215. * Gets the plane normal used to compute the sliding response (in local space)
  66216. */
  66217. readonly slidePlaneNormal: Vector3;
  66218. /** @hidden */
  66219. _initialize(source: Vector3, dir: Vector3, e: number): void;
  66220. /** @hidden */
  66221. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  66222. /** @hidden */
  66223. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  66224. /** @hidden */
  66225. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  66226. /** @hidden */
  66227. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  66228. /** @hidden */
  66229. _getResponse(pos: Vector3, vel: Vector3): void;
  66230. }
  66231. }
  66232. declare module BABYLON {
  66233. /**
  66234. * Interface for cullable objects
  66235. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  66236. */
  66237. export interface ICullable {
  66238. /**
  66239. * Checks if the object or part of the object is in the frustum
  66240. * @param frustumPlanes Camera near/planes
  66241. * @returns true if the object is in frustum otherwise false
  66242. */
  66243. isInFrustum(frustumPlanes: Plane[]): boolean;
  66244. /**
  66245. * Checks if a cullable object (mesh...) is in the camera frustum
  66246. * Unlike isInFrustum this cheks the full bounding box
  66247. * @param frustumPlanes Camera near/planes
  66248. * @returns true if the object is in frustum otherwise false
  66249. */
  66250. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  66251. }
  66252. /**
  66253. * Info for a bounding data of a mesh
  66254. */
  66255. export class BoundingInfo implements ICullable {
  66256. /**
  66257. * Bounding box for the mesh
  66258. */
  66259. readonly boundingBox: BoundingBox;
  66260. /**
  66261. * Bounding sphere for the mesh
  66262. */
  66263. readonly boundingSphere: BoundingSphere;
  66264. private _isLocked;
  66265. private static readonly TmpVector3;
  66266. /**
  66267. * Constructs bounding info
  66268. * @param minimum min vector of the bounding box/sphere
  66269. * @param maximum max vector of the bounding box/sphere
  66270. * @param worldMatrix defines the new world matrix
  66271. */
  66272. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66273. /**
  66274. * Recreates the entire bounding info from scratch as if we call the constructor in place
  66275. * @param min defines the new minimum vector (in local space)
  66276. * @param max defines the new maximum vector (in local space)
  66277. * @param worldMatrix defines the new world matrix
  66278. */
  66279. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66280. /**
  66281. * min vector of the bounding box/sphere
  66282. */
  66283. readonly minimum: Vector3;
  66284. /**
  66285. * max vector of the bounding box/sphere
  66286. */
  66287. readonly maximum: Vector3;
  66288. /**
  66289. * If the info is locked and won't be updated to avoid perf overhead
  66290. */
  66291. isLocked: boolean;
  66292. /**
  66293. * Updates the bounding sphere and box
  66294. * @param world world matrix to be used to update
  66295. */
  66296. update(world: DeepImmutable<Matrix>): void;
  66297. /**
  66298. * Recreate the bounding info to be centered around a specific point given a specific extend.
  66299. * @param center New center of the bounding info
  66300. * @param extend New extend of the bounding info
  66301. * @returns the current bounding info
  66302. */
  66303. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  66304. /**
  66305. * Scale the current bounding info by applying a scale factor
  66306. * @param factor defines the scale factor to apply
  66307. * @returns the current bounding info
  66308. */
  66309. scale(factor: number): BoundingInfo;
  66310. /**
  66311. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  66312. * @param frustumPlanes defines the frustum to test
  66313. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  66314. * @returns true if the bounding info is in the frustum planes
  66315. */
  66316. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  66317. /**
  66318. * Gets the world distance between the min and max points of the bounding box
  66319. */
  66320. readonly diagonalLength: number;
  66321. /**
  66322. * Checks if a cullable object (mesh...) is in the camera frustum
  66323. * Unlike isInFrustum this cheks the full bounding box
  66324. * @param frustumPlanes Camera near/planes
  66325. * @returns true if the object is in frustum otherwise false
  66326. */
  66327. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66328. /** @hidden */
  66329. _checkCollision(collider: Collider): boolean;
  66330. /**
  66331. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  66332. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66333. * @param point the point to check intersection with
  66334. * @returns if the point intersects
  66335. */
  66336. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66337. /**
  66338. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  66339. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66340. * @param boundingInfo the bounding info to check intersection with
  66341. * @param precise if the intersection should be done using OBB
  66342. * @returns if the bounding info intersects
  66343. */
  66344. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  66345. }
  66346. }
  66347. declare module BABYLON {
  66348. /**
  66349. * Defines an array and its length.
  66350. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  66351. */
  66352. export interface ISmartArrayLike<T> {
  66353. /**
  66354. * The data of the array.
  66355. */
  66356. data: Array<T>;
  66357. /**
  66358. * The active length of the array.
  66359. */
  66360. length: number;
  66361. }
  66362. /**
  66363. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66364. */
  66365. export class SmartArray<T> implements ISmartArrayLike<T> {
  66366. /**
  66367. * The full set of data from the array.
  66368. */
  66369. data: Array<T>;
  66370. /**
  66371. * The active length of the array.
  66372. */
  66373. length: number;
  66374. protected _id: number;
  66375. /**
  66376. * Instantiates a Smart Array.
  66377. * @param capacity defines the default capacity of the array.
  66378. */
  66379. constructor(capacity: number);
  66380. /**
  66381. * Pushes a value at the end of the active data.
  66382. * @param value defines the object to push in the array.
  66383. */
  66384. push(value: T): void;
  66385. /**
  66386. * Iterates over the active data and apply the lambda to them.
  66387. * @param func defines the action to apply on each value.
  66388. */
  66389. forEach(func: (content: T) => void): void;
  66390. /**
  66391. * Sorts the full sets of data.
  66392. * @param compareFn defines the comparison function to apply.
  66393. */
  66394. sort(compareFn: (a: T, b: T) => number): void;
  66395. /**
  66396. * Resets the active data to an empty array.
  66397. */
  66398. reset(): void;
  66399. /**
  66400. * Releases all the data from the array as well as the array.
  66401. */
  66402. dispose(): void;
  66403. /**
  66404. * Concats the active data with a given array.
  66405. * @param array defines the data to concatenate with.
  66406. */
  66407. concat(array: any): void;
  66408. /**
  66409. * Returns the position of a value in the active data.
  66410. * @param value defines the value to find the index for
  66411. * @returns the index if found in the active data otherwise -1
  66412. */
  66413. indexOf(value: T): number;
  66414. /**
  66415. * Returns whether an element is part of the active data.
  66416. * @param value defines the value to look for
  66417. * @returns true if found in the active data otherwise false
  66418. */
  66419. contains(value: T): boolean;
  66420. private static _GlobalId;
  66421. }
  66422. /**
  66423. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66424. * The data in this array can only be present once
  66425. */
  66426. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  66427. private _duplicateId;
  66428. /**
  66429. * Pushes a value at the end of the active data.
  66430. * THIS DOES NOT PREVENT DUPPLICATE DATA
  66431. * @param value defines the object to push in the array.
  66432. */
  66433. push(value: T): void;
  66434. /**
  66435. * Pushes a value at the end of the active data.
  66436. * If the data is already present, it won t be added again
  66437. * @param value defines the object to push in the array.
  66438. * @returns true if added false if it was already present
  66439. */
  66440. pushNoDuplicate(value: T): boolean;
  66441. /**
  66442. * Resets the active data to an empty array.
  66443. */
  66444. reset(): void;
  66445. /**
  66446. * Concats the active data with a given array.
  66447. * This ensures no dupplicate will be present in the result.
  66448. * @param array defines the data to concatenate with.
  66449. */
  66450. concatWithNoDuplicate(array: any): void;
  66451. }
  66452. }
  66453. declare module BABYLON {
  66454. /**
  66455. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66456. * separate meshes. This can be use to improve performances.
  66457. * @see http://doc.babylonjs.com/how_to/multi_materials
  66458. */
  66459. export class MultiMaterial extends Material {
  66460. private _subMaterials;
  66461. /**
  66462. * Gets or Sets the list of Materials used within the multi material.
  66463. * They need to be ordered according to the submeshes order in the associated mesh
  66464. */
  66465. subMaterials: Nullable<Material>[];
  66466. /**
  66467. * Function used to align with Node.getChildren()
  66468. * @returns the list of Materials used within the multi material
  66469. */
  66470. getChildren(): Nullable<Material>[];
  66471. /**
  66472. * Instantiates a new Multi Material
  66473. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66474. * separate meshes. This can be use to improve performances.
  66475. * @see http://doc.babylonjs.com/how_to/multi_materials
  66476. * @param name Define the name in the scene
  66477. * @param scene Define the scene the material belongs to
  66478. */
  66479. constructor(name: string, scene: Scene);
  66480. private _hookArray;
  66481. /**
  66482. * Get one of the submaterial by its index in the submaterials array
  66483. * @param index The index to look the sub material at
  66484. * @returns The Material if the index has been defined
  66485. */
  66486. getSubMaterial(index: number): Nullable<Material>;
  66487. /**
  66488. * Get the list of active textures for the whole sub materials list.
  66489. * @returns All the textures that will be used during the rendering
  66490. */
  66491. getActiveTextures(): BaseTexture[];
  66492. /**
  66493. * Gets the current class name of the material e.g. "MultiMaterial"
  66494. * Mainly use in serialization.
  66495. * @returns the class name
  66496. */
  66497. getClassName(): string;
  66498. /**
  66499. * Checks if the material is ready to render the requested sub mesh
  66500. * @param mesh Define the mesh the submesh belongs to
  66501. * @param subMesh Define the sub mesh to look readyness for
  66502. * @param useInstances Define whether or not the material is used with instances
  66503. * @returns true if ready, otherwise false
  66504. */
  66505. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  66506. /**
  66507. * Clones the current material and its related sub materials
  66508. * @param name Define the name of the newly cloned material
  66509. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66510. * @returns the cloned material
  66511. */
  66512. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  66513. /**
  66514. * Serializes the materials into a JSON representation.
  66515. * @returns the JSON representation
  66516. */
  66517. serialize(): any;
  66518. /**
  66519. * Dispose the material and release its associated resources
  66520. * @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)
  66521. * @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)
  66522. * @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)
  66523. */
  66524. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  66525. /**
  66526. * Creates a MultiMaterial from parsed MultiMaterial data.
  66527. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66528. * @param scene defines the hosting scene
  66529. * @returns a new MultiMaterial
  66530. */
  66531. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  66532. }
  66533. }
  66534. declare module BABYLON {
  66535. /**
  66536. * Class used to represent data loading progression
  66537. */
  66538. export class SceneLoaderFlags {
  66539. private static _ForceFullSceneLoadingForIncremental;
  66540. private static _ShowLoadingScreen;
  66541. private static _CleanBoneMatrixWeights;
  66542. private static _loggingLevel;
  66543. /**
  66544. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  66545. */
  66546. static ForceFullSceneLoadingForIncremental: boolean;
  66547. /**
  66548. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  66549. */
  66550. static ShowLoadingScreen: boolean;
  66551. /**
  66552. * Defines the current logging level (while loading the scene)
  66553. * @ignorenaming
  66554. */
  66555. static loggingLevel: number;
  66556. /**
  66557. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  66558. */
  66559. static CleanBoneMatrixWeights: boolean;
  66560. }
  66561. }
  66562. declare module BABYLON {
  66563. /**
  66564. * 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.
  66565. * @see https://doc.babylonjs.com/how_to/transformnode
  66566. */
  66567. export class TransformNode extends Node {
  66568. /**
  66569. * Object will not rotate to face the camera
  66570. */
  66571. static BILLBOARDMODE_NONE: number;
  66572. /**
  66573. * Object will rotate to face the camera but only on the x axis
  66574. */
  66575. static BILLBOARDMODE_X: number;
  66576. /**
  66577. * Object will rotate to face the camera but only on the y axis
  66578. */
  66579. static BILLBOARDMODE_Y: number;
  66580. /**
  66581. * Object will rotate to face the camera but only on the z axis
  66582. */
  66583. static BILLBOARDMODE_Z: number;
  66584. /**
  66585. * Object will rotate to face the camera
  66586. */
  66587. static BILLBOARDMODE_ALL: number;
  66588. private _forward;
  66589. private _forwardInverted;
  66590. private _up;
  66591. private _right;
  66592. private _rightInverted;
  66593. private _position;
  66594. private _rotation;
  66595. private _rotationQuaternion;
  66596. protected _scaling: Vector3;
  66597. protected _isDirty: boolean;
  66598. private _transformToBoneReferal;
  66599. /**
  66600. * Set the billboard mode. Default is 0.
  66601. *
  66602. * | Value | Type | Description |
  66603. * | --- | --- | --- |
  66604. * | 0 | BILLBOARDMODE_NONE | |
  66605. * | 1 | BILLBOARDMODE_X | |
  66606. * | 2 | BILLBOARDMODE_Y | |
  66607. * | 4 | BILLBOARDMODE_Z | |
  66608. * | 7 | BILLBOARDMODE_ALL | |
  66609. *
  66610. */
  66611. billboardMode: number;
  66612. /**
  66613. * 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
  66614. */
  66615. scalingDeterminant: number;
  66616. /**
  66617. * Sets the distance of the object to max, often used by skybox
  66618. */
  66619. infiniteDistance: boolean;
  66620. /**
  66621. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66622. * By default the system will update normals to compensate
  66623. */
  66624. ignoreNonUniformScaling: boolean;
  66625. /** @hidden */
  66626. _poseMatrix: Matrix;
  66627. /** @hidden */
  66628. _localMatrix: Matrix;
  66629. private _absolutePosition;
  66630. private _pivotMatrix;
  66631. private _pivotMatrixInverse;
  66632. protected _postMultiplyPivotMatrix: boolean;
  66633. private _tempMatrix;
  66634. private _tempMatrix2;
  66635. protected _isWorldMatrixFrozen: boolean;
  66636. /** @hidden */
  66637. _indexInSceneTransformNodesArray: number;
  66638. /**
  66639. * An event triggered after the world matrix is updated
  66640. */
  66641. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66642. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66643. /**
  66644. * Gets a string identifying the name of the class
  66645. * @returns "TransformNode" string
  66646. */
  66647. getClassName(): string;
  66648. /**
  66649. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66650. */
  66651. position: Vector3;
  66652. /**
  66653. * 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)).
  66654. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66655. */
  66656. rotation: Vector3;
  66657. /**
  66658. * 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)).
  66659. */
  66660. scaling: Vector3;
  66661. /**
  66662. * 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).
  66663. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66664. */
  66665. rotationQuaternion: Nullable<Quaternion>;
  66666. /**
  66667. * The forward direction of that transform in world space.
  66668. */
  66669. readonly forward: Vector3;
  66670. /**
  66671. * The up direction of that transform in world space.
  66672. */
  66673. readonly up: Vector3;
  66674. /**
  66675. * The right direction of that transform in world space.
  66676. */
  66677. readonly right: Vector3;
  66678. /**
  66679. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66680. * @param matrix the matrix to copy the pose from
  66681. * @returns this TransformNode.
  66682. */
  66683. updatePoseMatrix(matrix: Matrix): TransformNode;
  66684. /**
  66685. * Returns the mesh Pose matrix.
  66686. * @returns the pose matrix
  66687. */
  66688. getPoseMatrix(): Matrix;
  66689. /** @hidden */
  66690. _isSynchronized(): boolean;
  66691. /** @hidden */
  66692. _initCache(): void;
  66693. /**
  66694. * Flag the transform node as dirty (Forcing it to update everything)
  66695. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  66696. * @returns this transform node
  66697. */
  66698. markAsDirty(property: string): TransformNode;
  66699. /**
  66700. * Returns the current mesh absolute position.
  66701. * Returns a Vector3.
  66702. */
  66703. readonly absolutePosition: Vector3;
  66704. /**
  66705. * Sets a new matrix to apply before all other transformation
  66706. * @param matrix defines the transform matrix
  66707. * @returns the current TransformNode
  66708. */
  66709. setPreTransformMatrix(matrix: Matrix): TransformNode;
  66710. /**
  66711. * Sets a new pivot matrix to the current node
  66712. * @param matrix defines the new pivot matrix to use
  66713. * @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
  66714. * @returns the current TransformNode
  66715. */
  66716. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  66717. /**
  66718. * Returns the mesh pivot matrix.
  66719. * Default : Identity.
  66720. * @returns the matrix
  66721. */
  66722. getPivotMatrix(): Matrix;
  66723. /**
  66724. * Prevents the World matrix to be computed any longer.
  66725. * @returns the TransformNode.
  66726. */
  66727. freezeWorldMatrix(): TransformNode;
  66728. /**
  66729. * Allows back the World matrix computation.
  66730. * @returns the TransformNode.
  66731. */
  66732. unfreezeWorldMatrix(): this;
  66733. /**
  66734. * True if the World matrix has been frozen.
  66735. */
  66736. readonly isWorldMatrixFrozen: boolean;
  66737. /**
  66738. * Retuns the mesh absolute position in the World.
  66739. * @returns a Vector3.
  66740. */
  66741. getAbsolutePosition(): Vector3;
  66742. /**
  66743. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  66744. * @param absolutePosition the absolute position to set
  66745. * @returns the TransformNode.
  66746. */
  66747. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  66748. /**
  66749. * Sets the mesh position in its local space.
  66750. * @param vector3 the position to set in localspace
  66751. * @returns the TransformNode.
  66752. */
  66753. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  66754. /**
  66755. * Returns the mesh position in the local space from the current World matrix values.
  66756. * @returns a new Vector3.
  66757. */
  66758. getPositionExpressedInLocalSpace(): Vector3;
  66759. /**
  66760. * Translates the mesh along the passed Vector3 in its local space.
  66761. * @param vector3 the distance to translate in localspace
  66762. * @returns the TransformNode.
  66763. */
  66764. locallyTranslate(vector3: Vector3): TransformNode;
  66765. private static _lookAtVectorCache;
  66766. /**
  66767. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  66768. * @param targetPoint the position (must be in same space as current mesh) to look at
  66769. * @param yawCor optional yaw (y-axis) correction in radians
  66770. * @param pitchCor optional pitch (x-axis) correction in radians
  66771. * @param rollCor optional roll (z-axis) correction in radians
  66772. * @param space the choosen space of the target
  66773. * @returns the TransformNode.
  66774. */
  66775. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  66776. /**
  66777. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66778. * This Vector3 is expressed in the World space.
  66779. * @param localAxis axis to rotate
  66780. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66781. */
  66782. getDirection(localAxis: Vector3): Vector3;
  66783. /**
  66784. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  66785. * localAxis is expressed in the mesh local space.
  66786. * result is computed in the Wordl space from the mesh World matrix.
  66787. * @param localAxis axis to rotate
  66788. * @param result the resulting transformnode
  66789. * @returns this TransformNode.
  66790. */
  66791. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  66792. /**
  66793. * Sets this transform node rotation to the given local axis.
  66794. * @param localAxis the axis in local space
  66795. * @param yawCor optional yaw (y-axis) correction in radians
  66796. * @param pitchCor optional pitch (x-axis) correction in radians
  66797. * @param rollCor optional roll (z-axis) correction in radians
  66798. * @returns this TransformNode
  66799. */
  66800. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  66801. /**
  66802. * Sets a new pivot point to the current node
  66803. * @param point defines the new pivot point to use
  66804. * @param space defines if the point is in world or local space (local by default)
  66805. * @returns the current TransformNode
  66806. */
  66807. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  66808. /**
  66809. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  66810. * @returns the pivot point
  66811. */
  66812. getPivotPoint(): Vector3;
  66813. /**
  66814. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  66815. * @param result the vector3 to store the result
  66816. * @returns this TransformNode.
  66817. */
  66818. getPivotPointToRef(result: Vector3): TransformNode;
  66819. /**
  66820. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  66821. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  66822. */
  66823. getAbsolutePivotPoint(): Vector3;
  66824. /**
  66825. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  66826. * @param result vector3 to store the result
  66827. * @returns this TransformNode.
  66828. */
  66829. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  66830. /**
  66831. * Defines the passed node as the parent of the current node.
  66832. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  66833. * @see https://doc.babylonjs.com/how_to/parenting
  66834. * @param node the node ot set as the parent
  66835. * @returns this TransformNode.
  66836. */
  66837. setParent(node: Nullable<Node>): TransformNode;
  66838. private _nonUniformScaling;
  66839. /**
  66840. * True if the scaling property of this object is non uniform eg. (1,2,1)
  66841. */
  66842. readonly nonUniformScaling: boolean;
  66843. /** @hidden */
  66844. _updateNonUniformScalingState(value: boolean): boolean;
  66845. /**
  66846. * Attach the current TransformNode to another TransformNode associated with a bone
  66847. * @param bone Bone affecting the TransformNode
  66848. * @param affectedTransformNode TransformNode associated with the bone
  66849. * @returns this object
  66850. */
  66851. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  66852. /**
  66853. * Detach the transform node if its associated with a bone
  66854. * @returns this object
  66855. */
  66856. detachFromBone(): TransformNode;
  66857. private static _rotationAxisCache;
  66858. /**
  66859. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  66860. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66861. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66862. * The passed axis is also normalized.
  66863. * @param axis the axis to rotate around
  66864. * @param amount the amount to rotate in radians
  66865. * @param space Space to rotate in (Default: local)
  66866. * @returns the TransformNode.
  66867. */
  66868. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  66869. /**
  66870. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  66871. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66872. * The passed axis is also normalized. .
  66873. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  66874. * @param point the point to rotate around
  66875. * @param axis the axis to rotate around
  66876. * @param amount the amount to rotate in radians
  66877. * @returns the TransformNode
  66878. */
  66879. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  66880. /**
  66881. * Translates the mesh along the axis vector for the passed distance in the given space.
  66882. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66883. * @param axis the axis to translate in
  66884. * @param distance the distance to translate
  66885. * @param space Space to rotate in (Default: local)
  66886. * @returns the TransformNode.
  66887. */
  66888. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  66889. /**
  66890. * Adds a rotation step to the mesh current rotation.
  66891. * x, y, z are Euler angles expressed in radians.
  66892. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  66893. * This means this rotation is made in the mesh local space only.
  66894. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  66895. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  66896. * ```javascript
  66897. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  66898. * ```
  66899. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  66900. * 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.
  66901. * @param x Rotation to add
  66902. * @param y Rotation to add
  66903. * @param z Rotation to add
  66904. * @returns the TransformNode.
  66905. */
  66906. addRotation(x: number, y: number, z: number): TransformNode;
  66907. /**
  66908. * Computes the world matrix of the node
  66909. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66910. * @returns the world matrix
  66911. */
  66912. computeWorldMatrix(force?: boolean): Matrix;
  66913. protected _afterComputeWorldMatrix(): void;
  66914. /**
  66915. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  66916. * @param func callback function to add
  66917. *
  66918. * @returns the TransformNode.
  66919. */
  66920. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66921. /**
  66922. * Removes a registered callback function.
  66923. * @param func callback function to remove
  66924. * @returns the TransformNode.
  66925. */
  66926. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66927. /**
  66928. * Gets the position of the current mesh in camera space
  66929. * @param camera defines the camera to use
  66930. * @returns a position
  66931. */
  66932. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  66933. /**
  66934. * Returns the distance from the mesh to the active camera
  66935. * @param camera defines the camera to use
  66936. * @returns the distance
  66937. */
  66938. getDistanceToCamera(camera?: Nullable<Camera>): number;
  66939. /**
  66940. * Clone the current transform node
  66941. * @param name Name of the new clone
  66942. * @param newParent New parent for the clone
  66943. * @param doNotCloneChildren Do not clone children hierarchy
  66944. * @returns the new transform node
  66945. */
  66946. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  66947. /**
  66948. * Serializes the objects information.
  66949. * @param currentSerializationObject defines the object to serialize in
  66950. * @returns the serialized object
  66951. */
  66952. serialize(currentSerializationObject?: any): any;
  66953. /**
  66954. * Returns a new TransformNode object parsed from the source provided.
  66955. * @param parsedTransformNode is the source.
  66956. * @param scene the scne the object belongs to
  66957. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  66958. * @returns a new TransformNode object parsed from the source provided.
  66959. */
  66960. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  66961. /**
  66962. * Get all child-transformNodes of this node
  66963. * @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
  66964. * @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
  66965. * @returns an array of TransformNode
  66966. */
  66967. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  66968. /**
  66969. * Releases resources associated with this transform node.
  66970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66972. */
  66973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66974. }
  66975. }
  66976. declare module BABYLON {
  66977. /**
  66978. * Class used to override all child animations of a given target
  66979. */
  66980. export class AnimationPropertiesOverride {
  66981. /**
  66982. * Gets or sets a value indicating if animation blending must be used
  66983. */
  66984. enableBlending: boolean;
  66985. /**
  66986. * Gets or sets the blending speed to use when enableBlending is true
  66987. */
  66988. blendingSpeed: number;
  66989. /**
  66990. * Gets or sets the default loop mode to use
  66991. */
  66992. loopMode: number;
  66993. }
  66994. }
  66995. declare module BABYLON {
  66996. /**
  66997. * Class used to store bone information
  66998. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  66999. */
  67000. export class Bone extends Node {
  67001. /**
  67002. * defines the bone name
  67003. */
  67004. name: string;
  67005. private static _tmpVecs;
  67006. private static _tmpQuat;
  67007. private static _tmpMats;
  67008. /**
  67009. * Gets the list of child bones
  67010. */
  67011. children: Bone[];
  67012. /** Gets the animations associated with this bone */
  67013. animations: Animation[];
  67014. /**
  67015. * Gets or sets bone length
  67016. */
  67017. length: number;
  67018. /**
  67019. * @hidden Internal only
  67020. * Set this value to map this bone to a different index in the transform matrices
  67021. * Set this value to -1 to exclude the bone from the transform matrices
  67022. */
  67023. _index: Nullable<number>;
  67024. private _skeleton;
  67025. private _localMatrix;
  67026. private _restPose;
  67027. private _baseMatrix;
  67028. private _absoluteTransform;
  67029. private _invertedAbsoluteTransform;
  67030. private _parent;
  67031. private _scalingDeterminant;
  67032. private _worldTransform;
  67033. private _localScaling;
  67034. private _localRotation;
  67035. private _localPosition;
  67036. private _needToDecompose;
  67037. private _needToCompose;
  67038. /** @hidden */
  67039. _linkedTransformNode: Nullable<TransformNode>;
  67040. /** @hidden */
  67041. /** @hidden */
  67042. _matrix: Matrix;
  67043. /**
  67044. * Create a new bone
  67045. * @param name defines the bone name
  67046. * @param skeleton defines the parent skeleton
  67047. * @param parentBone defines the parent (can be null if the bone is the root)
  67048. * @param localMatrix defines the local matrix
  67049. * @param restPose defines the rest pose matrix
  67050. * @param baseMatrix defines the base matrix
  67051. * @param index defines index of the bone in the hiearchy
  67052. */
  67053. constructor(
  67054. /**
  67055. * defines the bone name
  67056. */
  67057. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67058. /**
  67059. * Gets the current object class name.
  67060. * @return the class name
  67061. */
  67062. getClassName(): string;
  67063. /**
  67064. * Gets the parent skeleton
  67065. * @returns a skeleton
  67066. */
  67067. getSkeleton(): Skeleton;
  67068. /**
  67069. * Gets parent bone
  67070. * @returns a bone or null if the bone is the root of the bone hierarchy
  67071. */
  67072. getParent(): Nullable<Bone>;
  67073. /**
  67074. * Returns an array containing the root bones
  67075. * @returns an array containing the root bones
  67076. */
  67077. getChildren(): Array<Bone>;
  67078. /**
  67079. * Sets the parent bone
  67080. * @param parent defines the parent (can be null if the bone is the root)
  67081. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67082. */
  67083. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67084. /**
  67085. * Gets the local matrix
  67086. * @returns a matrix
  67087. */
  67088. getLocalMatrix(): Matrix;
  67089. /**
  67090. * Gets the base matrix (initial matrix which remains unchanged)
  67091. * @returns a matrix
  67092. */
  67093. getBaseMatrix(): Matrix;
  67094. /**
  67095. * Gets the rest pose matrix
  67096. * @returns a matrix
  67097. */
  67098. getRestPose(): Matrix;
  67099. /**
  67100. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67101. */
  67102. getWorldMatrix(): Matrix;
  67103. /**
  67104. * Sets the local matrix to rest pose matrix
  67105. */
  67106. returnToRest(): void;
  67107. /**
  67108. * Gets the inverse of the absolute transform matrix.
  67109. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67110. * @returns a matrix
  67111. */
  67112. getInvertedAbsoluteTransform(): Matrix;
  67113. /**
  67114. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67115. * @returns a matrix
  67116. */
  67117. getAbsoluteTransform(): Matrix;
  67118. /**
  67119. * Links with the given transform node.
  67120. * The local matrix of this bone is copied from the transform node every frame.
  67121. * @param transformNode defines the transform node to link to
  67122. */
  67123. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67124. /** Gets or sets current position (in local space) */
  67125. position: Vector3;
  67126. /** Gets or sets current rotation (in local space) */
  67127. rotation: Vector3;
  67128. /** Gets or sets current rotation quaternion (in local space) */
  67129. rotationQuaternion: Quaternion;
  67130. /** Gets or sets current scaling (in local space) */
  67131. scaling: Vector3;
  67132. /**
  67133. * Gets the animation properties override
  67134. */
  67135. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67136. private _decompose;
  67137. private _compose;
  67138. /**
  67139. * Update the base and local matrices
  67140. * @param matrix defines the new base or local matrix
  67141. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67142. * @param updateLocalMatrix defines if the local matrix should be updated
  67143. */
  67144. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67145. /** @hidden */
  67146. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67147. /**
  67148. * Flag the bone as dirty (Forcing it to update everything)
  67149. */
  67150. markAsDirty(): void;
  67151. private _markAsDirtyAndCompose;
  67152. private _markAsDirtyAndDecompose;
  67153. /**
  67154. * Translate the bone in local or world space
  67155. * @param vec The amount to translate the bone
  67156. * @param space The space that the translation is in
  67157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67158. */
  67159. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67160. /**
  67161. * Set the postion of the bone in local or world space
  67162. * @param position The position to set the bone
  67163. * @param space The space that the position is in
  67164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67165. */
  67166. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67167. /**
  67168. * Set the absolute position of the bone (world space)
  67169. * @param position The position to set the bone
  67170. * @param mesh The mesh that this bone is attached to
  67171. */
  67172. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67173. /**
  67174. * Scale the bone on the x, y and z axes (in local space)
  67175. * @param x The amount to scale the bone on the x axis
  67176. * @param y The amount to scale the bone on the y axis
  67177. * @param z The amount to scale the bone on the z axis
  67178. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67179. */
  67180. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67181. /**
  67182. * Set the bone scaling in local space
  67183. * @param scale defines the scaling vector
  67184. */
  67185. setScale(scale: Vector3): void;
  67186. /**
  67187. * Gets the current scaling in local space
  67188. * @returns the current scaling vector
  67189. */
  67190. getScale(): Vector3;
  67191. /**
  67192. * Gets the current scaling in local space and stores it in a target vector
  67193. * @param result defines the target vector
  67194. */
  67195. getScaleToRef(result: Vector3): void;
  67196. /**
  67197. * Set the yaw, pitch, and roll of the bone in local or world space
  67198. * @param yaw The rotation of the bone on the y axis
  67199. * @param pitch The rotation of the bone on the x axis
  67200. * @param roll The rotation of the bone on the z axis
  67201. * @param space The space that the axes of rotation are in
  67202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67203. */
  67204. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  67205. /**
  67206. * Add a rotation to the bone on an axis in local or world space
  67207. * @param axis The axis to rotate the bone on
  67208. * @param amount The amount to rotate the bone
  67209. * @param space The space that the axis is in
  67210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67211. */
  67212. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  67213. /**
  67214. * Set the rotation of the bone to a particular axis angle in local or world space
  67215. * @param axis The axis to rotate the bone on
  67216. * @param angle The angle that the bone should be rotated to
  67217. * @param space The space that the axis is in
  67218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67219. */
  67220. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  67221. /**
  67222. * Set the euler rotation of the bone in local of world space
  67223. * @param rotation The euler rotation that the bone should be set to
  67224. * @param space The space that the rotation is in
  67225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67226. */
  67227. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67228. /**
  67229. * Set the quaternion rotation of the bone in local of world space
  67230. * @param quat The quaternion rotation that the bone should be set to
  67231. * @param space The space that the rotation is in
  67232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67233. */
  67234. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  67235. /**
  67236. * Set the rotation matrix of the bone in local of world space
  67237. * @param rotMat The rotation matrix that the bone should be set to
  67238. * @param space The space that the rotation is in
  67239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67240. */
  67241. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  67242. private _rotateWithMatrix;
  67243. private _getNegativeRotationToRef;
  67244. /**
  67245. * Get the position of the bone in local or world space
  67246. * @param space The space that the returned position is in
  67247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67248. * @returns The position of the bone
  67249. */
  67250. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67251. /**
  67252. * Copy the position of the bone to a vector3 in local or world space
  67253. * @param space The space that the returned position is in
  67254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67255. * @param result The vector3 to copy the position to
  67256. */
  67257. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  67258. /**
  67259. * Get the absolute position of the bone (world space)
  67260. * @param mesh The mesh that this bone is attached to
  67261. * @returns The absolute position of the bone
  67262. */
  67263. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  67264. /**
  67265. * Copy the absolute position of the bone (world space) to the result param
  67266. * @param mesh The mesh that this bone is attached to
  67267. * @param result The vector3 to copy the absolute position to
  67268. */
  67269. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  67270. /**
  67271. * Compute the absolute transforms of this bone and its children
  67272. */
  67273. computeAbsoluteTransforms(): void;
  67274. /**
  67275. * Get the world direction from an axis that is in the local space of the bone
  67276. * @param localAxis The local direction that is used to compute the world direction
  67277. * @param mesh The mesh that this bone is attached to
  67278. * @returns The world direction
  67279. */
  67280. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67281. /**
  67282. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  67283. * @param localAxis The local direction that is used to compute the world direction
  67284. * @param mesh The mesh that this bone is attached to
  67285. * @param result The vector3 that the world direction will be copied to
  67286. */
  67287. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67288. /**
  67289. * Get the euler rotation of the bone in local or world space
  67290. * @param space The space that the rotation should be in
  67291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67292. * @returns The euler rotation
  67293. */
  67294. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67295. /**
  67296. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  67297. * @param space The space that the rotation should be in
  67298. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67299. * @param result The vector3 that the rotation should be copied to
  67300. */
  67301. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67302. /**
  67303. * Get the quaternion rotation of the bone in either local or world space
  67304. * @param space The space that the rotation should be in
  67305. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67306. * @returns The quaternion rotation
  67307. */
  67308. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  67309. /**
  67310. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  67311. * @param space The space that the rotation should be in
  67312. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67313. * @param result The quaternion that the rotation should be copied to
  67314. */
  67315. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  67316. /**
  67317. * Get the rotation matrix of the bone in local or world space
  67318. * @param space The space that the rotation should be in
  67319. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67320. * @returns The rotation matrix
  67321. */
  67322. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  67323. /**
  67324. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  67325. * @param space The space that the rotation should be in
  67326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67327. * @param result The quaternion that the rotation should be copied to
  67328. */
  67329. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  67330. /**
  67331. * Get the world position of a point that is in the local space of the bone
  67332. * @param position The local position
  67333. * @param mesh The mesh that this bone is attached to
  67334. * @returns The world position
  67335. */
  67336. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67337. /**
  67338. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  67339. * @param position The local position
  67340. * @param mesh The mesh that this bone is attached to
  67341. * @param result The vector3 that the world position should be copied to
  67342. */
  67343. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67344. /**
  67345. * Get the local position of a point that is in world space
  67346. * @param position The world position
  67347. * @param mesh The mesh that this bone is attached to
  67348. * @returns The local position
  67349. */
  67350. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67351. /**
  67352. * Get the local position of a point that is in world space and copy it to the result param
  67353. * @param position The world position
  67354. * @param mesh The mesh that this bone is attached to
  67355. * @param result The vector3 that the local position should be copied to
  67356. */
  67357. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67358. }
  67359. }
  67360. declare module BABYLON {
  67361. /**
  67362. * Enum that determines the text-wrapping mode to use.
  67363. */
  67364. export enum InspectableType {
  67365. /**
  67366. * Checkbox for booleans
  67367. */
  67368. Checkbox = 0,
  67369. /**
  67370. * Sliders for numbers
  67371. */
  67372. Slider = 1,
  67373. /**
  67374. * Vector3
  67375. */
  67376. Vector3 = 2,
  67377. /**
  67378. * Quaternions
  67379. */
  67380. Quaternion = 3,
  67381. /**
  67382. * Color3
  67383. */
  67384. Color3 = 4
  67385. }
  67386. /**
  67387. * Interface used to define custom inspectable properties.
  67388. * This interface is used by the inspector to display custom property grids
  67389. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67390. */
  67391. export interface IInspectable {
  67392. /**
  67393. * Gets the label to display
  67394. */
  67395. label: string;
  67396. /**
  67397. * Gets the name of the property to edit
  67398. */
  67399. propertyName: string;
  67400. /**
  67401. * Gets the type of the editor to use
  67402. */
  67403. type: InspectableType;
  67404. /**
  67405. * Gets the minimum value of the property when using in "slider" mode
  67406. */
  67407. min?: number;
  67408. /**
  67409. * Gets the maximum value of the property when using in "slider" mode
  67410. */
  67411. max?: number;
  67412. /**
  67413. * Gets the setp to use when using in "slider" mode
  67414. */
  67415. step?: number;
  67416. }
  67417. }
  67418. declare module BABYLON {
  67419. /**
  67420. * Class for creating a cube texture
  67421. */
  67422. export class CubeTexture extends BaseTexture {
  67423. private _delayedOnLoad;
  67424. /**
  67425. * The url of the texture
  67426. */
  67427. url: string;
  67428. /**
  67429. * Gets or sets the center of the bounding box associated with the cube texture.
  67430. * It must define where the camera used to render the texture was set
  67431. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67432. */
  67433. boundingBoxPosition: Vector3;
  67434. private _boundingBoxSize;
  67435. /**
  67436. * Gets or sets the size of the bounding box associated with the cube texture
  67437. * When defined, the cubemap will switch to local mode
  67438. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67439. * @example https://www.babylonjs-playground.com/#RNASML
  67440. */
  67441. /**
  67442. * Returns the bounding box size
  67443. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67444. */
  67445. boundingBoxSize: Vector3;
  67446. protected _rotationY: number;
  67447. /**
  67448. * Sets texture matrix rotation angle around Y axis in radians.
  67449. */
  67450. /**
  67451. * Gets texture matrix rotation angle around Y axis radians.
  67452. */
  67453. rotationY: number;
  67454. /**
  67455. * Are mip maps generated for this texture or not.
  67456. */
  67457. readonly noMipmap: boolean;
  67458. private _noMipmap;
  67459. private _files;
  67460. private _extensions;
  67461. private _textureMatrix;
  67462. private _format;
  67463. private _createPolynomials;
  67464. /** @hidden */
  67465. _prefiltered: boolean;
  67466. /**
  67467. * Creates a cube texture from an array of image urls
  67468. * @param files defines an array of image urls
  67469. * @param scene defines the hosting scene
  67470. * @param noMipmap specifies if mip maps are not used
  67471. * @returns a cube texture
  67472. */
  67473. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  67474. /**
  67475. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67476. * @param url defines the url of the prefiltered texture
  67477. * @param scene defines the scene the texture is attached to
  67478. * @param forcedExtension defines the extension of the file if different from the url
  67479. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67480. * @return the prefiltered texture
  67481. */
  67482. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  67483. /**
  67484. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67485. * as prefiltered data.
  67486. * @param rootUrl defines the url of the texture or the root name of the six images
  67487. * @param scene defines the scene the texture is attached to
  67488. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67489. * @param noMipmap defines if mipmaps should be created or not
  67490. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67491. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67492. * @param onError defines a callback triggered in case of error during load
  67493. * @param format defines the internal format to use for the texture once loaded
  67494. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67495. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67496. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67497. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67498. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67499. * @return the cube texture
  67500. */
  67501. 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);
  67502. /**
  67503. * Get the current class name of the texture useful for serialization or dynamic coding.
  67504. * @returns "CubeTexture"
  67505. */
  67506. getClassName(): string;
  67507. /**
  67508. * Update the url (and optional buffer) of this texture if url was null during construction.
  67509. * @param url the url of the texture
  67510. * @param forcedExtension defines the extension to use
  67511. * @param onLoad callback called when the texture is loaded (defaults to null)
  67512. */
  67513. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  67514. /**
  67515. * Delays loading of the cube texture
  67516. * @param forcedExtension defines the extension to use
  67517. */
  67518. delayLoad(forcedExtension?: string): void;
  67519. /**
  67520. * Returns the reflection texture matrix
  67521. * @returns the reflection texture matrix
  67522. */
  67523. getReflectionTextureMatrix(): Matrix;
  67524. /**
  67525. * Sets the reflection texture matrix
  67526. * @param value Reflection texture matrix
  67527. */
  67528. setReflectionTextureMatrix(value: Matrix): void;
  67529. /**
  67530. * Parses text to create a cube texture
  67531. * @param parsedTexture define the serialized text to read from
  67532. * @param scene defines the hosting scene
  67533. * @param rootUrl defines the root url of the cube texture
  67534. * @returns a cube texture
  67535. */
  67536. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  67537. /**
  67538. * Makes a clone, or deep copy, of the cube texture
  67539. * @returns a new cube texture
  67540. */
  67541. clone(): CubeTexture;
  67542. }
  67543. }
  67544. declare module BABYLON {
  67545. /** @hidden */
  67546. export var postprocessVertexShader: {
  67547. name: string;
  67548. shader: string;
  67549. };
  67550. }
  67551. declare module BABYLON {
  67552. /**
  67553. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  67554. * This is the base of the follow, arc rotate cameras and Free camera
  67555. * @see http://doc.babylonjs.com/features/cameras
  67556. */
  67557. export class TargetCamera extends Camera {
  67558. private static _RigCamTransformMatrix;
  67559. private static _TargetTransformMatrix;
  67560. private static _TargetFocalPoint;
  67561. /**
  67562. * Define the current direction the camera is moving to
  67563. */
  67564. cameraDirection: Vector3;
  67565. /**
  67566. * Define the current rotation the camera is rotating to
  67567. */
  67568. cameraRotation: Vector2;
  67569. /**
  67570. * When set, the up vector of the camera will be updated by the rotation of the camera
  67571. */
  67572. updateUpVectorFromRotation: boolean;
  67573. private _tmpQuaternion;
  67574. /**
  67575. * Define the current rotation of the camera
  67576. */
  67577. rotation: Vector3;
  67578. /**
  67579. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  67580. */
  67581. rotationQuaternion: Quaternion;
  67582. /**
  67583. * Define the current speed of the camera
  67584. */
  67585. speed: number;
  67586. /**
  67587. * Add cconstraint to the camera to prevent it to move freely in all directions and
  67588. * around all axis.
  67589. */
  67590. noRotationConstraint: boolean;
  67591. /**
  67592. * Define the current target of the camera as an object or a position.
  67593. */
  67594. lockedTarget: any;
  67595. /** @hidden */
  67596. _currentTarget: Vector3;
  67597. /** @hidden */
  67598. _initialFocalDistance: number;
  67599. /** @hidden */
  67600. _viewMatrix: Matrix;
  67601. /** @hidden */
  67602. _camMatrix: Matrix;
  67603. /** @hidden */
  67604. _cameraTransformMatrix: Matrix;
  67605. /** @hidden */
  67606. _cameraRotationMatrix: Matrix;
  67607. /** @hidden */
  67608. _referencePoint: Vector3;
  67609. /** @hidden */
  67610. _transformedReferencePoint: Vector3;
  67611. protected _globalCurrentTarget: Vector3;
  67612. protected _globalCurrentUpVector: Vector3;
  67613. /** @hidden */
  67614. _reset: () => void;
  67615. private _defaultUp;
  67616. /**
  67617. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67618. * This is the base of the follow, arc rotate cameras and Free camera
  67619. * @see http://doc.babylonjs.com/features/cameras
  67620. * @param name Defines the name of the camera in the scene
  67621. * @param position Defines the start position of the camera in the scene
  67622. * @param scene Defines the scene the camera belongs to
  67623. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67624. */
  67625. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67626. /**
  67627. * Gets the position in front of the camera at a given distance.
  67628. * @param distance The distance from the camera we want the position to be
  67629. * @returns the position
  67630. */
  67631. getFrontPosition(distance: number): Vector3;
  67632. /** @hidden */
  67633. _getLockedTargetPosition(): Nullable<Vector3>;
  67634. private _storedPosition;
  67635. private _storedRotation;
  67636. private _storedRotationQuaternion;
  67637. /**
  67638. * Store current camera state of the camera (fov, position, rotation, etc..)
  67639. * @returns the camera
  67640. */
  67641. storeState(): Camera;
  67642. /**
  67643. * Restored camera state. You must call storeState() first
  67644. * @returns whether it was successful or not
  67645. * @hidden
  67646. */
  67647. _restoreStateValues(): boolean;
  67648. /** @hidden */
  67649. _initCache(): void;
  67650. /** @hidden */
  67651. _updateCache(ignoreParentClass?: boolean): void;
  67652. /** @hidden */
  67653. _isSynchronizedViewMatrix(): boolean;
  67654. /** @hidden */
  67655. _computeLocalCameraSpeed(): number;
  67656. /**
  67657. * Defines the target the camera should look at.
  67658. * This will automatically adapt alpha beta and radius to fit within the new target.
  67659. * @param target Defines the new target as a Vector or a mesh
  67660. */
  67661. setTarget(target: Vector3): void;
  67662. /**
  67663. * Return the current target position of the camera. This value is expressed in local space.
  67664. * @returns the target position
  67665. */
  67666. getTarget(): Vector3;
  67667. /** @hidden */
  67668. _decideIfNeedsToMove(): boolean;
  67669. /** @hidden */
  67670. _updatePosition(): void;
  67671. /** @hidden */
  67672. _checkInputs(): void;
  67673. protected _updateCameraRotationMatrix(): void;
  67674. /**
  67675. * 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)
  67676. * @returns the current camera
  67677. */
  67678. private _rotateUpVectorWithCameraRotationMatrix;
  67679. private _cachedRotationZ;
  67680. private _cachedQuaternionRotationZ;
  67681. /** @hidden */
  67682. _getViewMatrix(): Matrix;
  67683. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  67684. /**
  67685. * @hidden
  67686. */
  67687. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  67688. /**
  67689. * @hidden
  67690. */
  67691. _updateRigCameras(): void;
  67692. private _getRigCamPositionAndTarget;
  67693. /**
  67694. * Gets the current object class name.
  67695. * @return the class name
  67696. */
  67697. getClassName(): string;
  67698. }
  67699. }
  67700. declare module BABYLON {
  67701. /**
  67702. * @ignore
  67703. * This is a list of all the different input types that are available in the application.
  67704. * Fo instance: ArcRotateCameraGamepadInput...
  67705. */
  67706. export var CameraInputTypes: {};
  67707. /**
  67708. * This is the contract to implement in order to create a new input class.
  67709. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  67710. */
  67711. export interface ICameraInput<TCamera extends Camera> {
  67712. /**
  67713. * Defines the camera the input is attached to.
  67714. */
  67715. camera: Nullable<TCamera>;
  67716. /**
  67717. * Gets the class name of the current intput.
  67718. * @returns the class name
  67719. */
  67720. getClassName(): string;
  67721. /**
  67722. * Get the friendly name associated with the input class.
  67723. * @returns the input friendly name
  67724. */
  67725. getSimpleName(): string;
  67726. /**
  67727. * Attach the input controls to a specific dom element to get the input from.
  67728. * @param element Defines the element the controls should be listened from
  67729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67730. */
  67731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67732. /**
  67733. * Detach the current controls from the specified dom element.
  67734. * @param element Defines the element to stop listening the inputs from
  67735. */
  67736. detachControl(element: Nullable<HTMLElement>): void;
  67737. /**
  67738. * Update the current camera state depending on the inputs that have been used this frame.
  67739. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67740. */
  67741. checkInputs?: () => void;
  67742. }
  67743. /**
  67744. * Represents a map of input types to input instance or input index to input instance.
  67745. */
  67746. export interface CameraInputsMap<TCamera extends Camera> {
  67747. /**
  67748. * Accessor to the input by input type.
  67749. */
  67750. [name: string]: ICameraInput<TCamera>;
  67751. /**
  67752. * Accessor to the input by input index.
  67753. */
  67754. [idx: number]: ICameraInput<TCamera>;
  67755. }
  67756. /**
  67757. * This represents the input manager used within a camera.
  67758. * It helps dealing with all the different kind of input attached to a camera.
  67759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67760. */
  67761. export class CameraInputsManager<TCamera extends Camera> {
  67762. /**
  67763. * Defines the list of inputs attahed to the camera.
  67764. */
  67765. attached: CameraInputsMap<TCamera>;
  67766. /**
  67767. * Defines the dom element the camera is collecting inputs from.
  67768. * This is null if the controls have not been attached.
  67769. */
  67770. attachedElement: Nullable<HTMLElement>;
  67771. /**
  67772. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67773. */
  67774. noPreventDefault: boolean;
  67775. /**
  67776. * Defined the camera the input manager belongs to.
  67777. */
  67778. camera: TCamera;
  67779. /**
  67780. * Update the current camera state depending on the inputs that have been used this frame.
  67781. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67782. */
  67783. checkInputs: () => void;
  67784. /**
  67785. * Instantiate a new Camera Input Manager.
  67786. * @param camera Defines the camera the input manager blongs to
  67787. */
  67788. constructor(camera: TCamera);
  67789. /**
  67790. * Add an input method to a camera
  67791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67792. * @param input camera input method
  67793. */
  67794. add(input: ICameraInput<TCamera>): void;
  67795. /**
  67796. * Remove a specific input method from a camera
  67797. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  67798. * @param inputToRemove camera input method
  67799. */
  67800. remove(inputToRemove: ICameraInput<TCamera>): void;
  67801. /**
  67802. * Remove a specific input type from a camera
  67803. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  67804. * @param inputType the type of the input to remove
  67805. */
  67806. removeByType(inputType: string): void;
  67807. private _addCheckInputs;
  67808. /**
  67809. * Attach the input controls to the currently attached dom element to listen the events from.
  67810. * @param input Defines the input to attach
  67811. */
  67812. attachInput(input: ICameraInput<TCamera>): void;
  67813. /**
  67814. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  67815. * @param element Defines the dom element to collect the events from
  67816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67817. */
  67818. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  67819. /**
  67820. * Detach the current manager inputs controls from a specific dom element.
  67821. * @param element Defines the dom element to collect the events from
  67822. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  67823. */
  67824. detachElement(element: HTMLElement, disconnect?: boolean): void;
  67825. /**
  67826. * Rebuild the dynamic inputCheck function from the current list of
  67827. * defined inputs in the manager.
  67828. */
  67829. rebuildInputCheck(): void;
  67830. /**
  67831. * Remove all attached input methods from a camera
  67832. */
  67833. clear(): void;
  67834. /**
  67835. * Serialize the current input manager attached to a camera.
  67836. * This ensures than once parsed,
  67837. * the input associated to the camera will be identical to the current ones
  67838. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  67839. */
  67840. serialize(serializedCamera: any): void;
  67841. /**
  67842. * Parses an input manager serialized JSON to restore the previous list of inputs
  67843. * and states associated to a camera.
  67844. * @param parsedCamera Defines the JSON to parse
  67845. */
  67846. parse(parsedCamera: any): void;
  67847. }
  67848. }
  67849. declare module BABYLON {
  67850. /**
  67851. * Gather the list of keyboard event types as constants.
  67852. */
  67853. export class KeyboardEventTypes {
  67854. /**
  67855. * The keydown event is fired when a key becomes active (pressed).
  67856. */
  67857. static readonly KEYDOWN: number;
  67858. /**
  67859. * The keyup event is fired when a key has been released.
  67860. */
  67861. static readonly KEYUP: number;
  67862. }
  67863. /**
  67864. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67865. */
  67866. export class KeyboardInfo {
  67867. /**
  67868. * Defines the type of event (KeyboardEventTypes)
  67869. */
  67870. type: number;
  67871. /**
  67872. * Defines the related dom event
  67873. */
  67874. event: KeyboardEvent;
  67875. /**
  67876. * Instantiates a new keyboard info.
  67877. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67878. * @param type Defines the type of event (KeyboardEventTypes)
  67879. * @param event Defines the related dom event
  67880. */
  67881. constructor(
  67882. /**
  67883. * Defines the type of event (KeyboardEventTypes)
  67884. */
  67885. type: number,
  67886. /**
  67887. * Defines the related dom event
  67888. */
  67889. event: KeyboardEvent);
  67890. }
  67891. /**
  67892. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67893. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  67894. */
  67895. export class KeyboardInfoPre extends KeyboardInfo {
  67896. /**
  67897. * Defines the type of event (KeyboardEventTypes)
  67898. */
  67899. type: number;
  67900. /**
  67901. * Defines the related dom event
  67902. */
  67903. event: KeyboardEvent;
  67904. /**
  67905. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  67906. */
  67907. skipOnPointerObservable: boolean;
  67908. /**
  67909. * Instantiates a new keyboard pre info.
  67910. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67911. * @param type Defines the type of event (KeyboardEventTypes)
  67912. * @param event Defines the related dom event
  67913. */
  67914. constructor(
  67915. /**
  67916. * Defines the type of event (KeyboardEventTypes)
  67917. */
  67918. type: number,
  67919. /**
  67920. * Defines the related dom event
  67921. */
  67922. event: KeyboardEvent);
  67923. }
  67924. }
  67925. declare module BABYLON {
  67926. /**
  67927. * Manage the keyboard inputs to control the movement of a free camera.
  67928. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67929. */
  67930. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  67931. /**
  67932. * Defines the camera the input is attached to.
  67933. */
  67934. camera: FreeCamera;
  67935. /**
  67936. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  67937. */
  67938. keysUp: number[];
  67939. /**
  67940. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  67941. */
  67942. keysDown: number[];
  67943. /**
  67944. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  67945. */
  67946. keysLeft: number[];
  67947. /**
  67948. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  67949. */
  67950. keysRight: number[];
  67951. private _keys;
  67952. private _onCanvasBlurObserver;
  67953. private _onKeyboardObserver;
  67954. private _engine;
  67955. private _scene;
  67956. /**
  67957. * Attach the input controls to a specific dom element to get the input from.
  67958. * @param element Defines the element the controls should be listened from
  67959. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67960. */
  67961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67962. /**
  67963. * Detach the current controls from the specified dom element.
  67964. * @param element Defines the element to stop listening the inputs from
  67965. */
  67966. detachControl(element: Nullable<HTMLElement>): void;
  67967. /**
  67968. * Update the current camera state depending on the inputs that have been used this frame.
  67969. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67970. */
  67971. checkInputs(): void;
  67972. /**
  67973. * Gets the class name of the current intput.
  67974. * @returns the class name
  67975. */
  67976. getClassName(): string;
  67977. /** @hidden */
  67978. _onLostFocus(): void;
  67979. /**
  67980. * Get the friendly name associated with the input class.
  67981. * @returns the input friendly name
  67982. */
  67983. getSimpleName(): string;
  67984. }
  67985. }
  67986. declare module BABYLON {
  67987. /**
  67988. * Interface describing all the common properties and methods a shadow light needs to implement.
  67989. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  67990. * as well as binding the different shadow properties to the effects.
  67991. */
  67992. export interface IShadowLight extends Light {
  67993. /**
  67994. * The light id in the scene (used in scene.findLighById for instance)
  67995. */
  67996. id: string;
  67997. /**
  67998. * The position the shdow will be casted from.
  67999. */
  68000. position: Vector3;
  68001. /**
  68002. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68003. */
  68004. direction: Vector3;
  68005. /**
  68006. * The transformed position. Position of the light in world space taking parenting in account.
  68007. */
  68008. transformedPosition: Vector3;
  68009. /**
  68010. * The transformed direction. Direction of the light in world space taking parenting in account.
  68011. */
  68012. transformedDirection: Vector3;
  68013. /**
  68014. * The friendly name of the light in the scene.
  68015. */
  68016. name: string;
  68017. /**
  68018. * Defines the shadow projection clipping minimum z value.
  68019. */
  68020. shadowMinZ: number;
  68021. /**
  68022. * Defines the shadow projection clipping maximum z value.
  68023. */
  68024. shadowMaxZ: number;
  68025. /**
  68026. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68027. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68028. */
  68029. computeTransformedInformation(): boolean;
  68030. /**
  68031. * Gets the scene the light belongs to.
  68032. * @returns The scene
  68033. */
  68034. getScene(): Scene;
  68035. /**
  68036. * Callback defining a custom Projection Matrix Builder.
  68037. * This can be used to override the default projection matrix computation.
  68038. */
  68039. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68040. /**
  68041. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68042. * @param matrix The materix to updated with the projection information
  68043. * @param viewMatrix The transform matrix of the light
  68044. * @param renderList The list of mesh to render in the map
  68045. * @returns The current light
  68046. */
  68047. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68048. /**
  68049. * Gets the current depth scale used in ESM.
  68050. * @returns The scale
  68051. */
  68052. getDepthScale(): number;
  68053. /**
  68054. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68055. * @returns true if a cube texture needs to be use
  68056. */
  68057. needCube(): boolean;
  68058. /**
  68059. * Detects if the projection matrix requires to be recomputed this frame.
  68060. * @returns true if it requires to be recomputed otherwise, false.
  68061. */
  68062. needProjectionMatrixCompute(): boolean;
  68063. /**
  68064. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68065. */
  68066. forceProjectionMatrixCompute(): void;
  68067. /**
  68068. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68069. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68070. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68071. */
  68072. getShadowDirection(faceIndex?: number): Vector3;
  68073. /**
  68074. * Gets the minZ used for shadow according to both the scene and the light.
  68075. * @param activeCamera The camera we are returning the min for
  68076. * @returns the depth min z
  68077. */
  68078. getDepthMinZ(activeCamera: Camera): number;
  68079. /**
  68080. * Gets the maxZ used for shadow according to both the scene and the light.
  68081. * @param activeCamera The camera we are returning the max for
  68082. * @returns the depth max z
  68083. */
  68084. getDepthMaxZ(activeCamera: Camera): number;
  68085. }
  68086. /**
  68087. * Base implementation IShadowLight
  68088. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  68089. */
  68090. export abstract class ShadowLight extends Light implements IShadowLight {
  68091. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68092. protected _position: Vector3;
  68093. protected _setPosition(value: Vector3): void;
  68094. /**
  68095. * Sets the position the shadow will be casted from. Also use as the light position for both
  68096. * point and spot lights.
  68097. */
  68098. /**
  68099. * Sets the position the shadow will be casted from. Also use as the light position for both
  68100. * point and spot lights.
  68101. */
  68102. position: Vector3;
  68103. protected _direction: Vector3;
  68104. protected _setDirection(value: Vector3): void;
  68105. /**
  68106. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  68107. * Also use as the light direction on spot and directional lights.
  68108. */
  68109. /**
  68110. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  68111. * Also use as the light direction on spot and directional lights.
  68112. */
  68113. direction: Vector3;
  68114. private _shadowMinZ;
  68115. /**
  68116. * Gets the shadow projection clipping minimum z value.
  68117. */
  68118. /**
  68119. * Sets the shadow projection clipping minimum z value.
  68120. */
  68121. shadowMinZ: number;
  68122. private _shadowMaxZ;
  68123. /**
  68124. * Sets the shadow projection clipping maximum z value.
  68125. */
  68126. /**
  68127. * Gets the shadow projection clipping maximum z value.
  68128. */
  68129. shadowMaxZ: number;
  68130. /**
  68131. * Callback defining a custom Projection Matrix Builder.
  68132. * This can be used to override the default projection matrix computation.
  68133. */
  68134. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68135. /**
  68136. * The transformed position. Position of the light in world space taking parenting in account.
  68137. */
  68138. transformedPosition: Vector3;
  68139. /**
  68140. * The transformed direction. Direction of the light in world space taking parenting in account.
  68141. */
  68142. transformedDirection: Vector3;
  68143. private _needProjectionMatrixCompute;
  68144. /**
  68145. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68146. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68147. */
  68148. computeTransformedInformation(): boolean;
  68149. /**
  68150. * Return the depth scale used for the shadow map.
  68151. * @returns the depth scale.
  68152. */
  68153. getDepthScale(): number;
  68154. /**
  68155. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68156. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68157. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68158. */
  68159. getShadowDirection(faceIndex?: number): Vector3;
  68160. /**
  68161. * Returns the ShadowLight absolute position in the World.
  68162. * @returns the position vector in world space
  68163. */
  68164. getAbsolutePosition(): Vector3;
  68165. /**
  68166. * Sets the ShadowLight direction toward the passed target.
  68167. * @param target The point to target in local space
  68168. * @returns the updated ShadowLight direction
  68169. */
  68170. setDirectionToTarget(target: Vector3): Vector3;
  68171. /**
  68172. * Returns the light rotation in euler definition.
  68173. * @returns the x y z rotation in local space.
  68174. */
  68175. getRotation(): Vector3;
  68176. /**
  68177. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68178. * @returns true if a cube texture needs to be use
  68179. */
  68180. needCube(): boolean;
  68181. /**
  68182. * Detects if the projection matrix requires to be recomputed this frame.
  68183. * @returns true if it requires to be recomputed otherwise, false.
  68184. */
  68185. needProjectionMatrixCompute(): boolean;
  68186. /**
  68187. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68188. */
  68189. forceProjectionMatrixCompute(): void;
  68190. /** @hidden */
  68191. _initCache(): void;
  68192. /** @hidden */
  68193. _isSynchronized(): boolean;
  68194. /**
  68195. * Computes the world matrix of the node
  68196. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68197. * @returns the world matrix
  68198. */
  68199. computeWorldMatrix(force?: boolean): Matrix;
  68200. /**
  68201. * Gets the minZ used for shadow according to both the scene and the light.
  68202. * @param activeCamera The camera we are returning the min for
  68203. * @returns the depth min z
  68204. */
  68205. getDepthMinZ(activeCamera: Camera): number;
  68206. /**
  68207. * Gets the maxZ used for shadow according to both the scene and the light.
  68208. * @param activeCamera The camera we are returning the max for
  68209. * @returns the depth max z
  68210. */
  68211. getDepthMaxZ(activeCamera: Camera): number;
  68212. /**
  68213. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68214. * @param matrix The materix to updated with the projection information
  68215. * @param viewMatrix The transform matrix of the light
  68216. * @param renderList The list of mesh to render in the map
  68217. * @returns The current light
  68218. */
  68219. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68220. }
  68221. }
  68222. declare module BABYLON {
  68223. /**
  68224. * "Static Class" containing the most commonly used helper while dealing with material for
  68225. * rendering purpose.
  68226. *
  68227. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  68228. *
  68229. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  68230. */
  68231. export class MaterialHelper {
  68232. /**
  68233. * Bind the current view position to an effect.
  68234. * @param effect The effect to be bound
  68235. * @param scene The scene the eyes position is used from
  68236. */
  68237. static BindEyePosition(effect: Effect, scene: Scene): void;
  68238. /**
  68239. * Helps preparing the defines values about the UVs in used in the effect.
  68240. * UVs are shared as much as we can accross channels in the shaders.
  68241. * @param texture The texture we are preparing the UVs for
  68242. * @param defines The defines to update
  68243. * @param key The channel key "diffuse", "specular"... used in the shader
  68244. */
  68245. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  68246. /**
  68247. * Binds a texture matrix value to its corrsponding uniform
  68248. * @param texture The texture to bind the matrix for
  68249. * @param uniformBuffer The uniform buffer receivin the data
  68250. * @param key The channel key "diffuse", "specular"... used in the shader
  68251. */
  68252. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  68253. /**
  68254. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  68255. * @param mesh defines the current mesh
  68256. * @param scene defines the current scene
  68257. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  68258. * @param pointsCloud defines if point cloud rendering has to be turned on
  68259. * @param fogEnabled defines if fog has to be turned on
  68260. * @param alphaTest defines if alpha testing has to be turned on
  68261. * @param defines defines the current list of defines
  68262. */
  68263. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  68264. /**
  68265. * Helper used to prepare the list of defines associated with frame values for shader compilation
  68266. * @param scene defines the current scene
  68267. * @param engine defines the current engine
  68268. * @param defines specifies the list of active defines
  68269. * @param useInstances defines if instances have to be turned on
  68270. * @param useClipPlane defines if clip plane have to be turned on
  68271. */
  68272. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  68273. /**
  68274. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  68275. * @param mesh The mesh containing the geometry data we will draw
  68276. * @param defines The defines to update
  68277. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  68278. * @param useBones Precise whether bones should be used or not (override mesh info)
  68279. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  68280. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  68281. * @returns false if defines are considered not dirty and have not been checked
  68282. */
  68283. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  68284. /**
  68285. * Prepares the defines related to multiview
  68286. * @param scene The scene we are intending to draw
  68287. * @param defines The defines to update
  68288. */
  68289. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  68290. /**
  68291. * Prepares the defines related to the light information passed in parameter
  68292. * @param scene The scene we are intending to draw
  68293. * @param mesh The mesh the effect is compiling for
  68294. * @param defines The defines to update
  68295. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  68296. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  68297. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  68298. * @returns true if normals will be required for the rest of the effect
  68299. */
  68300. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  68301. /**
  68302. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  68303. * that won t be acctive due to defines being turned off.
  68304. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  68305. * @param samplersList The samplers list
  68306. * @param defines The defines helping in the list generation
  68307. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  68308. */
  68309. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  68310. /**
  68311. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  68312. * @param defines The defines to update while falling back
  68313. * @param fallbacks The authorized effect fallbacks
  68314. * @param maxSimultaneousLights The maximum number of lights allowed
  68315. * @param rank the current rank of the Effect
  68316. * @returns The newly affected rank
  68317. */
  68318. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  68319. /**
  68320. * Prepares the list of attributes required for morph targets according to the effect defines.
  68321. * @param attribs The current list of supported attribs
  68322. * @param mesh The mesh to prepare the morph targets attributes for
  68323. * @param defines The current Defines of the effect
  68324. */
  68325. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  68326. /**
  68327. * Prepares the list of attributes required for bones according to the effect defines.
  68328. * @param attribs The current list of supported attribs
  68329. * @param mesh The mesh to prepare the bones attributes for
  68330. * @param defines The current Defines of the effect
  68331. * @param fallbacks The current efffect fallback strategy
  68332. */
  68333. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  68334. /**
  68335. * Prepares the list of attributes required for instances according to the effect defines.
  68336. * @param attribs The current list of supported attribs
  68337. * @param defines The current Defines of the effect
  68338. */
  68339. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  68340. /**
  68341. * Binds the light shadow information to the effect for the given mesh.
  68342. * @param light The light containing the generator
  68343. * @param scene The scene the lights belongs to
  68344. * @param mesh The mesh we are binding the information to render
  68345. * @param lightIndex The light index in the effect used to render the mesh
  68346. * @param effect The effect we are binding the data to
  68347. */
  68348. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  68349. /**
  68350. * Binds the light information to the effect.
  68351. * @param light The light containing the generator
  68352. * @param effect The effect we are binding the data to
  68353. * @param lightIndex The light index in the effect used to render
  68354. */
  68355. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  68356. /**
  68357. * Binds the lights information from the scene to the effect for the given mesh.
  68358. * @param scene The scene the lights belongs to
  68359. * @param mesh The mesh we are binding the information to render
  68360. * @param effect The effect we are binding the data to
  68361. * @param defines The generated defines for the effect
  68362. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  68363. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  68364. */
  68365. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  68366. private static _tempFogColor;
  68367. /**
  68368. * Binds the fog information from the scene to the effect for the given mesh.
  68369. * @param scene The scene the lights belongs to
  68370. * @param mesh The mesh we are binding the information to render
  68371. * @param effect The effect we are binding the data to
  68372. * @param linearSpace Defines if the fog effect is applied in linear space
  68373. */
  68374. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  68375. /**
  68376. * Binds the bones information from the mesh to the effect.
  68377. * @param mesh The mesh we are binding the information to render
  68378. * @param effect The effect we are binding the data to
  68379. */
  68380. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  68381. /**
  68382. * Binds the morph targets information from the mesh to the effect.
  68383. * @param abstractMesh The mesh we are binding the information to render
  68384. * @param effect The effect we are binding the data to
  68385. */
  68386. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  68387. /**
  68388. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  68389. * @param defines The generated defines used in the effect
  68390. * @param effect The effect we are binding the data to
  68391. * @param scene The scene we are willing to render with logarithmic scale for
  68392. */
  68393. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  68394. /**
  68395. * Binds the clip plane information from the scene to the effect.
  68396. * @param scene The scene the clip plane information are extracted from
  68397. * @param effect The effect we are binding the data to
  68398. */
  68399. static BindClipPlane(effect: Effect, scene: Scene): void;
  68400. }
  68401. }
  68402. declare module BABYLON {
  68403. /** @hidden */
  68404. export var kernelBlurVaryingDeclaration: {
  68405. name: string;
  68406. shader: string;
  68407. };
  68408. }
  68409. declare module BABYLON {
  68410. /** @hidden */
  68411. export var kernelBlurFragment: {
  68412. name: string;
  68413. shader: string;
  68414. };
  68415. }
  68416. declare module BABYLON {
  68417. /** @hidden */
  68418. export var kernelBlurFragment2: {
  68419. name: string;
  68420. shader: string;
  68421. };
  68422. }
  68423. declare module BABYLON {
  68424. /** @hidden */
  68425. export var kernelBlurPixelShader: {
  68426. name: string;
  68427. shader: string;
  68428. };
  68429. }
  68430. declare module BABYLON {
  68431. /** @hidden */
  68432. export var kernelBlurVertex: {
  68433. name: string;
  68434. shader: string;
  68435. };
  68436. }
  68437. declare module BABYLON {
  68438. /** @hidden */
  68439. export var kernelBlurVertexShader: {
  68440. name: string;
  68441. shader: string;
  68442. };
  68443. }
  68444. declare module BABYLON {
  68445. /**
  68446. * The Blur Post Process which blurs an image based on a kernel and direction.
  68447. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  68448. */
  68449. export class BlurPostProcess extends PostProcess {
  68450. /** The direction in which to blur the image. */
  68451. direction: Vector2;
  68452. private blockCompilation;
  68453. protected _kernel: number;
  68454. protected _idealKernel: number;
  68455. protected _packedFloat: boolean;
  68456. private _staticDefines;
  68457. /**
  68458. * Sets the length in pixels of the blur sample region
  68459. */
  68460. /**
  68461. * Gets the length in pixels of the blur sample region
  68462. */
  68463. kernel: number;
  68464. /**
  68465. * Sets wether or not the blur needs to unpack/repack floats
  68466. */
  68467. /**
  68468. * Gets wether or not the blur is unpacking/repacking floats
  68469. */
  68470. packedFloat: boolean;
  68471. /**
  68472. * Creates a new instance BlurPostProcess
  68473. * @param name The name of the effect.
  68474. * @param direction The direction in which to blur the image.
  68475. * @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.
  68476. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68477. * @param camera The camera to apply the render pass to.
  68478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68479. * @param engine The engine which the post process will be applied. (default: current engine)
  68480. * @param reusable If the post process can be reused on the same frame. (default: false)
  68481. * @param textureType Type of textures used when performing the post process. (default: 0)
  68482. * @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)
  68483. */
  68484. constructor(name: string,
  68485. /** The direction in which to blur the image. */
  68486. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68487. /**
  68488. * Updates the effect with the current post process compile time values and recompiles the shader.
  68489. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68490. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68491. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68492. * @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
  68493. * @param onCompiled Called when the shader has been compiled.
  68494. * @param onError Called if there is an error when compiling a shader.
  68495. */
  68496. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68497. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68498. /**
  68499. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68500. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68501. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68502. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68503. * The gaps between physical kernels are compensated for in the weighting of the samples
  68504. * @param idealKernel Ideal blur kernel.
  68505. * @return Nearest best kernel.
  68506. */
  68507. protected _nearestBestKernel(idealKernel: number): number;
  68508. /**
  68509. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68510. * @param x The point on the Gaussian distribution to sample.
  68511. * @return the value of the Gaussian function at x.
  68512. */
  68513. protected _gaussianWeight(x: number): number;
  68514. /**
  68515. * Generates a string that can be used as a floating point number in GLSL.
  68516. * @param x Value to print.
  68517. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68518. * @return GLSL float string.
  68519. */
  68520. protected _glslFloat(x: number, decimalFigures?: number): string;
  68521. }
  68522. }
  68523. declare module BABYLON {
  68524. /** @hidden */
  68525. export var shadowMapPixelShader: {
  68526. name: string;
  68527. shader: string;
  68528. };
  68529. }
  68530. declare module BABYLON {
  68531. /** @hidden */
  68532. export var bonesDeclaration: {
  68533. name: string;
  68534. shader: string;
  68535. };
  68536. }
  68537. declare module BABYLON {
  68538. /** @hidden */
  68539. export var morphTargetsVertexGlobalDeclaration: {
  68540. name: string;
  68541. shader: string;
  68542. };
  68543. }
  68544. declare module BABYLON {
  68545. /** @hidden */
  68546. export var morphTargetsVertexDeclaration: {
  68547. name: string;
  68548. shader: string;
  68549. };
  68550. }
  68551. declare module BABYLON {
  68552. /** @hidden */
  68553. export var instancesDeclaration: {
  68554. name: string;
  68555. shader: string;
  68556. };
  68557. }
  68558. declare module BABYLON {
  68559. /** @hidden */
  68560. export var helperFunctions: {
  68561. name: string;
  68562. shader: string;
  68563. };
  68564. }
  68565. declare module BABYLON {
  68566. /** @hidden */
  68567. export var morphTargetsVertex: {
  68568. name: string;
  68569. shader: string;
  68570. };
  68571. }
  68572. declare module BABYLON {
  68573. /** @hidden */
  68574. export var instancesVertex: {
  68575. name: string;
  68576. shader: string;
  68577. };
  68578. }
  68579. declare module BABYLON {
  68580. /** @hidden */
  68581. export var bonesVertex: {
  68582. name: string;
  68583. shader: string;
  68584. };
  68585. }
  68586. declare module BABYLON {
  68587. /** @hidden */
  68588. export var shadowMapVertexShader: {
  68589. name: string;
  68590. shader: string;
  68591. };
  68592. }
  68593. declare module BABYLON {
  68594. /** @hidden */
  68595. export var depthBoxBlurPixelShader: {
  68596. name: string;
  68597. shader: string;
  68598. };
  68599. }
  68600. declare module BABYLON {
  68601. /**
  68602. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68603. */
  68604. export interface ICustomShaderOptions {
  68605. /**
  68606. * Gets or sets the custom shader name to use
  68607. */
  68608. shaderName: string;
  68609. /**
  68610. * The list of attribute names used in the shader
  68611. */
  68612. attributes?: string[];
  68613. /**
  68614. * The list of unifrom names used in the shader
  68615. */
  68616. uniforms?: string[];
  68617. /**
  68618. * The list of sampler names used in the shader
  68619. */
  68620. samplers?: string[];
  68621. /**
  68622. * The list of defines used in the shader
  68623. */
  68624. defines?: string[];
  68625. }
  68626. /**
  68627. * Interface to implement to create a shadow generator compatible with BJS.
  68628. */
  68629. export interface IShadowGenerator {
  68630. /**
  68631. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68632. * @returns The render target texture if present otherwise, null
  68633. */
  68634. getShadowMap(): Nullable<RenderTargetTexture>;
  68635. /**
  68636. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68637. * @returns The render target texture if the shadow map is present otherwise, null
  68638. */
  68639. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68640. /**
  68641. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68642. * @param subMesh The submesh we want to render in the shadow map
  68643. * @param useInstances Defines wether will draw in the map using instances
  68644. * @returns true if ready otherwise, false
  68645. */
  68646. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68647. /**
  68648. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68649. * @param defines Defines of the material we want to update
  68650. * @param lightIndex Index of the light in the enabled light list of the material
  68651. */
  68652. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68653. /**
  68654. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68655. * defined in the generator but impacting the effect).
  68656. * It implies the unifroms available on the materials are the standard BJS ones.
  68657. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68658. * @param effect The effect we are binfing the information for
  68659. */
  68660. bindShadowLight(lightIndex: string, effect: Effect): void;
  68661. /**
  68662. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68663. * (eq to shadow prjection matrix * light transform matrix)
  68664. * @returns The transform matrix used to create the shadow map
  68665. */
  68666. getTransformMatrix(): Matrix;
  68667. /**
  68668. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68669. * Cube and 2D textures for instance.
  68670. */
  68671. recreateShadowMap(): void;
  68672. /**
  68673. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68674. * @param onCompiled Callback triggered at the and of the effects compilation
  68675. * @param options Sets of optional options forcing the compilation with different modes
  68676. */
  68677. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68678. useInstances: boolean;
  68679. }>): void;
  68680. /**
  68681. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68682. * @param options Sets of optional options forcing the compilation with different modes
  68683. * @returns A promise that resolves when the compilation completes
  68684. */
  68685. forceCompilationAsync(options?: Partial<{
  68686. useInstances: boolean;
  68687. }>): Promise<void>;
  68688. /**
  68689. * Serializes the shadow generator setup to a json object.
  68690. * @returns The serialized JSON object
  68691. */
  68692. serialize(): any;
  68693. /**
  68694. * Disposes the Shadow map and related Textures and effects.
  68695. */
  68696. dispose(): void;
  68697. }
  68698. /**
  68699. * Default implementation IShadowGenerator.
  68700. * This is the main object responsible of generating shadows in the framework.
  68701. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  68702. */
  68703. export class ShadowGenerator implements IShadowGenerator {
  68704. /**
  68705. * Shadow generator mode None: no filtering applied.
  68706. */
  68707. static readonly FILTER_NONE: number;
  68708. /**
  68709. * Shadow generator mode ESM: Exponential Shadow Mapping.
  68710. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68711. */
  68712. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  68713. /**
  68714. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  68715. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  68716. */
  68717. static readonly FILTER_POISSONSAMPLING: number;
  68718. /**
  68719. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  68720. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68721. */
  68722. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  68723. /**
  68724. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  68725. * edge artifacts on steep falloff.
  68726. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68727. */
  68728. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  68729. /**
  68730. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  68731. * edge artifacts on steep falloff.
  68732. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68733. */
  68734. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  68735. /**
  68736. * Shadow generator mode PCF: Percentage Closer Filtering
  68737. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68738. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  68739. */
  68740. static readonly FILTER_PCF: number;
  68741. /**
  68742. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  68743. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68744. * Contact Hardening
  68745. */
  68746. static readonly FILTER_PCSS: number;
  68747. /**
  68748. * Reserved for PCF and PCSS
  68749. * Highest Quality.
  68750. *
  68751. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  68752. *
  68753. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  68754. */
  68755. static readonly QUALITY_HIGH: number;
  68756. /**
  68757. * Reserved for PCF and PCSS
  68758. * Good tradeoff for quality/perf cross devices
  68759. *
  68760. * Execute PCF on a 3*3 kernel.
  68761. *
  68762. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  68763. */
  68764. static readonly QUALITY_MEDIUM: number;
  68765. /**
  68766. * Reserved for PCF and PCSS
  68767. * The lowest quality but the fastest.
  68768. *
  68769. * Execute PCF on a 1*1 kernel.
  68770. *
  68771. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  68772. */
  68773. static readonly QUALITY_LOW: number;
  68774. /** Gets or sets the custom shader name to use */
  68775. customShaderOptions: ICustomShaderOptions;
  68776. /**
  68777. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  68778. */
  68779. onBeforeShadowMapRenderObservable: Observable<Effect>;
  68780. /**
  68781. * Observable triggered before a mesh is rendered in the shadow map.
  68782. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  68783. */
  68784. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  68785. private _bias;
  68786. /**
  68787. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  68788. */
  68789. /**
  68790. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  68791. */
  68792. bias: number;
  68793. private _normalBias;
  68794. /**
  68795. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68796. */
  68797. /**
  68798. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68799. */
  68800. normalBias: number;
  68801. private _blurBoxOffset;
  68802. /**
  68803. * Gets the blur box offset: offset applied during the blur pass.
  68804. * Only useful if useKernelBlur = false
  68805. */
  68806. /**
  68807. * Sets the blur box offset: offset applied during the blur pass.
  68808. * Only useful if useKernelBlur = false
  68809. */
  68810. blurBoxOffset: number;
  68811. private _blurScale;
  68812. /**
  68813. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  68814. * 2 means half of the size.
  68815. */
  68816. /**
  68817. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  68818. * 2 means half of the size.
  68819. */
  68820. blurScale: number;
  68821. private _blurKernel;
  68822. /**
  68823. * Gets the blur kernel: kernel size of the blur pass.
  68824. * Only useful if useKernelBlur = true
  68825. */
  68826. /**
  68827. * Sets the blur kernel: kernel size of the blur pass.
  68828. * Only useful if useKernelBlur = true
  68829. */
  68830. blurKernel: number;
  68831. private _useKernelBlur;
  68832. /**
  68833. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  68834. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68835. */
  68836. /**
  68837. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  68838. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68839. */
  68840. useKernelBlur: boolean;
  68841. private _depthScale;
  68842. /**
  68843. * Gets the depth scale used in ESM mode.
  68844. */
  68845. /**
  68846. * Sets the depth scale used in ESM mode.
  68847. * This can override the scale stored on the light.
  68848. */
  68849. depthScale: number;
  68850. private _filter;
  68851. /**
  68852. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  68853. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68854. */
  68855. /**
  68856. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  68857. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68858. */
  68859. filter: number;
  68860. /**
  68861. * Gets if the current filter is set to Poisson Sampling.
  68862. */
  68863. /**
  68864. * Sets the current filter to Poisson Sampling.
  68865. */
  68866. usePoissonSampling: boolean;
  68867. /**
  68868. * Gets if the current filter is set to ESM.
  68869. */
  68870. /**
  68871. * Sets the current filter is to ESM.
  68872. */
  68873. useExponentialShadowMap: boolean;
  68874. /**
  68875. * Gets if the current filter is set to filtered ESM.
  68876. */
  68877. /**
  68878. * Gets if the current filter is set to filtered ESM.
  68879. */
  68880. useBlurExponentialShadowMap: boolean;
  68881. /**
  68882. * Gets if the current filter is set to "close ESM" (using the inverse of the
  68883. * exponential to prevent steep falloff artifacts).
  68884. */
  68885. /**
  68886. * Sets the current filter to "close ESM" (using the inverse of the
  68887. * exponential to prevent steep falloff artifacts).
  68888. */
  68889. useCloseExponentialShadowMap: boolean;
  68890. /**
  68891. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  68892. * exponential to prevent steep falloff artifacts).
  68893. */
  68894. /**
  68895. * Sets the current filter to filtered "close ESM" (using the inverse of the
  68896. * exponential to prevent steep falloff artifacts).
  68897. */
  68898. useBlurCloseExponentialShadowMap: boolean;
  68899. /**
  68900. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  68901. */
  68902. /**
  68903. * Sets the current filter to "PCF" (percentage closer filtering).
  68904. */
  68905. usePercentageCloserFiltering: boolean;
  68906. private _filteringQuality;
  68907. /**
  68908. * Gets the PCF or PCSS Quality.
  68909. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68910. */
  68911. /**
  68912. * Sets the PCF or PCSS Quality.
  68913. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68914. */
  68915. filteringQuality: number;
  68916. /**
  68917. * Gets if the current filter is set to "PCSS" (contact hardening).
  68918. */
  68919. /**
  68920. * Sets the current filter to "PCSS" (contact hardening).
  68921. */
  68922. useContactHardeningShadow: boolean;
  68923. private _contactHardeningLightSizeUVRatio;
  68924. /**
  68925. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68926. * Using a ratio helps keeping shape stability independently of the map size.
  68927. *
  68928. * It does not account for the light projection as it was having too much
  68929. * instability during the light setup or during light position changes.
  68930. *
  68931. * Only valid if useContactHardeningShadow is true.
  68932. */
  68933. /**
  68934. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68935. * Using a ratio helps keeping shape stability independently of the map size.
  68936. *
  68937. * It does not account for the light projection as it was having too much
  68938. * instability during the light setup or during light position changes.
  68939. *
  68940. * Only valid if useContactHardeningShadow is true.
  68941. */
  68942. contactHardeningLightSizeUVRatio: number;
  68943. private _darkness;
  68944. /**
  68945. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  68946. * 0 means strongest and 1 would means no shadow.
  68947. * @returns the darkness.
  68948. */
  68949. getDarkness(): number;
  68950. /**
  68951. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  68952. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  68953. * @returns the shadow generator allowing fluent coding.
  68954. */
  68955. setDarkness(darkness: number): ShadowGenerator;
  68956. private _transparencyShadow;
  68957. /**
  68958. * Sets the ability to have transparent shadow (boolean).
  68959. * @param transparent True if transparent else False
  68960. * @returns the shadow generator allowing fluent coding
  68961. */
  68962. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  68963. private _shadowMap;
  68964. private _shadowMap2;
  68965. /**
  68966. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68967. * @returns The render target texture if present otherwise, null
  68968. */
  68969. getShadowMap(): Nullable<RenderTargetTexture>;
  68970. /**
  68971. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68972. * @returns The render target texture if the shadow map is present otherwise, null
  68973. */
  68974. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68975. /**
  68976. * Helper function to add a mesh and its descendants to the list of shadow casters.
  68977. * @param mesh Mesh to add
  68978. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  68979. * @returns the Shadow Generator itself
  68980. */
  68981. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68982. /**
  68983. * Helper function to remove a mesh and its descendants from the list of shadow casters
  68984. * @param mesh Mesh to remove
  68985. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  68986. * @returns the Shadow Generator itself
  68987. */
  68988. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68989. /**
  68990. * Controls the extent to which the shadows fade out at the edge of the frustum
  68991. * Used only by directionals and spots
  68992. */
  68993. frustumEdgeFalloff: number;
  68994. private _light;
  68995. /**
  68996. * Returns the associated light object.
  68997. * @returns the light generating the shadow
  68998. */
  68999. getLight(): IShadowLight;
  69000. /**
  69001. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69002. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69003. * It might on the other hand introduce peter panning.
  69004. */
  69005. forceBackFacesOnly: boolean;
  69006. private _scene;
  69007. private _lightDirection;
  69008. private _effect;
  69009. private _viewMatrix;
  69010. private _projectionMatrix;
  69011. private _transformMatrix;
  69012. private _cachedPosition;
  69013. private _cachedDirection;
  69014. private _cachedDefines;
  69015. private _currentRenderID;
  69016. private _boxBlurPostprocess;
  69017. private _kernelBlurXPostprocess;
  69018. private _kernelBlurYPostprocess;
  69019. private _blurPostProcesses;
  69020. private _mapSize;
  69021. private _currentFaceIndex;
  69022. private _currentFaceIndexCache;
  69023. private _textureType;
  69024. private _defaultTextureMatrix;
  69025. /** @hidden */
  69026. static _SceneComponentInitialization: (scene: Scene) => void;
  69027. /**
  69028. * Creates a ShadowGenerator object.
  69029. * A ShadowGenerator is the required tool to use the shadows.
  69030. * Each light casting shadows needs to use its own ShadowGenerator.
  69031. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69032. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69033. * @param light The light object generating the shadows.
  69034. * @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.
  69035. */
  69036. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69037. private _initializeGenerator;
  69038. private _initializeShadowMap;
  69039. private _initializeBlurRTTAndPostProcesses;
  69040. private _renderForShadowMap;
  69041. private _renderSubMeshForShadowMap;
  69042. private _applyFilterValues;
  69043. /**
  69044. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69045. * @param onCompiled Callback triggered at the and of the effects compilation
  69046. * @param options Sets of optional options forcing the compilation with different modes
  69047. */
  69048. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69049. useInstances: boolean;
  69050. }>): void;
  69051. /**
  69052. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69053. * @param options Sets of optional options forcing the compilation with different modes
  69054. * @returns A promise that resolves when the compilation completes
  69055. */
  69056. forceCompilationAsync(options?: Partial<{
  69057. useInstances: boolean;
  69058. }>): Promise<void>;
  69059. /**
  69060. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69061. * @param subMesh The submesh we want to render in the shadow map
  69062. * @param useInstances Defines wether will draw in the map using instances
  69063. * @returns true if ready otherwise, false
  69064. */
  69065. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69066. /**
  69067. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69068. * @param defines Defines of the material we want to update
  69069. * @param lightIndex Index of the light in the enabled light list of the material
  69070. */
  69071. prepareDefines(defines: any, lightIndex: number): void;
  69072. /**
  69073. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69074. * defined in the generator but impacting the effect).
  69075. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69076. * @param effect The effect we are binfing the information for
  69077. */
  69078. bindShadowLight(lightIndex: string, effect: Effect): void;
  69079. /**
  69080. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69081. * (eq to shadow prjection matrix * light transform matrix)
  69082. * @returns The transform matrix used to create the shadow map
  69083. */
  69084. getTransformMatrix(): Matrix;
  69085. /**
  69086. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69087. * Cube and 2D textures for instance.
  69088. */
  69089. recreateShadowMap(): void;
  69090. private _disposeBlurPostProcesses;
  69091. private _disposeRTTandPostProcesses;
  69092. /**
  69093. * Disposes the ShadowGenerator.
  69094. * Returns nothing.
  69095. */
  69096. dispose(): void;
  69097. /**
  69098. * Serializes the shadow generator setup to a json object.
  69099. * @returns The serialized JSON object
  69100. */
  69101. serialize(): any;
  69102. /**
  69103. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  69104. * @param parsedShadowGenerator The JSON object to parse
  69105. * @param scene The scene to create the shadow map for
  69106. * @returns The parsed shadow generator
  69107. */
  69108. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  69109. }
  69110. }
  69111. declare module BABYLON {
  69112. /**
  69113. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  69114. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  69115. * 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.
  69116. */
  69117. export abstract class Light extends Node {
  69118. /**
  69119. * Falloff Default: light is falling off following the material specification:
  69120. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  69121. */
  69122. static readonly FALLOFF_DEFAULT: number;
  69123. /**
  69124. * Falloff Physical: light is falling off following the inverse squared distance law.
  69125. */
  69126. static readonly FALLOFF_PHYSICAL: number;
  69127. /**
  69128. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  69129. * to enhance interoperability with other engines.
  69130. */
  69131. static readonly FALLOFF_GLTF: number;
  69132. /**
  69133. * Falloff Standard: light is falling off like in the standard material
  69134. * to enhance interoperability with other materials.
  69135. */
  69136. static readonly FALLOFF_STANDARD: number;
  69137. /**
  69138. * If every light affecting the material is in this lightmapMode,
  69139. * material.lightmapTexture adds or multiplies
  69140. * (depends on material.useLightmapAsShadowmap)
  69141. * after every other light calculations.
  69142. */
  69143. static readonly LIGHTMAP_DEFAULT: number;
  69144. /**
  69145. * material.lightmapTexture as only diffuse lighting from this light
  69146. * adds only specular lighting from this light
  69147. * adds dynamic shadows
  69148. */
  69149. static readonly LIGHTMAP_SPECULAR: number;
  69150. /**
  69151. * material.lightmapTexture as only lighting
  69152. * no light calculation from this light
  69153. * only adds dynamic shadows from this light
  69154. */
  69155. static readonly LIGHTMAP_SHADOWSONLY: number;
  69156. /**
  69157. * Each light type uses the default quantity according to its type:
  69158. * point/spot lights use luminous intensity
  69159. * directional lights use illuminance
  69160. */
  69161. static readonly INTENSITYMODE_AUTOMATIC: number;
  69162. /**
  69163. * lumen (lm)
  69164. */
  69165. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  69166. /**
  69167. * candela (lm/sr)
  69168. */
  69169. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  69170. /**
  69171. * lux (lm/m^2)
  69172. */
  69173. static readonly INTENSITYMODE_ILLUMINANCE: number;
  69174. /**
  69175. * nit (cd/m^2)
  69176. */
  69177. static readonly INTENSITYMODE_LUMINANCE: number;
  69178. /**
  69179. * Light type const id of the point light.
  69180. */
  69181. static readonly LIGHTTYPEID_POINTLIGHT: number;
  69182. /**
  69183. * Light type const id of the directional light.
  69184. */
  69185. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  69186. /**
  69187. * Light type const id of the spot light.
  69188. */
  69189. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  69190. /**
  69191. * Light type const id of the hemispheric light.
  69192. */
  69193. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  69194. /**
  69195. * Diffuse gives the basic color to an object.
  69196. */
  69197. diffuse: Color3;
  69198. /**
  69199. * Specular produces a highlight color on an object.
  69200. * Note: This is note affecting PBR materials.
  69201. */
  69202. specular: Color3;
  69203. /**
  69204. * Defines the falloff type for this light. This lets overrriding how punctual light are
  69205. * falling off base on range or angle.
  69206. * This can be set to any values in Light.FALLOFF_x.
  69207. *
  69208. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  69209. * other types of materials.
  69210. */
  69211. falloffType: number;
  69212. /**
  69213. * Strength of the light.
  69214. * Note: By default it is define in the framework own unit.
  69215. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  69216. */
  69217. intensity: number;
  69218. private _range;
  69219. protected _inverseSquaredRange: number;
  69220. /**
  69221. * Defines how far from the source the light is impacting in scene units.
  69222. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69223. */
  69224. /**
  69225. * Defines how far from the source the light is impacting in scene units.
  69226. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69227. */
  69228. range: number;
  69229. /**
  69230. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  69231. * of light.
  69232. */
  69233. private _photometricScale;
  69234. private _intensityMode;
  69235. /**
  69236. * Gets the photometric scale used to interpret the intensity.
  69237. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69238. */
  69239. /**
  69240. * Sets the photometric scale used to interpret the intensity.
  69241. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69242. */
  69243. intensityMode: number;
  69244. private _radius;
  69245. /**
  69246. * Gets the light radius used by PBR Materials to simulate soft area lights.
  69247. */
  69248. /**
  69249. * sets the light radius used by PBR Materials to simulate soft area lights.
  69250. */
  69251. radius: number;
  69252. private _renderPriority;
  69253. /**
  69254. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  69255. * exceeding the number allowed of the materials.
  69256. */
  69257. renderPriority: number;
  69258. private _shadowEnabled;
  69259. /**
  69260. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69261. * the current shadow generator.
  69262. */
  69263. /**
  69264. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69265. * the current shadow generator.
  69266. */
  69267. shadowEnabled: boolean;
  69268. private _includedOnlyMeshes;
  69269. /**
  69270. * Gets the only meshes impacted by this light.
  69271. */
  69272. /**
  69273. * Sets the only meshes impacted by this light.
  69274. */
  69275. includedOnlyMeshes: AbstractMesh[];
  69276. private _excludedMeshes;
  69277. /**
  69278. * Gets the meshes not impacted by this light.
  69279. */
  69280. /**
  69281. * Sets the meshes not impacted by this light.
  69282. */
  69283. excludedMeshes: AbstractMesh[];
  69284. private _excludeWithLayerMask;
  69285. /**
  69286. * Gets the layer id use to find what meshes are not impacted by the light.
  69287. * Inactive if 0
  69288. */
  69289. /**
  69290. * Sets the layer id use to find what meshes are not impacted by the light.
  69291. * Inactive if 0
  69292. */
  69293. excludeWithLayerMask: number;
  69294. private _includeOnlyWithLayerMask;
  69295. /**
  69296. * Gets the layer id use to find what meshes are impacted by the light.
  69297. * Inactive if 0
  69298. */
  69299. /**
  69300. * Sets the layer id use to find what meshes are impacted by the light.
  69301. * Inactive if 0
  69302. */
  69303. includeOnlyWithLayerMask: number;
  69304. private _lightmapMode;
  69305. /**
  69306. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69307. */
  69308. /**
  69309. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69310. */
  69311. lightmapMode: number;
  69312. /**
  69313. * Shadow generator associted to the light.
  69314. * @hidden Internal use only.
  69315. */
  69316. _shadowGenerator: Nullable<IShadowGenerator>;
  69317. /**
  69318. * @hidden Internal use only.
  69319. */
  69320. _excludedMeshesIds: string[];
  69321. /**
  69322. * @hidden Internal use only.
  69323. */
  69324. _includedOnlyMeshesIds: string[];
  69325. /**
  69326. * The current light unifom buffer.
  69327. * @hidden Internal use only.
  69328. */
  69329. _uniformBuffer: UniformBuffer;
  69330. /**
  69331. * Creates a Light object in the scene.
  69332. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69333. * @param name The firendly name of the light
  69334. * @param scene The scene the light belongs too
  69335. */
  69336. constructor(name: string, scene: Scene);
  69337. protected abstract _buildUniformLayout(): void;
  69338. /**
  69339. * Sets the passed Effect "effect" with the Light information.
  69340. * @param effect The effect to update
  69341. * @param lightIndex The index of the light in the effect to update
  69342. * @returns The light
  69343. */
  69344. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  69345. /**
  69346. * Returns the string "Light".
  69347. * @returns the class name
  69348. */
  69349. getClassName(): string;
  69350. /** @hidden */
  69351. readonly _isLight: boolean;
  69352. /**
  69353. * Converts the light information to a readable string for debug purpose.
  69354. * @param fullDetails Supports for multiple levels of logging within scene loading
  69355. * @returns the human readable light info
  69356. */
  69357. toString(fullDetails?: boolean): string;
  69358. /** @hidden */
  69359. protected _syncParentEnabledState(): void;
  69360. /**
  69361. * Set the enabled state of this node.
  69362. * @param value - the new enabled state
  69363. */
  69364. setEnabled(value: boolean): void;
  69365. /**
  69366. * Returns the Light associated shadow generator if any.
  69367. * @return the associated shadow generator.
  69368. */
  69369. getShadowGenerator(): Nullable<IShadowGenerator>;
  69370. /**
  69371. * Returns a Vector3, the absolute light position in the World.
  69372. * @returns the world space position of the light
  69373. */
  69374. getAbsolutePosition(): Vector3;
  69375. /**
  69376. * Specifies if the light will affect the passed mesh.
  69377. * @param mesh The mesh to test against the light
  69378. * @return true the mesh is affected otherwise, false.
  69379. */
  69380. canAffectMesh(mesh: AbstractMesh): boolean;
  69381. /**
  69382. * Sort function to order lights for rendering.
  69383. * @param a First Light object to compare to second.
  69384. * @param b Second Light object to compare first.
  69385. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  69386. */
  69387. static CompareLightsPriority(a: Light, b: Light): number;
  69388. /**
  69389. * Releases resources associated with this node.
  69390. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69391. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69392. */
  69393. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69394. /**
  69395. * Returns the light type ID (integer).
  69396. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69397. */
  69398. getTypeID(): number;
  69399. /**
  69400. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  69401. * @returns the scaled intensity in intensity mode unit
  69402. */
  69403. getScaledIntensity(): number;
  69404. /**
  69405. * Returns a new Light object, named "name", from the current one.
  69406. * @param name The name of the cloned light
  69407. * @returns the new created light
  69408. */
  69409. clone(name: string): Nullable<Light>;
  69410. /**
  69411. * Serializes the current light into a Serialization object.
  69412. * @returns the serialized object.
  69413. */
  69414. serialize(): any;
  69415. /**
  69416. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  69417. * This new light is named "name" and added to the passed scene.
  69418. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  69419. * @param name The friendly name of the light
  69420. * @param scene The scene the new light will belong to
  69421. * @returns the constructor function
  69422. */
  69423. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  69424. /**
  69425. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  69426. * @param parsedLight The JSON representation of the light
  69427. * @param scene The scene to create the parsed light in
  69428. * @returns the created light after parsing
  69429. */
  69430. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  69431. private _hookArrayForExcluded;
  69432. private _hookArrayForIncludedOnly;
  69433. private _resyncMeshes;
  69434. /**
  69435. * Forces the meshes to update their light related information in their rendering used effects
  69436. * @hidden Internal Use Only
  69437. */
  69438. _markMeshesAsLightDirty(): void;
  69439. /**
  69440. * Recomputes the cached photometric scale if needed.
  69441. */
  69442. private _computePhotometricScale;
  69443. /**
  69444. * Returns the Photometric Scale according to the light type and intensity mode.
  69445. */
  69446. private _getPhotometricScale;
  69447. /**
  69448. * Reorder the light in the scene according to their defined priority.
  69449. * @hidden Internal Use Only
  69450. */
  69451. _reorderLightsInScene(): void;
  69452. /**
  69453. * Prepares the list of defines specific to the light type.
  69454. * @param defines the list of defines
  69455. * @param lightIndex defines the index of the light for the effect
  69456. */
  69457. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69458. }
  69459. }
  69460. declare module BABYLON {
  69461. /**
  69462. * Interface used to define Action
  69463. */
  69464. export interface IAction {
  69465. /**
  69466. * Trigger for the action
  69467. */
  69468. trigger: number;
  69469. /** Options of the trigger */
  69470. triggerOptions: any;
  69471. /**
  69472. * Gets the trigger parameters
  69473. * @returns the trigger parameters
  69474. */
  69475. getTriggerParameter(): any;
  69476. /**
  69477. * Internal only - executes current action event
  69478. * @hidden
  69479. */
  69480. _executeCurrent(evt?: ActionEvent): void;
  69481. /**
  69482. * Serialize placeholder for child classes
  69483. * @param parent of child
  69484. * @returns the serialized object
  69485. */
  69486. serialize(parent: any): any;
  69487. /**
  69488. * Internal only
  69489. * @hidden
  69490. */
  69491. _prepare(): void;
  69492. /**
  69493. * Internal only - manager for action
  69494. * @hidden
  69495. */
  69496. _actionManager: AbstractActionManager;
  69497. }
  69498. /**
  69499. * The action to be carried out following a trigger
  69500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  69501. */
  69502. export class Action implements IAction {
  69503. /** the trigger, with or without parameters, for the action */
  69504. triggerOptions: any;
  69505. /**
  69506. * Trigger for the action
  69507. */
  69508. trigger: number;
  69509. /**
  69510. * Internal only - manager for action
  69511. * @hidden
  69512. */
  69513. _actionManager: ActionManager;
  69514. private _nextActiveAction;
  69515. private _child;
  69516. private _condition?;
  69517. private _triggerParameter;
  69518. /**
  69519. * An event triggered prior to action being executed.
  69520. */
  69521. onBeforeExecuteObservable: Observable<Action>;
  69522. /**
  69523. * Creates a new Action
  69524. * @param triggerOptions the trigger, with or without parameters, for the action
  69525. * @param condition an optional determinant of action
  69526. */
  69527. constructor(
  69528. /** the trigger, with or without parameters, for the action */
  69529. triggerOptions: any, condition?: Condition);
  69530. /**
  69531. * Internal only
  69532. * @hidden
  69533. */
  69534. _prepare(): void;
  69535. /**
  69536. * Gets the trigger parameters
  69537. * @returns the trigger parameters
  69538. */
  69539. getTriggerParameter(): any;
  69540. /**
  69541. * Internal only - executes current action event
  69542. * @hidden
  69543. */
  69544. _executeCurrent(evt?: ActionEvent): void;
  69545. /**
  69546. * Execute placeholder for child classes
  69547. * @param evt optional action event
  69548. */
  69549. execute(evt?: ActionEvent): void;
  69550. /**
  69551. * Skips to next active action
  69552. */
  69553. skipToNextActiveAction(): void;
  69554. /**
  69555. * Adds action to chain of actions, may be a DoNothingAction
  69556. * @param action defines the next action to execute
  69557. * @returns The action passed in
  69558. * @see https://www.babylonjs-playground.com/#1T30HR#0
  69559. */
  69560. then(action: Action): Action;
  69561. /**
  69562. * Internal only
  69563. * @hidden
  69564. */
  69565. _getProperty(propertyPath: string): string;
  69566. /**
  69567. * Internal only
  69568. * @hidden
  69569. */
  69570. _getEffectiveTarget(target: any, propertyPath: string): any;
  69571. /**
  69572. * Serialize placeholder for child classes
  69573. * @param parent of child
  69574. * @returns the serialized object
  69575. */
  69576. serialize(parent: any): any;
  69577. /**
  69578. * Internal only called by serialize
  69579. * @hidden
  69580. */
  69581. protected _serialize(serializedAction: any, parent?: any): any;
  69582. /**
  69583. * Internal only
  69584. * @hidden
  69585. */
  69586. static _SerializeValueAsString: (value: any) => string;
  69587. /**
  69588. * Internal only
  69589. * @hidden
  69590. */
  69591. static _GetTargetProperty: (target: Scene | Node) => {
  69592. name: string;
  69593. targetType: string;
  69594. value: string;
  69595. };
  69596. }
  69597. }
  69598. declare module BABYLON {
  69599. /**
  69600. * A Condition applied to an Action
  69601. */
  69602. export class Condition {
  69603. /**
  69604. * Internal only - manager for action
  69605. * @hidden
  69606. */
  69607. _actionManager: ActionManager;
  69608. /**
  69609. * Internal only
  69610. * @hidden
  69611. */
  69612. _evaluationId: number;
  69613. /**
  69614. * Internal only
  69615. * @hidden
  69616. */
  69617. _currentResult: boolean;
  69618. /**
  69619. * Creates a new Condition
  69620. * @param actionManager the manager of the action the condition is applied to
  69621. */
  69622. constructor(actionManager: ActionManager);
  69623. /**
  69624. * Check if the current condition is valid
  69625. * @returns a boolean
  69626. */
  69627. isValid(): boolean;
  69628. /**
  69629. * Internal only
  69630. * @hidden
  69631. */
  69632. _getProperty(propertyPath: string): string;
  69633. /**
  69634. * Internal only
  69635. * @hidden
  69636. */
  69637. _getEffectiveTarget(target: any, propertyPath: string): any;
  69638. /**
  69639. * Serialize placeholder for child classes
  69640. * @returns the serialized object
  69641. */
  69642. serialize(): any;
  69643. /**
  69644. * Internal only
  69645. * @hidden
  69646. */
  69647. protected _serialize(serializedCondition: any): any;
  69648. }
  69649. /**
  69650. * Defines specific conditional operators as extensions of Condition
  69651. */
  69652. export class ValueCondition extends Condition {
  69653. /** path to specify the property of the target the conditional operator uses */
  69654. propertyPath: string;
  69655. /** the value compared by the conditional operator against the current value of the property */
  69656. value: any;
  69657. /** the conditional operator, default ValueCondition.IsEqual */
  69658. operator: number;
  69659. /**
  69660. * Internal only
  69661. * @hidden
  69662. */
  69663. private static _IsEqual;
  69664. /**
  69665. * Internal only
  69666. * @hidden
  69667. */
  69668. private static _IsDifferent;
  69669. /**
  69670. * Internal only
  69671. * @hidden
  69672. */
  69673. private static _IsGreater;
  69674. /**
  69675. * Internal only
  69676. * @hidden
  69677. */
  69678. private static _IsLesser;
  69679. /**
  69680. * returns the number for IsEqual
  69681. */
  69682. static readonly IsEqual: number;
  69683. /**
  69684. * Returns the number for IsDifferent
  69685. */
  69686. static readonly IsDifferent: number;
  69687. /**
  69688. * Returns the number for IsGreater
  69689. */
  69690. static readonly IsGreater: number;
  69691. /**
  69692. * Returns the number for IsLesser
  69693. */
  69694. static readonly IsLesser: number;
  69695. /**
  69696. * Internal only The action manager for the condition
  69697. * @hidden
  69698. */
  69699. _actionManager: ActionManager;
  69700. /**
  69701. * Internal only
  69702. * @hidden
  69703. */
  69704. private _target;
  69705. /**
  69706. * Internal only
  69707. * @hidden
  69708. */
  69709. private _effectiveTarget;
  69710. /**
  69711. * Internal only
  69712. * @hidden
  69713. */
  69714. private _property;
  69715. /**
  69716. * Creates a new ValueCondition
  69717. * @param actionManager manager for the action the condition applies to
  69718. * @param target for the action
  69719. * @param propertyPath path to specify the property of the target the conditional operator uses
  69720. * @param value the value compared by the conditional operator against the current value of the property
  69721. * @param operator the conditional operator, default ValueCondition.IsEqual
  69722. */
  69723. constructor(actionManager: ActionManager, target: any,
  69724. /** path to specify the property of the target the conditional operator uses */
  69725. propertyPath: string,
  69726. /** the value compared by the conditional operator against the current value of the property */
  69727. value: any,
  69728. /** the conditional operator, default ValueCondition.IsEqual */
  69729. operator?: number);
  69730. /**
  69731. * Compares the given value with the property value for the specified conditional operator
  69732. * @returns the result of the comparison
  69733. */
  69734. isValid(): boolean;
  69735. /**
  69736. * Serialize the ValueCondition into a JSON compatible object
  69737. * @returns serialization object
  69738. */
  69739. serialize(): any;
  69740. /**
  69741. * Gets the name of the conditional operator for the ValueCondition
  69742. * @param operator the conditional operator
  69743. * @returns the name
  69744. */
  69745. static GetOperatorName(operator: number): string;
  69746. }
  69747. /**
  69748. * Defines a predicate condition as an extension of Condition
  69749. */
  69750. export class PredicateCondition extends Condition {
  69751. /** defines the predicate function used to validate the condition */
  69752. predicate: () => boolean;
  69753. /**
  69754. * Internal only - manager for action
  69755. * @hidden
  69756. */
  69757. _actionManager: ActionManager;
  69758. /**
  69759. * Creates a new PredicateCondition
  69760. * @param actionManager manager for the action the condition applies to
  69761. * @param predicate defines the predicate function used to validate the condition
  69762. */
  69763. constructor(actionManager: ActionManager,
  69764. /** defines the predicate function used to validate the condition */
  69765. predicate: () => boolean);
  69766. /**
  69767. * @returns the validity of the predicate condition
  69768. */
  69769. isValid(): boolean;
  69770. }
  69771. /**
  69772. * Defines a state condition as an extension of Condition
  69773. */
  69774. export class StateCondition extends Condition {
  69775. /** Value to compare with target state */
  69776. value: string;
  69777. /**
  69778. * Internal only - manager for action
  69779. * @hidden
  69780. */
  69781. _actionManager: ActionManager;
  69782. /**
  69783. * Internal only
  69784. * @hidden
  69785. */
  69786. private _target;
  69787. /**
  69788. * Creates a new StateCondition
  69789. * @param actionManager manager for the action the condition applies to
  69790. * @param target of the condition
  69791. * @param value to compare with target state
  69792. */
  69793. constructor(actionManager: ActionManager, target: any,
  69794. /** Value to compare with target state */
  69795. value: string);
  69796. /**
  69797. * Gets a boolean indicating if the current condition is met
  69798. * @returns the validity of the state
  69799. */
  69800. isValid(): boolean;
  69801. /**
  69802. * Serialize the StateCondition into a JSON compatible object
  69803. * @returns serialization object
  69804. */
  69805. serialize(): any;
  69806. }
  69807. }
  69808. declare module BABYLON {
  69809. /**
  69810. * This defines an action responsible to toggle a boolean once triggered.
  69811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69812. */
  69813. export class SwitchBooleanAction extends Action {
  69814. /**
  69815. * The path to the boolean property in the target object
  69816. */
  69817. propertyPath: string;
  69818. private _target;
  69819. private _effectiveTarget;
  69820. private _property;
  69821. /**
  69822. * Instantiate the action
  69823. * @param triggerOptions defines the trigger options
  69824. * @param target defines the object containing the boolean
  69825. * @param propertyPath defines the path to the boolean property in the target object
  69826. * @param condition defines the trigger related conditions
  69827. */
  69828. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  69829. /** @hidden */
  69830. _prepare(): void;
  69831. /**
  69832. * Execute the action toggle the boolean value.
  69833. */
  69834. execute(): void;
  69835. /**
  69836. * Serializes the actions and its related information.
  69837. * @param parent defines the object to serialize in
  69838. * @returns the serialized object
  69839. */
  69840. serialize(parent: any): any;
  69841. }
  69842. /**
  69843. * This defines an action responsible to set a the state field of the target
  69844. * to a desired value once triggered.
  69845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69846. */
  69847. export class SetStateAction extends Action {
  69848. /**
  69849. * The value to store in the state field.
  69850. */
  69851. value: string;
  69852. private _target;
  69853. /**
  69854. * Instantiate the action
  69855. * @param triggerOptions defines the trigger options
  69856. * @param target defines the object containing the state property
  69857. * @param value defines the value to store in the state field
  69858. * @param condition defines the trigger related conditions
  69859. */
  69860. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  69861. /**
  69862. * Execute the action and store the value on the target state property.
  69863. */
  69864. execute(): void;
  69865. /**
  69866. * Serializes the actions and its related information.
  69867. * @param parent defines the object to serialize in
  69868. * @returns the serialized object
  69869. */
  69870. serialize(parent: any): any;
  69871. }
  69872. /**
  69873. * This defines an action responsible to set a property of the target
  69874. * to a desired value once triggered.
  69875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69876. */
  69877. export class SetValueAction extends Action {
  69878. /**
  69879. * The path of the property to set in the target.
  69880. */
  69881. propertyPath: string;
  69882. /**
  69883. * The value to set in the property
  69884. */
  69885. value: any;
  69886. private _target;
  69887. private _effectiveTarget;
  69888. private _property;
  69889. /**
  69890. * Instantiate the action
  69891. * @param triggerOptions defines the trigger options
  69892. * @param target defines the object containing the property
  69893. * @param propertyPath defines the path of the property to set in the target
  69894. * @param value defines the value to set in the property
  69895. * @param condition defines the trigger related conditions
  69896. */
  69897. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69898. /** @hidden */
  69899. _prepare(): void;
  69900. /**
  69901. * Execute the action and set the targetted property to the desired value.
  69902. */
  69903. execute(): void;
  69904. /**
  69905. * Serializes the actions and its related information.
  69906. * @param parent defines the object to serialize in
  69907. * @returns the serialized object
  69908. */
  69909. serialize(parent: any): any;
  69910. }
  69911. /**
  69912. * This defines an action responsible to increment the target value
  69913. * to a desired value once triggered.
  69914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69915. */
  69916. export class IncrementValueAction extends Action {
  69917. /**
  69918. * The path of the property to increment in the target.
  69919. */
  69920. propertyPath: string;
  69921. /**
  69922. * The value we should increment the property by.
  69923. */
  69924. value: any;
  69925. private _target;
  69926. private _effectiveTarget;
  69927. private _property;
  69928. /**
  69929. * Instantiate the action
  69930. * @param triggerOptions defines the trigger options
  69931. * @param target defines the object containing the property
  69932. * @param propertyPath defines the path of the property to increment in the target
  69933. * @param value defines the value value we should increment the property by
  69934. * @param condition defines the trigger related conditions
  69935. */
  69936. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69937. /** @hidden */
  69938. _prepare(): void;
  69939. /**
  69940. * Execute the action and increment the target of the value amount.
  69941. */
  69942. execute(): void;
  69943. /**
  69944. * Serializes the actions and its related information.
  69945. * @param parent defines the object to serialize in
  69946. * @returns the serialized object
  69947. */
  69948. serialize(parent: any): any;
  69949. }
  69950. /**
  69951. * This defines an action responsible to start an animation once triggered.
  69952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69953. */
  69954. export class PlayAnimationAction extends Action {
  69955. /**
  69956. * Where the animation should start (animation frame)
  69957. */
  69958. from: number;
  69959. /**
  69960. * Where the animation should stop (animation frame)
  69961. */
  69962. to: number;
  69963. /**
  69964. * Define if the animation should loop or stop after the first play.
  69965. */
  69966. loop?: boolean;
  69967. private _target;
  69968. /**
  69969. * Instantiate the action
  69970. * @param triggerOptions defines the trigger options
  69971. * @param target defines the target animation or animation name
  69972. * @param from defines from where the animation should start (animation frame)
  69973. * @param end defines where the animation should stop (animation frame)
  69974. * @param loop defines if the animation should loop or stop after the first play
  69975. * @param condition defines the trigger related conditions
  69976. */
  69977. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  69978. /** @hidden */
  69979. _prepare(): void;
  69980. /**
  69981. * Execute the action and play the animation.
  69982. */
  69983. execute(): void;
  69984. /**
  69985. * Serializes the actions and its related information.
  69986. * @param parent defines the object to serialize in
  69987. * @returns the serialized object
  69988. */
  69989. serialize(parent: any): any;
  69990. }
  69991. /**
  69992. * This defines an action responsible to stop an animation once triggered.
  69993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69994. */
  69995. export class StopAnimationAction extends Action {
  69996. private _target;
  69997. /**
  69998. * Instantiate the action
  69999. * @param triggerOptions defines the trigger options
  70000. * @param target defines the target animation or animation name
  70001. * @param condition defines the trigger related conditions
  70002. */
  70003. constructor(triggerOptions: any, target: any, condition?: Condition);
  70004. /** @hidden */
  70005. _prepare(): void;
  70006. /**
  70007. * Execute the action and stop the animation.
  70008. */
  70009. execute(): void;
  70010. /**
  70011. * Serializes the actions and its related information.
  70012. * @param parent defines the object to serialize in
  70013. * @returns the serialized object
  70014. */
  70015. serialize(parent: any): any;
  70016. }
  70017. /**
  70018. * This defines an action responsible that does nothing once triggered.
  70019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70020. */
  70021. export class DoNothingAction extends Action {
  70022. /**
  70023. * Instantiate the action
  70024. * @param triggerOptions defines the trigger options
  70025. * @param condition defines the trigger related conditions
  70026. */
  70027. constructor(triggerOptions?: any, condition?: Condition);
  70028. /**
  70029. * Execute the action and do nothing.
  70030. */
  70031. execute(): void;
  70032. /**
  70033. * Serializes the actions and its related information.
  70034. * @param parent defines the object to serialize in
  70035. * @returns the serialized object
  70036. */
  70037. serialize(parent: any): any;
  70038. }
  70039. /**
  70040. * This defines an action responsible to trigger several actions once triggered.
  70041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70042. */
  70043. export class CombineAction extends Action {
  70044. /**
  70045. * The list of aggregated animations to run.
  70046. */
  70047. children: Action[];
  70048. /**
  70049. * Instantiate the action
  70050. * @param triggerOptions defines the trigger options
  70051. * @param children defines the list of aggregated animations to run
  70052. * @param condition defines the trigger related conditions
  70053. */
  70054. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70055. /** @hidden */
  70056. _prepare(): void;
  70057. /**
  70058. * Execute the action and executes all the aggregated actions.
  70059. */
  70060. execute(evt: ActionEvent): void;
  70061. /**
  70062. * Serializes the actions and its related information.
  70063. * @param parent defines the object to serialize in
  70064. * @returns the serialized object
  70065. */
  70066. serialize(parent: any): any;
  70067. }
  70068. /**
  70069. * This defines an action responsible to run code (external event) once triggered.
  70070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70071. */
  70072. export class ExecuteCodeAction extends Action {
  70073. /**
  70074. * The callback function to run.
  70075. */
  70076. func: (evt: ActionEvent) => void;
  70077. /**
  70078. * Instantiate the action
  70079. * @param triggerOptions defines the trigger options
  70080. * @param func defines the callback function to run
  70081. * @param condition defines the trigger related conditions
  70082. */
  70083. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  70084. /**
  70085. * Execute the action and run the attached code.
  70086. */
  70087. execute(evt: ActionEvent): void;
  70088. }
  70089. /**
  70090. * This defines an action responsible to set the parent property of the target once triggered.
  70091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70092. */
  70093. export class SetParentAction extends Action {
  70094. private _parent;
  70095. private _target;
  70096. /**
  70097. * Instantiate the action
  70098. * @param triggerOptions defines the trigger options
  70099. * @param target defines the target containing the parent property
  70100. * @param parent defines from where the animation should start (animation frame)
  70101. * @param condition defines the trigger related conditions
  70102. */
  70103. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  70104. /** @hidden */
  70105. _prepare(): void;
  70106. /**
  70107. * Execute the action and set the parent property.
  70108. */
  70109. execute(): void;
  70110. /**
  70111. * Serializes the actions and its related information.
  70112. * @param parent defines the object to serialize in
  70113. * @returns the serialized object
  70114. */
  70115. serialize(parent: any): any;
  70116. }
  70117. }
  70118. declare module BABYLON {
  70119. /**
  70120. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  70121. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  70122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70123. */
  70124. export class ActionManager extends AbstractActionManager {
  70125. /**
  70126. * Nothing
  70127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70128. */
  70129. static readonly NothingTrigger: number;
  70130. /**
  70131. * On pick
  70132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70133. */
  70134. static readonly OnPickTrigger: number;
  70135. /**
  70136. * On left pick
  70137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70138. */
  70139. static readonly OnLeftPickTrigger: number;
  70140. /**
  70141. * On right pick
  70142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70143. */
  70144. static readonly OnRightPickTrigger: number;
  70145. /**
  70146. * On center pick
  70147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70148. */
  70149. static readonly OnCenterPickTrigger: number;
  70150. /**
  70151. * On pick down
  70152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70153. */
  70154. static readonly OnPickDownTrigger: number;
  70155. /**
  70156. * On double pick
  70157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70158. */
  70159. static readonly OnDoublePickTrigger: number;
  70160. /**
  70161. * On pick up
  70162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70163. */
  70164. static readonly OnPickUpTrigger: number;
  70165. /**
  70166. * On pick out.
  70167. * This trigger will only be raised if you also declared a OnPickDown
  70168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70169. */
  70170. static readonly OnPickOutTrigger: number;
  70171. /**
  70172. * On long press
  70173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70174. */
  70175. static readonly OnLongPressTrigger: number;
  70176. /**
  70177. * On pointer over
  70178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70179. */
  70180. static readonly OnPointerOverTrigger: number;
  70181. /**
  70182. * On pointer out
  70183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70184. */
  70185. static readonly OnPointerOutTrigger: number;
  70186. /**
  70187. * On every frame
  70188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70189. */
  70190. static readonly OnEveryFrameTrigger: number;
  70191. /**
  70192. * On intersection enter
  70193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70194. */
  70195. static readonly OnIntersectionEnterTrigger: number;
  70196. /**
  70197. * On intersection exit
  70198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70199. */
  70200. static readonly OnIntersectionExitTrigger: number;
  70201. /**
  70202. * On key down
  70203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70204. */
  70205. static readonly OnKeyDownTrigger: number;
  70206. /**
  70207. * On key up
  70208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70209. */
  70210. static readonly OnKeyUpTrigger: number;
  70211. private _scene;
  70212. /**
  70213. * Creates a new action manager
  70214. * @param scene defines the hosting scene
  70215. */
  70216. constructor(scene: Scene);
  70217. /**
  70218. * Releases all associated resources
  70219. */
  70220. dispose(): void;
  70221. /**
  70222. * Gets hosting scene
  70223. * @returns the hosting scene
  70224. */
  70225. getScene(): Scene;
  70226. /**
  70227. * Does this action manager handles actions of any of the given triggers
  70228. * @param triggers defines the triggers to be tested
  70229. * @return a boolean indicating whether one (or more) of the triggers is handled
  70230. */
  70231. hasSpecificTriggers(triggers: number[]): boolean;
  70232. /**
  70233. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  70234. * speed.
  70235. * @param triggerA defines the trigger to be tested
  70236. * @param triggerB defines the trigger to be tested
  70237. * @return a boolean indicating whether one (or more) of the triggers is handled
  70238. */
  70239. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  70240. /**
  70241. * Does this action manager handles actions of a given trigger
  70242. * @param trigger defines the trigger to be tested
  70243. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  70244. * @return whether the trigger is handled
  70245. */
  70246. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  70247. /**
  70248. * Does this action manager has pointer triggers
  70249. */
  70250. readonly hasPointerTriggers: boolean;
  70251. /**
  70252. * Does this action manager has pick triggers
  70253. */
  70254. readonly hasPickTriggers: boolean;
  70255. /**
  70256. * Registers an action to this action manager
  70257. * @param action defines the action to be registered
  70258. * @return the action amended (prepared) after registration
  70259. */
  70260. registerAction(action: IAction): Nullable<IAction>;
  70261. /**
  70262. * Unregisters an action to this action manager
  70263. * @param action defines the action to be unregistered
  70264. * @return a boolean indicating whether the action has been unregistered
  70265. */
  70266. unregisterAction(action: IAction): Boolean;
  70267. /**
  70268. * Process a specific trigger
  70269. * @param trigger defines the trigger to process
  70270. * @param evt defines the event details to be processed
  70271. */
  70272. processTrigger(trigger: number, evt?: IActionEvent): void;
  70273. /** @hidden */
  70274. _getEffectiveTarget(target: any, propertyPath: string): any;
  70275. /** @hidden */
  70276. _getProperty(propertyPath: string): string;
  70277. /**
  70278. * Serialize this manager to a JSON object
  70279. * @param name defines the property name to store this manager
  70280. * @returns a JSON representation of this manager
  70281. */
  70282. serialize(name: string): any;
  70283. /**
  70284. * Creates a new ActionManager from a JSON data
  70285. * @param parsedActions defines the JSON data to read from
  70286. * @param object defines the hosting mesh
  70287. * @param scene defines the hosting scene
  70288. */
  70289. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  70290. /**
  70291. * Get a trigger name by index
  70292. * @param trigger defines the trigger index
  70293. * @returns a trigger name
  70294. */
  70295. static GetTriggerName(trigger: number): string;
  70296. }
  70297. }
  70298. declare module BABYLON {
  70299. /**
  70300. * Class representing a ray with position and direction
  70301. */
  70302. export class Ray {
  70303. /** origin point */
  70304. origin: Vector3;
  70305. /** direction */
  70306. direction: Vector3;
  70307. /** length of the ray */
  70308. length: number;
  70309. private static readonly TmpVector3;
  70310. private _tmpRay;
  70311. /**
  70312. * Creates a new ray
  70313. * @param origin origin point
  70314. * @param direction direction
  70315. * @param length length of the ray
  70316. */
  70317. constructor(
  70318. /** origin point */
  70319. origin: Vector3,
  70320. /** direction */
  70321. direction: Vector3,
  70322. /** length of the ray */
  70323. length?: number);
  70324. /**
  70325. * Checks if the ray intersects a box
  70326. * @param minimum bound of the box
  70327. * @param maximum bound of the box
  70328. * @param intersectionTreshold extra extend to be added to the box in all direction
  70329. * @returns if the box was hit
  70330. */
  70331. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  70332. /**
  70333. * Checks if the ray intersects a box
  70334. * @param box the bounding box to check
  70335. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  70336. * @returns if the box was hit
  70337. */
  70338. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  70339. /**
  70340. * If the ray hits a sphere
  70341. * @param sphere the bounding sphere to check
  70342. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  70343. * @returns true if it hits the sphere
  70344. */
  70345. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  70346. /**
  70347. * If the ray hits a triange
  70348. * @param vertex0 triangle vertex
  70349. * @param vertex1 triangle vertex
  70350. * @param vertex2 triangle vertex
  70351. * @returns intersection information if hit
  70352. */
  70353. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  70354. /**
  70355. * Checks if ray intersects a plane
  70356. * @param plane the plane to check
  70357. * @returns the distance away it was hit
  70358. */
  70359. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  70360. /**
  70361. * Checks if ray intersects a mesh
  70362. * @param mesh the mesh to check
  70363. * @param fastCheck if only the bounding box should checked
  70364. * @returns picking info of the intersecton
  70365. */
  70366. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  70367. /**
  70368. * Checks if ray intersects a mesh
  70369. * @param meshes the meshes to check
  70370. * @param fastCheck if only the bounding box should checked
  70371. * @param results array to store result in
  70372. * @returns Array of picking infos
  70373. */
  70374. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  70375. private _comparePickingInfo;
  70376. private static smallnum;
  70377. private static rayl;
  70378. /**
  70379. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  70380. * @param sega the first point of the segment to test the intersection against
  70381. * @param segb the second point of the segment to test the intersection against
  70382. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  70383. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  70384. */
  70385. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  70386. /**
  70387. * Update the ray from viewport position
  70388. * @param x position
  70389. * @param y y position
  70390. * @param viewportWidth viewport width
  70391. * @param viewportHeight viewport height
  70392. * @param world world matrix
  70393. * @param view view matrix
  70394. * @param projection projection matrix
  70395. * @returns this ray updated
  70396. */
  70397. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70398. /**
  70399. * Creates a ray with origin and direction of 0,0,0
  70400. * @returns the new ray
  70401. */
  70402. static Zero(): Ray;
  70403. /**
  70404. * Creates a new ray from screen space and viewport
  70405. * @param x position
  70406. * @param y y position
  70407. * @param viewportWidth viewport width
  70408. * @param viewportHeight viewport height
  70409. * @param world world matrix
  70410. * @param view view matrix
  70411. * @param projection projection matrix
  70412. * @returns new ray
  70413. */
  70414. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70415. /**
  70416. * 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
  70417. * transformed to the given world matrix.
  70418. * @param origin The origin point
  70419. * @param end The end point
  70420. * @param world a matrix to transform the ray to. Default is the identity matrix.
  70421. * @returns the new ray
  70422. */
  70423. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  70424. /**
  70425. * Transforms a ray by a matrix
  70426. * @param ray ray to transform
  70427. * @param matrix matrix to apply
  70428. * @returns the resulting new ray
  70429. */
  70430. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  70431. /**
  70432. * Transforms a ray by a matrix
  70433. * @param ray ray to transform
  70434. * @param matrix matrix to apply
  70435. * @param result ray to store result in
  70436. */
  70437. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  70438. /**
  70439. * Unproject a ray from screen space to object space
  70440. * @param sourceX defines the screen space x coordinate to use
  70441. * @param sourceY defines the screen space y coordinate to use
  70442. * @param viewportWidth defines the current width of the viewport
  70443. * @param viewportHeight defines the current height of the viewport
  70444. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70445. * @param view defines the view matrix to use
  70446. * @param projection defines the projection matrix to use
  70447. */
  70448. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  70449. }
  70450. /**
  70451. * Type used to define predicate used to select faces when a mesh intersection is detected
  70452. */
  70453. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  70454. interface Scene {
  70455. /** @hidden */
  70456. _tempPickingRay: Nullable<Ray>;
  70457. /** @hidden */
  70458. _cachedRayForTransform: Ray;
  70459. /** @hidden */
  70460. _pickWithRayInverseMatrix: Matrix;
  70461. /** @hidden */
  70462. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  70463. /** @hidden */
  70464. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  70465. }
  70466. }
  70467. declare module BABYLON {
  70468. /**
  70469. * Groups all the scene component constants in one place to ease maintenance.
  70470. * @hidden
  70471. */
  70472. export class SceneComponentConstants {
  70473. static readonly NAME_EFFECTLAYER: string;
  70474. static readonly NAME_LAYER: string;
  70475. static readonly NAME_LENSFLARESYSTEM: string;
  70476. static readonly NAME_BOUNDINGBOXRENDERER: string;
  70477. static readonly NAME_PARTICLESYSTEM: string;
  70478. static readonly NAME_GAMEPAD: string;
  70479. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  70480. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  70481. static readonly NAME_DEPTHRENDERER: string;
  70482. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  70483. static readonly NAME_SPRITE: string;
  70484. static readonly NAME_OUTLINERENDERER: string;
  70485. static readonly NAME_PROCEDURALTEXTURE: string;
  70486. static readonly NAME_SHADOWGENERATOR: string;
  70487. static readonly NAME_OCTREE: string;
  70488. static readonly NAME_PHYSICSENGINE: string;
  70489. static readonly NAME_AUDIO: string;
  70490. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  70491. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70492. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  70493. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70494. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  70495. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  70496. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  70497. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  70498. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  70499. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  70500. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  70501. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  70502. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  70503. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  70504. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  70505. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  70506. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  70507. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  70508. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  70509. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  70510. static readonly STEP_AFTERRENDER_AUDIO: number;
  70511. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  70512. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  70513. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  70514. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  70515. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  70516. static readonly STEP_POINTERMOVE_SPRITE: number;
  70517. static readonly STEP_POINTERDOWN_SPRITE: number;
  70518. static readonly STEP_POINTERUP_SPRITE: number;
  70519. }
  70520. /**
  70521. * This represents a scene component.
  70522. *
  70523. * This is used to decouple the dependency the scene is having on the different workloads like
  70524. * layers, post processes...
  70525. */
  70526. export interface ISceneComponent {
  70527. /**
  70528. * The name of the component. Each component must have a unique name.
  70529. */
  70530. name: string;
  70531. /**
  70532. * The scene the component belongs to.
  70533. */
  70534. scene: Scene;
  70535. /**
  70536. * Register the component to one instance of a scene.
  70537. */
  70538. register(): void;
  70539. /**
  70540. * Rebuilds the elements related to this component in case of
  70541. * context lost for instance.
  70542. */
  70543. rebuild(): void;
  70544. /**
  70545. * Disposes the component and the associated ressources.
  70546. */
  70547. dispose(): void;
  70548. }
  70549. /**
  70550. * This represents a SERIALIZABLE scene component.
  70551. *
  70552. * This extends Scene Component to add Serialization methods on top.
  70553. */
  70554. export interface ISceneSerializableComponent extends ISceneComponent {
  70555. /**
  70556. * Adds all the element from the container to the scene
  70557. * @param container the container holding the elements
  70558. */
  70559. addFromContainer(container: AbstractScene): void;
  70560. /**
  70561. * Removes all the elements in the container from the scene
  70562. * @param container contains the elements to remove
  70563. * @param dispose if the removed element should be disposed (default: false)
  70564. */
  70565. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70566. /**
  70567. * Serializes the component data to the specified json object
  70568. * @param serializationObject The object to serialize to
  70569. */
  70570. serialize(serializationObject: any): void;
  70571. }
  70572. /**
  70573. * Strong typing of a Mesh related stage step action
  70574. */
  70575. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  70576. /**
  70577. * Strong typing of a Evaluate Sub Mesh related stage step action
  70578. */
  70579. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  70580. /**
  70581. * Strong typing of a Active Mesh related stage step action
  70582. */
  70583. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  70584. /**
  70585. * Strong typing of a Camera related stage step action
  70586. */
  70587. export type CameraStageAction = (camera: Camera) => void;
  70588. /**
  70589. * Strong typing of a Render Target related stage step action
  70590. */
  70591. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  70592. /**
  70593. * Strong typing of a RenderingGroup related stage step action
  70594. */
  70595. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  70596. /**
  70597. * Strong typing of a Mesh Render related stage step action
  70598. */
  70599. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70600. /**
  70601. * Strong typing of a simple stage step action
  70602. */
  70603. export type SimpleStageAction = () => void;
  70604. /**
  70605. * Strong typing of a render target action.
  70606. */
  70607. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70608. /**
  70609. * Strong typing of a pointer move action.
  70610. */
  70611. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70612. /**
  70613. * Strong typing of a pointer up/down action.
  70614. */
  70615. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70616. /**
  70617. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70618. * @hidden
  70619. */
  70620. export class Stage<T extends Function> extends Array<{
  70621. index: number;
  70622. component: ISceneComponent;
  70623. action: T;
  70624. }> {
  70625. /**
  70626. * Hide ctor from the rest of the world.
  70627. * @param items The items to add.
  70628. */
  70629. private constructor();
  70630. /**
  70631. * Creates a new Stage.
  70632. * @returns A new instance of a Stage
  70633. */
  70634. static Create<T extends Function>(): Stage<T>;
  70635. /**
  70636. * Registers a step in an ordered way in the targeted stage.
  70637. * @param index Defines the position to register the step in
  70638. * @param component Defines the component attached to the step
  70639. * @param action Defines the action to launch during the step
  70640. */
  70641. registerStep(index: number, component: ISceneComponent, action: T): void;
  70642. /**
  70643. * Clears all the steps from the stage.
  70644. */
  70645. clear(): void;
  70646. }
  70647. }
  70648. declare module BABYLON {
  70649. interface Scene {
  70650. /** @hidden */
  70651. _pointerOverSprite: Nullable<Sprite>;
  70652. /** @hidden */
  70653. _pickedDownSprite: Nullable<Sprite>;
  70654. /** @hidden */
  70655. _tempSpritePickingRay: Nullable<Ray>;
  70656. /**
  70657. * All of the sprite managers added to this scene
  70658. * @see http://doc.babylonjs.com/babylon101/sprites
  70659. */
  70660. spriteManagers: Array<ISpriteManager>;
  70661. /**
  70662. * An event triggered when sprites rendering is about to start
  70663. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70664. */
  70665. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70666. /**
  70667. * An event triggered when sprites rendering is done
  70668. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70669. */
  70670. onAfterSpritesRenderingObservable: Observable<Scene>;
  70671. /** @hidden */
  70672. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70673. /** Launch a ray to try to pick a sprite in the scene
  70674. * @param x position on screen
  70675. * @param y position on screen
  70676. * @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
  70677. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70678. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  70679. * @returns a PickingInfo
  70680. */
  70681. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70682. /** Use the given ray to pick a sprite in the scene
  70683. * @param ray The ray (in world space) to use to pick meshes
  70684. * @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
  70685. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70686. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  70687. * @returns a PickingInfo
  70688. */
  70689. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70690. /**
  70691. * Force the sprite under the pointer
  70692. * @param sprite defines the sprite to use
  70693. */
  70694. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  70695. /**
  70696. * Gets the sprite under the pointer
  70697. * @returns a Sprite or null if no sprite is under the pointer
  70698. */
  70699. getPointerOverSprite(): Nullable<Sprite>;
  70700. }
  70701. /**
  70702. * Defines the sprite scene component responsible to manage sprites
  70703. * in a given scene.
  70704. */
  70705. export class SpriteSceneComponent implements ISceneComponent {
  70706. /**
  70707. * The component name helpfull to identify the component in the list of scene components.
  70708. */
  70709. readonly name: string;
  70710. /**
  70711. * The scene the component belongs to.
  70712. */
  70713. scene: Scene;
  70714. /** @hidden */
  70715. private _spritePredicate;
  70716. /**
  70717. * Creates a new instance of the component for the given scene
  70718. * @param scene Defines the scene to register the component in
  70719. */
  70720. constructor(scene: Scene);
  70721. /**
  70722. * Registers the component in a given scene
  70723. */
  70724. register(): void;
  70725. /**
  70726. * Rebuilds the elements related to this component in case of
  70727. * context lost for instance.
  70728. */
  70729. rebuild(): void;
  70730. /**
  70731. * Disposes the component and the associated ressources.
  70732. */
  70733. dispose(): void;
  70734. private _pickSpriteButKeepRay;
  70735. private _pointerMove;
  70736. private _pointerDown;
  70737. private _pointerUp;
  70738. }
  70739. }
  70740. declare module BABYLON {
  70741. /** @hidden */
  70742. export var fogFragmentDeclaration: {
  70743. name: string;
  70744. shader: string;
  70745. };
  70746. }
  70747. declare module BABYLON {
  70748. /** @hidden */
  70749. export var fogFragment: {
  70750. name: string;
  70751. shader: string;
  70752. };
  70753. }
  70754. declare module BABYLON {
  70755. /** @hidden */
  70756. export var spritesPixelShader: {
  70757. name: string;
  70758. shader: string;
  70759. };
  70760. }
  70761. declare module BABYLON {
  70762. /** @hidden */
  70763. export var fogVertexDeclaration: {
  70764. name: string;
  70765. shader: string;
  70766. };
  70767. }
  70768. declare module BABYLON {
  70769. /** @hidden */
  70770. export var spritesVertexShader: {
  70771. name: string;
  70772. shader: string;
  70773. };
  70774. }
  70775. declare module BABYLON {
  70776. /**
  70777. * Defines the minimum interface to fullfil in order to be a sprite manager.
  70778. */
  70779. export interface ISpriteManager extends IDisposable {
  70780. /**
  70781. * Restricts the camera to viewing objects with the same layerMask.
  70782. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  70783. */
  70784. layerMask: number;
  70785. /**
  70786. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  70787. */
  70788. isPickable: boolean;
  70789. /**
  70790. * Specifies the rendering group id for this mesh (0 by default)
  70791. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  70792. */
  70793. renderingGroupId: number;
  70794. /**
  70795. * Defines the list of sprites managed by the manager.
  70796. */
  70797. sprites: Array<Sprite>;
  70798. /**
  70799. * Tests the intersection of a sprite with a specific ray.
  70800. * @param ray The ray we are sending to test the collision
  70801. * @param camera The camera space we are sending rays in
  70802. * @param predicate A predicate allowing excluding sprites from the list of object to test
  70803. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  70804. * @returns picking info or null.
  70805. */
  70806. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70807. /**
  70808. * Renders the list of sprites on screen.
  70809. */
  70810. render(): void;
  70811. }
  70812. /**
  70813. * Class used to manage multiple sprites on the same spritesheet
  70814. * @see http://doc.babylonjs.com/babylon101/sprites
  70815. */
  70816. export class SpriteManager implements ISpriteManager {
  70817. /** defines the manager's name */
  70818. name: string;
  70819. /** Gets the list of sprites */
  70820. sprites: Sprite[];
  70821. /** Gets or sets the rendering group id (0 by default) */
  70822. renderingGroupId: number;
  70823. /** Gets or sets camera layer mask */
  70824. layerMask: number;
  70825. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  70826. fogEnabled: boolean;
  70827. /** Gets or sets a boolean indicating if the sprites are pickable */
  70828. isPickable: boolean;
  70829. /** Defines the default width of a cell in the spritesheet */
  70830. cellWidth: number;
  70831. /** Defines the default height of a cell in the spritesheet */
  70832. cellHeight: number;
  70833. /**
  70834. * An event triggered when the manager is disposed.
  70835. */
  70836. onDisposeObservable: Observable<SpriteManager>;
  70837. private _onDisposeObserver;
  70838. /**
  70839. * Callback called when the manager is disposed
  70840. */
  70841. onDispose: () => void;
  70842. private _capacity;
  70843. private _spriteTexture;
  70844. private _epsilon;
  70845. private _scene;
  70846. private _vertexData;
  70847. private _buffer;
  70848. private _vertexBuffers;
  70849. private _indexBuffer;
  70850. private _effectBase;
  70851. private _effectFog;
  70852. /**
  70853. * Gets or sets the spritesheet texture
  70854. */
  70855. texture: Texture;
  70856. /**
  70857. * Creates a new sprite manager
  70858. * @param name defines the manager's name
  70859. * @param imgUrl defines the sprite sheet url
  70860. * @param capacity defines the maximum allowed number of sprites
  70861. * @param cellSize defines the size of a sprite cell
  70862. * @param scene defines the hosting scene
  70863. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70864. * @param samplingMode defines the smapling mode to use with spritesheet
  70865. */
  70866. constructor(
  70867. /** defines the manager's name */
  70868. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  70869. private _appendSpriteVertex;
  70870. /**
  70871. * Intersects the sprites with a ray
  70872. * @param ray defines the ray to intersect with
  70873. * @param camera defines the current active camera
  70874. * @param predicate defines a predicate used to select candidate sprites
  70875. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  70876. * @returns null if no hit or a PickingInfo
  70877. */
  70878. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70879. /**
  70880. * Render all child sprites
  70881. */
  70882. render(): void;
  70883. /**
  70884. * Release associated resources
  70885. */
  70886. dispose(): void;
  70887. }
  70888. }
  70889. declare module BABYLON {
  70890. /**
  70891. * Class used to represent a sprite
  70892. * @see http://doc.babylonjs.com/babylon101/sprites
  70893. */
  70894. export class Sprite {
  70895. /** defines the name */
  70896. name: string;
  70897. /** Gets or sets the current world position */
  70898. position: Vector3;
  70899. /** Gets or sets the main color */
  70900. color: Color4;
  70901. /** Gets or sets the width */
  70902. width: number;
  70903. /** Gets or sets the height */
  70904. height: number;
  70905. /** Gets or sets rotation angle */
  70906. angle: number;
  70907. /** Gets or sets the cell index in the sprite sheet */
  70908. cellIndex: number;
  70909. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  70910. invertU: number;
  70911. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  70912. invertV: number;
  70913. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  70914. disposeWhenFinishedAnimating: boolean;
  70915. /** Gets the list of attached animations */
  70916. animations: Animation[];
  70917. /** Gets or sets a boolean indicating if the sprite can be picked */
  70918. isPickable: boolean;
  70919. /**
  70920. * Gets or sets the associated action manager
  70921. */
  70922. actionManager: Nullable<ActionManager>;
  70923. private _animationStarted;
  70924. private _loopAnimation;
  70925. private _fromIndex;
  70926. private _toIndex;
  70927. private _delay;
  70928. private _direction;
  70929. private _manager;
  70930. private _time;
  70931. private _onAnimationEnd;
  70932. /**
  70933. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  70934. */
  70935. isVisible: boolean;
  70936. /**
  70937. * Gets or sets the sprite size
  70938. */
  70939. size: number;
  70940. /**
  70941. * Creates a new Sprite
  70942. * @param name defines the name
  70943. * @param manager defines the manager
  70944. */
  70945. constructor(
  70946. /** defines the name */
  70947. name: string, manager: ISpriteManager);
  70948. /**
  70949. * Starts an animation
  70950. * @param from defines the initial key
  70951. * @param to defines the end key
  70952. * @param loop defines if the animation must loop
  70953. * @param delay defines the start delay (in ms)
  70954. * @param onAnimationEnd defines a callback to call when animation ends
  70955. */
  70956. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  70957. /** Stops current animation (if any) */
  70958. stopAnimation(): void;
  70959. /** @hidden */
  70960. _animate(deltaTime: number): void;
  70961. /** Release associated resources */
  70962. dispose(): void;
  70963. }
  70964. }
  70965. declare module BABYLON {
  70966. /**
  70967. * Information about the result of picking within a scene
  70968. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  70969. */
  70970. export class PickingInfo {
  70971. /** @hidden */
  70972. _pickingUnavailable: boolean;
  70973. /**
  70974. * If the pick collided with an object
  70975. */
  70976. hit: boolean;
  70977. /**
  70978. * Distance away where the pick collided
  70979. */
  70980. distance: number;
  70981. /**
  70982. * The location of pick collision
  70983. */
  70984. pickedPoint: Nullable<Vector3>;
  70985. /**
  70986. * The mesh corresponding the the pick collision
  70987. */
  70988. pickedMesh: Nullable<AbstractMesh>;
  70989. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  70990. bu: number;
  70991. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  70992. bv: number;
  70993. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  70994. faceId: number;
  70995. /** Id of the the submesh that was picked */
  70996. subMeshId: number;
  70997. /** If a sprite was picked, this will be the sprite the pick collided with */
  70998. pickedSprite: Nullable<Sprite>;
  70999. /**
  71000. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71001. */
  71002. originMesh: Nullable<AbstractMesh>;
  71003. /**
  71004. * The ray that was used to perform the picking.
  71005. */
  71006. ray: Nullable<Ray>;
  71007. /**
  71008. * Gets the normal correspodning to the face the pick collided with
  71009. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71010. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71011. * @returns The normal correspodning to the face the pick collided with
  71012. */
  71013. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71014. /**
  71015. * Gets the texture coordinates of where the pick occured
  71016. * @returns the vector containing the coordnates of the texture
  71017. */
  71018. getTextureCoordinates(): Nullable<Vector2>;
  71019. }
  71020. }
  71021. declare module BABYLON {
  71022. /**
  71023. * Gather the list of pointer event types as constants.
  71024. */
  71025. export class PointerEventTypes {
  71026. /**
  71027. * 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.
  71028. */
  71029. static readonly POINTERDOWN: number;
  71030. /**
  71031. * The pointerup event is fired when a pointer is no longer active.
  71032. */
  71033. static readonly POINTERUP: number;
  71034. /**
  71035. * The pointermove event is fired when a pointer changes coordinates.
  71036. */
  71037. static readonly POINTERMOVE: number;
  71038. /**
  71039. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71040. */
  71041. static readonly POINTERWHEEL: number;
  71042. /**
  71043. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71044. */
  71045. static readonly POINTERPICK: number;
  71046. /**
  71047. * The pointertap event is fired when a the object has been touched and released without drag.
  71048. */
  71049. static readonly POINTERTAP: number;
  71050. /**
  71051. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71052. */
  71053. static readonly POINTERDOUBLETAP: number;
  71054. }
  71055. /**
  71056. * Base class of pointer info types.
  71057. */
  71058. export class PointerInfoBase {
  71059. /**
  71060. * Defines the type of event (PointerEventTypes)
  71061. */
  71062. type: number;
  71063. /**
  71064. * Defines the related dom event
  71065. */
  71066. event: PointerEvent | MouseWheelEvent;
  71067. /**
  71068. * Instantiates the base class of pointers info.
  71069. * @param type Defines the type of event (PointerEventTypes)
  71070. * @param event Defines the related dom event
  71071. */
  71072. constructor(
  71073. /**
  71074. * Defines the type of event (PointerEventTypes)
  71075. */
  71076. type: number,
  71077. /**
  71078. * Defines the related dom event
  71079. */
  71080. event: PointerEvent | MouseWheelEvent);
  71081. }
  71082. /**
  71083. * This class is used to store pointer related info for the onPrePointerObservable event.
  71084. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  71085. */
  71086. export class PointerInfoPre extends PointerInfoBase {
  71087. /**
  71088. * Ray from a pointer if availible (eg. 6dof controller)
  71089. */
  71090. ray: Nullable<Ray>;
  71091. /**
  71092. * Defines the local position of the pointer on the canvas.
  71093. */
  71094. localPosition: Vector2;
  71095. /**
  71096. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  71097. */
  71098. skipOnPointerObservable: boolean;
  71099. /**
  71100. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  71101. * @param type Defines the type of event (PointerEventTypes)
  71102. * @param event Defines the related dom event
  71103. * @param localX Defines the local x coordinates of the pointer when the event occured
  71104. * @param localY Defines the local y coordinates of the pointer when the event occured
  71105. */
  71106. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  71107. }
  71108. /**
  71109. * This type contains all the data related to a pointer event in Babylon.js.
  71110. * 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.
  71111. */
  71112. export class PointerInfo extends PointerInfoBase {
  71113. /**
  71114. * Defines the picking info associated to the info (if any)\
  71115. */
  71116. pickInfo: Nullable<PickingInfo>;
  71117. /**
  71118. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  71119. * @param type Defines the type of event (PointerEventTypes)
  71120. * @param event Defines the related dom event
  71121. * @param pickInfo Defines the picking info associated to the info (if any)\
  71122. */
  71123. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  71124. /**
  71125. * Defines the picking info associated to the info (if any)\
  71126. */
  71127. pickInfo: Nullable<PickingInfo>);
  71128. }
  71129. /**
  71130. * Data relating to a touch event on the screen.
  71131. */
  71132. export interface PointerTouch {
  71133. /**
  71134. * X coordinate of touch.
  71135. */
  71136. x: number;
  71137. /**
  71138. * Y coordinate of touch.
  71139. */
  71140. y: number;
  71141. /**
  71142. * Id of touch. Unique for each finger.
  71143. */
  71144. pointerId: number;
  71145. /**
  71146. * Event type passed from DOM.
  71147. */
  71148. type: any;
  71149. }
  71150. }
  71151. declare module BABYLON {
  71152. /**
  71153. * Manage the mouse inputs to control the movement of a free camera.
  71154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71155. */
  71156. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  71157. /**
  71158. * Define if touch is enabled in the mouse input
  71159. */
  71160. touchEnabled: boolean;
  71161. /**
  71162. * Defines the camera the input is attached to.
  71163. */
  71164. camera: FreeCamera;
  71165. /**
  71166. * Defines the buttons associated with the input to handle camera move.
  71167. */
  71168. buttons: number[];
  71169. /**
  71170. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  71171. */
  71172. angularSensibility: number;
  71173. private _pointerInput;
  71174. private _onMouseMove;
  71175. private _observer;
  71176. private previousPosition;
  71177. /**
  71178. * Observable for when a pointer move event occurs containing the move offset
  71179. */
  71180. onPointerMovedObservable: Observable<{
  71181. offsetX: number;
  71182. offsetY: number;
  71183. }>;
  71184. /**
  71185. * @hidden
  71186. * If the camera should be rotated automatically based on pointer movement
  71187. */
  71188. _allowCameraRotation: boolean;
  71189. /**
  71190. * Manage the mouse inputs to control the movement of a free camera.
  71191. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71192. * @param touchEnabled Defines if touch is enabled or not
  71193. */
  71194. constructor(
  71195. /**
  71196. * Define if touch is enabled in the mouse input
  71197. */
  71198. touchEnabled?: boolean);
  71199. /**
  71200. * Attach the input controls to a specific dom element to get the input from.
  71201. * @param element Defines the element the controls should be listened from
  71202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71203. */
  71204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71205. /**
  71206. * Called on JS contextmenu event.
  71207. * Override this method to provide functionality.
  71208. */
  71209. protected onContextMenu(evt: PointerEvent): void;
  71210. /**
  71211. * Detach the current controls from the specified dom element.
  71212. * @param element Defines the element to stop listening the inputs from
  71213. */
  71214. detachControl(element: Nullable<HTMLElement>): void;
  71215. /**
  71216. * Gets the class name of the current intput.
  71217. * @returns the class name
  71218. */
  71219. getClassName(): string;
  71220. /**
  71221. * Get the friendly name associated with the input class.
  71222. * @returns the input friendly name
  71223. */
  71224. getSimpleName(): string;
  71225. }
  71226. }
  71227. declare module BABYLON {
  71228. /**
  71229. * Manage the touch inputs to control the movement of a free camera.
  71230. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71231. */
  71232. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  71233. /**
  71234. * Defines the camera the input is attached to.
  71235. */
  71236. camera: FreeCamera;
  71237. /**
  71238. * Defines the touch sensibility for rotation.
  71239. * The higher the faster.
  71240. */
  71241. touchAngularSensibility: number;
  71242. /**
  71243. * Defines the touch sensibility for move.
  71244. * The higher the faster.
  71245. */
  71246. touchMoveSensibility: number;
  71247. private _offsetX;
  71248. private _offsetY;
  71249. private _pointerPressed;
  71250. private _pointerInput;
  71251. private _observer;
  71252. private _onLostFocus;
  71253. /**
  71254. * Attach the input controls to a specific dom element to get the input from.
  71255. * @param element Defines the element the controls should be listened from
  71256. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71257. */
  71258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71259. /**
  71260. * Detach the current controls from the specified dom element.
  71261. * @param element Defines the element to stop listening the inputs from
  71262. */
  71263. detachControl(element: Nullable<HTMLElement>): void;
  71264. /**
  71265. * Update the current camera state depending on the inputs that have been used this frame.
  71266. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71267. */
  71268. checkInputs(): void;
  71269. /**
  71270. * Gets the class name of the current intput.
  71271. * @returns the class name
  71272. */
  71273. getClassName(): string;
  71274. /**
  71275. * Get the friendly name associated with the input class.
  71276. * @returns the input friendly name
  71277. */
  71278. getSimpleName(): string;
  71279. }
  71280. }
  71281. declare module BABYLON {
  71282. /**
  71283. * Default Inputs manager for the FreeCamera.
  71284. * It groups all the default supported inputs for ease of use.
  71285. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71286. */
  71287. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  71288. /**
  71289. * @hidden
  71290. */
  71291. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  71292. /**
  71293. * @hidden
  71294. */
  71295. _mouseInput: Nullable<FreeCameraMouseInput>;
  71296. /**
  71297. * Instantiates a new FreeCameraInputsManager.
  71298. * @param camera Defines the camera the inputs belong to
  71299. */
  71300. constructor(camera: FreeCamera);
  71301. /**
  71302. * Add keyboard input support to the input manager.
  71303. * @returns the current input manager
  71304. */
  71305. addKeyboard(): FreeCameraInputsManager;
  71306. /**
  71307. * Add mouse input support to the input manager.
  71308. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  71309. * @returns the current input manager
  71310. */
  71311. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  71312. /**
  71313. * Removes the mouse input support from the manager
  71314. * @returns the current input manager
  71315. */
  71316. removeMouse(): FreeCameraInputsManager;
  71317. /**
  71318. * Add touch input support to the input manager.
  71319. * @returns the current input manager
  71320. */
  71321. addTouch(): FreeCameraInputsManager;
  71322. }
  71323. }
  71324. declare module BABYLON {
  71325. /**
  71326. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71327. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  71328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71329. */
  71330. export class FreeCamera extends TargetCamera {
  71331. /**
  71332. * Define the collision ellipsoid of the camera.
  71333. * This is helpful to simulate a camera body like the player body around the camera
  71334. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  71335. */
  71336. ellipsoid: Vector3;
  71337. /**
  71338. * Define an offset for the position of the ellipsoid around the camera.
  71339. * This can be helpful to determine the center of the body near the gravity center of the body
  71340. * instead of its head.
  71341. */
  71342. ellipsoidOffset: Vector3;
  71343. /**
  71344. * Enable or disable collisions of the camera with the rest of the scene objects.
  71345. */
  71346. checkCollisions: boolean;
  71347. /**
  71348. * Enable or disable gravity on the camera.
  71349. */
  71350. applyGravity: boolean;
  71351. /**
  71352. * Define the input manager associated to the camera.
  71353. */
  71354. inputs: FreeCameraInputsManager;
  71355. /**
  71356. * Gets the input sensibility for a mouse input. (default is 2000.0)
  71357. * Higher values reduce sensitivity.
  71358. */
  71359. /**
  71360. * Sets the input sensibility for a mouse input. (default is 2000.0)
  71361. * Higher values reduce sensitivity.
  71362. */
  71363. angularSensibility: number;
  71364. /**
  71365. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71366. */
  71367. keysUp: number[];
  71368. /**
  71369. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71370. */
  71371. keysDown: number[];
  71372. /**
  71373. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71374. */
  71375. keysLeft: number[];
  71376. /**
  71377. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71378. */
  71379. keysRight: number[];
  71380. /**
  71381. * Event raised when the camera collide with a mesh in the scene.
  71382. */
  71383. onCollide: (collidedMesh: AbstractMesh) => void;
  71384. private _collider;
  71385. private _needMoveForGravity;
  71386. private _oldPosition;
  71387. private _diffPosition;
  71388. private _newPosition;
  71389. /** @hidden */
  71390. _localDirection: Vector3;
  71391. /** @hidden */
  71392. _transformedDirection: Vector3;
  71393. /**
  71394. * Instantiates a Free Camera.
  71395. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71396. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  71397. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71398. * @param name Define the name of the camera in the scene
  71399. * @param position Define the start position of the camera in the scene
  71400. * @param scene Define the scene the camera belongs to
  71401. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71402. */
  71403. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71404. /**
  71405. * Attached controls to the current camera.
  71406. * @param element Defines the element the controls should be listened from
  71407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71408. */
  71409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71410. /**
  71411. * Detach the current controls from the camera.
  71412. * The camera will stop reacting to inputs.
  71413. * @param element Defines the element to stop listening the inputs from
  71414. */
  71415. detachControl(element: HTMLElement): void;
  71416. private _collisionMask;
  71417. /**
  71418. * Define a collision mask to limit the list of object the camera can collide with
  71419. */
  71420. collisionMask: number;
  71421. /** @hidden */
  71422. _collideWithWorld(displacement: Vector3): void;
  71423. private _onCollisionPositionChange;
  71424. /** @hidden */
  71425. _checkInputs(): void;
  71426. /** @hidden */
  71427. _decideIfNeedsToMove(): boolean;
  71428. /** @hidden */
  71429. _updatePosition(): void;
  71430. /**
  71431. * Destroy the camera and release the current resources hold by it.
  71432. */
  71433. dispose(): void;
  71434. /**
  71435. * Gets the current object class name.
  71436. * @return the class name
  71437. */
  71438. getClassName(): string;
  71439. }
  71440. }
  71441. declare module BABYLON {
  71442. /**
  71443. * Represents a gamepad control stick position
  71444. */
  71445. export class StickValues {
  71446. /**
  71447. * The x component of the control stick
  71448. */
  71449. x: number;
  71450. /**
  71451. * The y component of the control stick
  71452. */
  71453. y: number;
  71454. /**
  71455. * Initializes the gamepad x and y control stick values
  71456. * @param x The x component of the gamepad control stick value
  71457. * @param y The y component of the gamepad control stick value
  71458. */
  71459. constructor(
  71460. /**
  71461. * The x component of the control stick
  71462. */
  71463. x: number,
  71464. /**
  71465. * The y component of the control stick
  71466. */
  71467. y: number);
  71468. }
  71469. /**
  71470. * An interface which manages callbacks for gamepad button changes
  71471. */
  71472. export interface GamepadButtonChanges {
  71473. /**
  71474. * Called when a gamepad has been changed
  71475. */
  71476. changed: boolean;
  71477. /**
  71478. * Called when a gamepad press event has been triggered
  71479. */
  71480. pressChanged: boolean;
  71481. /**
  71482. * Called when a touch event has been triggered
  71483. */
  71484. touchChanged: boolean;
  71485. /**
  71486. * Called when a value has changed
  71487. */
  71488. valueChanged: boolean;
  71489. }
  71490. /**
  71491. * Represents a gamepad
  71492. */
  71493. export class Gamepad {
  71494. /**
  71495. * The id of the gamepad
  71496. */
  71497. id: string;
  71498. /**
  71499. * The index of the gamepad
  71500. */
  71501. index: number;
  71502. /**
  71503. * The browser gamepad
  71504. */
  71505. browserGamepad: any;
  71506. /**
  71507. * Specifies what type of gamepad this represents
  71508. */
  71509. type: number;
  71510. private _leftStick;
  71511. private _rightStick;
  71512. /** @hidden */
  71513. _isConnected: boolean;
  71514. private _leftStickAxisX;
  71515. private _leftStickAxisY;
  71516. private _rightStickAxisX;
  71517. private _rightStickAxisY;
  71518. /**
  71519. * Triggered when the left control stick has been changed
  71520. */
  71521. private _onleftstickchanged;
  71522. /**
  71523. * Triggered when the right control stick has been changed
  71524. */
  71525. private _onrightstickchanged;
  71526. /**
  71527. * Represents a gamepad controller
  71528. */
  71529. static GAMEPAD: number;
  71530. /**
  71531. * Represents a generic controller
  71532. */
  71533. static GENERIC: number;
  71534. /**
  71535. * Represents an XBox controller
  71536. */
  71537. static XBOX: number;
  71538. /**
  71539. * Represents a pose-enabled controller
  71540. */
  71541. static POSE_ENABLED: number;
  71542. /**
  71543. * Specifies whether the left control stick should be Y-inverted
  71544. */
  71545. protected _invertLeftStickY: boolean;
  71546. /**
  71547. * Specifies if the gamepad has been connected
  71548. */
  71549. readonly isConnected: boolean;
  71550. /**
  71551. * Initializes the gamepad
  71552. * @param id The id of the gamepad
  71553. * @param index The index of the gamepad
  71554. * @param browserGamepad The browser gamepad
  71555. * @param leftStickX The x component of the left joystick
  71556. * @param leftStickY The y component of the left joystick
  71557. * @param rightStickX The x component of the right joystick
  71558. * @param rightStickY The y component of the right joystick
  71559. */
  71560. constructor(
  71561. /**
  71562. * The id of the gamepad
  71563. */
  71564. id: string,
  71565. /**
  71566. * The index of the gamepad
  71567. */
  71568. index: number,
  71569. /**
  71570. * The browser gamepad
  71571. */
  71572. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  71573. /**
  71574. * Callback triggered when the left joystick has changed
  71575. * @param callback
  71576. */
  71577. onleftstickchanged(callback: (values: StickValues) => void): void;
  71578. /**
  71579. * Callback triggered when the right joystick has changed
  71580. * @param callback
  71581. */
  71582. onrightstickchanged(callback: (values: StickValues) => void): void;
  71583. /**
  71584. * Gets the left joystick
  71585. */
  71586. /**
  71587. * Sets the left joystick values
  71588. */
  71589. leftStick: StickValues;
  71590. /**
  71591. * Gets the right joystick
  71592. */
  71593. /**
  71594. * Sets the right joystick value
  71595. */
  71596. rightStick: StickValues;
  71597. /**
  71598. * Updates the gamepad joystick positions
  71599. */
  71600. update(): void;
  71601. /**
  71602. * Disposes the gamepad
  71603. */
  71604. dispose(): void;
  71605. }
  71606. /**
  71607. * Represents a generic gamepad
  71608. */
  71609. export class GenericPad extends Gamepad {
  71610. private _buttons;
  71611. private _onbuttondown;
  71612. private _onbuttonup;
  71613. /**
  71614. * Observable triggered when a button has been pressed
  71615. */
  71616. onButtonDownObservable: Observable<number>;
  71617. /**
  71618. * Observable triggered when a button has been released
  71619. */
  71620. onButtonUpObservable: Observable<number>;
  71621. /**
  71622. * Callback triggered when a button has been pressed
  71623. * @param callback Called when a button has been pressed
  71624. */
  71625. onbuttondown(callback: (buttonPressed: number) => void): void;
  71626. /**
  71627. * Callback triggered when a button has been released
  71628. * @param callback Called when a button has been released
  71629. */
  71630. onbuttonup(callback: (buttonReleased: number) => void): void;
  71631. /**
  71632. * Initializes the generic gamepad
  71633. * @param id The id of the generic gamepad
  71634. * @param index The index of the generic gamepad
  71635. * @param browserGamepad The browser gamepad
  71636. */
  71637. constructor(id: string, index: number, browserGamepad: any);
  71638. private _setButtonValue;
  71639. /**
  71640. * Updates the generic gamepad
  71641. */
  71642. update(): void;
  71643. /**
  71644. * Disposes the generic gamepad
  71645. */
  71646. dispose(): void;
  71647. }
  71648. }
  71649. declare module BABYLON {
  71650. /**
  71651. * Defines the types of pose enabled controllers that are supported
  71652. */
  71653. export enum PoseEnabledControllerType {
  71654. /**
  71655. * HTC Vive
  71656. */
  71657. VIVE = 0,
  71658. /**
  71659. * Oculus Rift
  71660. */
  71661. OCULUS = 1,
  71662. /**
  71663. * Windows mixed reality
  71664. */
  71665. WINDOWS = 2,
  71666. /**
  71667. * Samsung gear VR
  71668. */
  71669. GEAR_VR = 3,
  71670. /**
  71671. * Google Daydream
  71672. */
  71673. DAYDREAM = 4,
  71674. /**
  71675. * Generic
  71676. */
  71677. GENERIC = 5
  71678. }
  71679. /**
  71680. * Defines the MutableGamepadButton interface for the state of a gamepad button
  71681. */
  71682. export interface MutableGamepadButton {
  71683. /**
  71684. * Value of the button/trigger
  71685. */
  71686. value: number;
  71687. /**
  71688. * If the button/trigger is currently touched
  71689. */
  71690. touched: boolean;
  71691. /**
  71692. * If the button/trigger is currently pressed
  71693. */
  71694. pressed: boolean;
  71695. }
  71696. /**
  71697. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  71698. * @hidden
  71699. */
  71700. export interface ExtendedGamepadButton extends GamepadButton {
  71701. /**
  71702. * If the button/trigger is currently pressed
  71703. */
  71704. readonly pressed: boolean;
  71705. /**
  71706. * If the button/trigger is currently touched
  71707. */
  71708. readonly touched: boolean;
  71709. /**
  71710. * Value of the button/trigger
  71711. */
  71712. readonly value: number;
  71713. }
  71714. /** @hidden */
  71715. export interface _GamePadFactory {
  71716. /**
  71717. * Returns wether or not the current gamepad can be created for this type of controller.
  71718. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71719. * @returns true if it can be created, otherwise false
  71720. */
  71721. canCreate(gamepadInfo: any): boolean;
  71722. /**
  71723. * Creates a new instance of the Gamepad.
  71724. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71725. * @returns the new gamepad instance
  71726. */
  71727. create(gamepadInfo: any): Gamepad;
  71728. }
  71729. /**
  71730. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71731. */
  71732. export class PoseEnabledControllerHelper {
  71733. /** @hidden */
  71734. static _ControllerFactories: _GamePadFactory[];
  71735. /** @hidden */
  71736. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  71737. /**
  71738. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71739. * @param vrGamepad the gamepad to initialized
  71740. * @returns a vr controller of the type the gamepad identified as
  71741. */
  71742. static InitiateController(vrGamepad: any): Gamepad;
  71743. }
  71744. /**
  71745. * Defines the PoseEnabledController object that contains state of a vr capable controller
  71746. */
  71747. export class PoseEnabledController extends Gamepad implements PoseControlled {
  71748. private _deviceRoomPosition;
  71749. private _deviceRoomRotationQuaternion;
  71750. /**
  71751. * The device position in babylon space
  71752. */
  71753. devicePosition: Vector3;
  71754. /**
  71755. * The device rotation in babylon space
  71756. */
  71757. deviceRotationQuaternion: Quaternion;
  71758. /**
  71759. * The scale factor of the device in babylon space
  71760. */
  71761. deviceScaleFactor: number;
  71762. /**
  71763. * (Likely devicePosition should be used instead) The device position in its room space
  71764. */
  71765. position: Vector3;
  71766. /**
  71767. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  71768. */
  71769. rotationQuaternion: Quaternion;
  71770. /**
  71771. * The type of controller (Eg. Windows mixed reality)
  71772. */
  71773. controllerType: PoseEnabledControllerType;
  71774. protected _calculatedPosition: Vector3;
  71775. private _calculatedRotation;
  71776. /**
  71777. * The raw pose from the device
  71778. */
  71779. rawPose: DevicePose;
  71780. private _trackPosition;
  71781. private _maxRotationDistFromHeadset;
  71782. private _draggedRoomRotation;
  71783. /**
  71784. * @hidden
  71785. */
  71786. _disableTrackPosition(fixedPosition: Vector3): void;
  71787. /**
  71788. * Internal, the mesh attached to the controller
  71789. * @hidden
  71790. */
  71791. _mesh: Nullable<AbstractMesh>;
  71792. private _poseControlledCamera;
  71793. private _leftHandSystemQuaternion;
  71794. /**
  71795. * Internal, matrix used to convert room space to babylon space
  71796. * @hidden
  71797. */
  71798. _deviceToWorld: Matrix;
  71799. /**
  71800. * Node to be used when casting a ray from the controller
  71801. * @hidden
  71802. */
  71803. _pointingPoseNode: Nullable<TransformNode>;
  71804. /**
  71805. * Name of the child mesh that can be used to cast a ray from the controller
  71806. */
  71807. static readonly POINTING_POSE: string;
  71808. /**
  71809. * Creates a new PoseEnabledController from a gamepad
  71810. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  71811. */
  71812. constructor(browserGamepad: any);
  71813. private _workingMatrix;
  71814. /**
  71815. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  71816. */
  71817. update(): void;
  71818. /**
  71819. * Updates only the pose device and mesh without doing any button event checking
  71820. */
  71821. protected _updatePoseAndMesh(): void;
  71822. /**
  71823. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  71824. * @param poseData raw pose fromthe device
  71825. */
  71826. updateFromDevice(poseData: DevicePose): void;
  71827. /**
  71828. * @hidden
  71829. */
  71830. _meshAttachedObservable: Observable<AbstractMesh>;
  71831. /**
  71832. * Attaches a mesh to the controller
  71833. * @param mesh the mesh to be attached
  71834. */
  71835. attachToMesh(mesh: AbstractMesh): void;
  71836. /**
  71837. * Attaches the controllers mesh to a camera
  71838. * @param camera the camera the mesh should be attached to
  71839. */
  71840. attachToPoseControlledCamera(camera: TargetCamera): void;
  71841. /**
  71842. * Disposes of the controller
  71843. */
  71844. dispose(): void;
  71845. /**
  71846. * The mesh that is attached to the controller
  71847. */
  71848. readonly mesh: Nullable<AbstractMesh>;
  71849. /**
  71850. * Gets the ray of the controller in the direction the controller is pointing
  71851. * @param length the length the resulting ray should be
  71852. * @returns a ray in the direction the controller is pointing
  71853. */
  71854. getForwardRay(length?: number): Ray;
  71855. }
  71856. }
  71857. declare module BABYLON {
  71858. /**
  71859. * Defines the WebVRController object that represents controllers tracked in 3D space
  71860. */
  71861. export abstract class WebVRController extends PoseEnabledController {
  71862. /**
  71863. * Internal, the default controller model for the controller
  71864. */
  71865. protected _defaultModel: AbstractMesh;
  71866. /**
  71867. * Fired when the trigger state has changed
  71868. */
  71869. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  71870. /**
  71871. * Fired when the main button state has changed
  71872. */
  71873. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71874. /**
  71875. * Fired when the secondary button state has changed
  71876. */
  71877. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71878. /**
  71879. * Fired when the pad state has changed
  71880. */
  71881. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  71882. /**
  71883. * Fired when controllers stick values have changed
  71884. */
  71885. onPadValuesChangedObservable: Observable<StickValues>;
  71886. /**
  71887. * Array of button availible on the controller
  71888. */
  71889. protected _buttons: Array<MutableGamepadButton>;
  71890. private _onButtonStateChange;
  71891. /**
  71892. * Fired when a controller button's state has changed
  71893. * @param callback the callback containing the button that was modified
  71894. */
  71895. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  71896. /**
  71897. * X and Y axis corrisponding to the controllers joystick
  71898. */
  71899. pad: StickValues;
  71900. /**
  71901. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  71902. */
  71903. hand: string;
  71904. /**
  71905. * The default controller model for the controller
  71906. */
  71907. readonly defaultModel: AbstractMesh;
  71908. /**
  71909. * Creates a new WebVRController from a gamepad
  71910. * @param vrGamepad the gamepad that the WebVRController should be created from
  71911. */
  71912. constructor(vrGamepad: any);
  71913. /**
  71914. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  71915. */
  71916. update(): void;
  71917. /**
  71918. * Function to be called when a button is modified
  71919. */
  71920. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  71921. /**
  71922. * Loads a mesh and attaches it to the controller
  71923. * @param scene the scene the mesh should be added to
  71924. * @param meshLoaded callback for when the mesh has been loaded
  71925. */
  71926. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  71927. private _setButtonValue;
  71928. private _changes;
  71929. private _checkChanges;
  71930. /**
  71931. * Disposes of th webVRCOntroller
  71932. */
  71933. dispose(): void;
  71934. }
  71935. }
  71936. declare module BABYLON {
  71937. /**
  71938. * The HemisphericLight simulates the ambient environment light,
  71939. * so the passed direction is the light reflection direction, not the incoming direction.
  71940. */
  71941. export class HemisphericLight extends Light {
  71942. /**
  71943. * The groundColor is the light in the opposite direction to the one specified during creation.
  71944. * 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.
  71945. */
  71946. groundColor: Color3;
  71947. /**
  71948. * The light reflection direction, not the incoming direction.
  71949. */
  71950. direction: Vector3;
  71951. /**
  71952. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  71953. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  71954. * The HemisphericLight can't cast shadows.
  71955. * Documentation : https://doc.babylonjs.com/babylon101/lights
  71956. * @param name The friendly name of the light
  71957. * @param direction The direction of the light reflection
  71958. * @param scene The scene the light belongs to
  71959. */
  71960. constructor(name: string, direction: Vector3, scene: Scene);
  71961. protected _buildUniformLayout(): void;
  71962. /**
  71963. * Returns the string "HemisphericLight".
  71964. * @return The class name
  71965. */
  71966. getClassName(): string;
  71967. /**
  71968. * Sets the HemisphericLight direction towards the passed target (Vector3).
  71969. * Returns the updated direction.
  71970. * @param target The target the direction should point to
  71971. * @return The computed direction
  71972. */
  71973. setDirectionToTarget(target: Vector3): Vector3;
  71974. /**
  71975. * Returns the shadow generator associated to the light.
  71976. * @returns Always null for hemispheric lights because it does not support shadows.
  71977. */
  71978. getShadowGenerator(): Nullable<IShadowGenerator>;
  71979. /**
  71980. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  71981. * @param effect The effect to update
  71982. * @param lightIndex The index of the light in the effect to update
  71983. * @returns The hemispheric light
  71984. */
  71985. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  71986. /**
  71987. * Computes the world matrix of the node
  71988. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71989. * @param useWasUpdatedFlag defines a reserved property
  71990. * @returns the world matrix
  71991. */
  71992. computeWorldMatrix(): Matrix;
  71993. /**
  71994. * Returns the integer 3.
  71995. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  71996. */
  71997. getTypeID(): number;
  71998. /**
  71999. * Prepares the list of defines specific to the light type.
  72000. * @param defines the list of defines
  72001. * @param lightIndex defines the index of the light for the effect
  72002. */
  72003. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72004. }
  72005. }
  72006. declare module BABYLON {
  72007. /** @hidden */
  72008. export var vrMultiviewToSingleviewPixelShader: {
  72009. name: string;
  72010. shader: string;
  72011. };
  72012. }
  72013. declare module BABYLON {
  72014. /**
  72015. * Renders to multiple views with a single draw call
  72016. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72017. */
  72018. export class MultiviewRenderTarget extends RenderTargetTexture {
  72019. /**
  72020. * Creates a multiview render target
  72021. * @param scene scene used with the render target
  72022. * @param size the size of the render target (used for each view)
  72023. */
  72024. constructor(scene: Scene, size?: number | {
  72025. width: number;
  72026. height: number;
  72027. } | {
  72028. ratio: number;
  72029. });
  72030. /**
  72031. * @hidden
  72032. * @param faceIndex the face index, if its a cube texture
  72033. */
  72034. _bindFrameBuffer(faceIndex?: number): void;
  72035. /**
  72036. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72037. * @returns the view count
  72038. */
  72039. getViewCount(): number;
  72040. }
  72041. }
  72042. declare module BABYLON {
  72043. interface Engine {
  72044. /**
  72045. * Creates a new multiview render target
  72046. * @param width defines the width of the texture
  72047. * @param height defines the height of the texture
  72048. * @returns the created multiview texture
  72049. */
  72050. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72051. /**
  72052. * Binds a multiview framebuffer to be drawn to
  72053. * @param multiviewTexture texture to bind
  72054. */
  72055. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72056. }
  72057. interface Camera {
  72058. /**
  72059. * @hidden
  72060. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  72061. */
  72062. _useMultiviewToSingleView: boolean;
  72063. /**
  72064. * @hidden
  72065. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  72066. */
  72067. _multiviewTexture: Nullable<RenderTargetTexture>;
  72068. /**
  72069. * @hidden
  72070. * ensures the multiview texture of the camera exists and has the specified width/height
  72071. * @param width height to set on the multiview texture
  72072. * @param height width to set on the multiview texture
  72073. */
  72074. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  72075. }
  72076. interface Scene {
  72077. /** @hidden */
  72078. _transformMatrixR: Matrix;
  72079. /** @hidden */
  72080. _multiviewSceneUbo: Nullable<UniformBuffer>;
  72081. /** @hidden */
  72082. _createMultiviewUbo(): void;
  72083. /** @hidden */
  72084. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  72085. /** @hidden */
  72086. _renderMultiviewToSingleView(camera: Camera): void;
  72087. }
  72088. }
  72089. declare module BABYLON {
  72090. /**
  72091. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  72092. * This will not be used for webXR as it supports displaying texture arrays directly
  72093. */
  72094. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  72095. /**
  72096. * Initializes a VRMultiviewToSingleview
  72097. * @param name name of the post process
  72098. * @param camera camera to be applied to
  72099. * @param scaleFactor scaling factor to the size of the output texture
  72100. */
  72101. constructor(name: string, camera: Camera, scaleFactor: number);
  72102. }
  72103. }
  72104. declare module BABYLON {
  72105. /**
  72106. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  72107. * IMPORTANT!! The data is right-hand data.
  72108. * @export
  72109. * @interface DevicePose
  72110. */
  72111. export interface DevicePose {
  72112. /**
  72113. * The position of the device, values in array are [x,y,z].
  72114. */
  72115. readonly position: Nullable<Float32Array>;
  72116. /**
  72117. * The linearVelocity of the device, values in array are [x,y,z].
  72118. */
  72119. readonly linearVelocity: Nullable<Float32Array>;
  72120. /**
  72121. * The linearAcceleration of the device, values in array are [x,y,z].
  72122. */
  72123. readonly linearAcceleration: Nullable<Float32Array>;
  72124. /**
  72125. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  72126. */
  72127. readonly orientation: Nullable<Float32Array>;
  72128. /**
  72129. * The angularVelocity of the device, values in array are [x,y,z].
  72130. */
  72131. readonly angularVelocity: Nullable<Float32Array>;
  72132. /**
  72133. * The angularAcceleration of the device, values in array are [x,y,z].
  72134. */
  72135. readonly angularAcceleration: Nullable<Float32Array>;
  72136. }
  72137. /**
  72138. * Interface representing a pose controlled object in Babylon.
  72139. * A pose controlled object has both regular pose values as well as pose values
  72140. * from an external device such as a VR head mounted display
  72141. */
  72142. export interface PoseControlled {
  72143. /**
  72144. * The position of the object in babylon space.
  72145. */
  72146. position: Vector3;
  72147. /**
  72148. * The rotation quaternion of the object in babylon space.
  72149. */
  72150. rotationQuaternion: Quaternion;
  72151. /**
  72152. * The position of the device in babylon space.
  72153. */
  72154. devicePosition?: Vector3;
  72155. /**
  72156. * The rotation quaternion of the device in babylon space.
  72157. */
  72158. deviceRotationQuaternion: Quaternion;
  72159. /**
  72160. * The raw pose coming from the device.
  72161. */
  72162. rawPose: Nullable<DevicePose>;
  72163. /**
  72164. * The scale of the device to be used when translating from device space to babylon space.
  72165. */
  72166. deviceScaleFactor: number;
  72167. /**
  72168. * Updates the poseControlled values based on the input device pose.
  72169. * @param poseData the pose data to update the object with
  72170. */
  72171. updateFromDevice(poseData: DevicePose): void;
  72172. }
  72173. /**
  72174. * Set of options to customize the webVRCamera
  72175. */
  72176. export interface WebVROptions {
  72177. /**
  72178. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  72179. */
  72180. trackPosition?: boolean;
  72181. /**
  72182. * Sets the scale of the vrDevice in babylon space. (default: 1)
  72183. */
  72184. positionScale?: number;
  72185. /**
  72186. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  72187. */
  72188. displayName?: string;
  72189. /**
  72190. * Should the native controller meshes be initialized. (default: true)
  72191. */
  72192. controllerMeshes?: boolean;
  72193. /**
  72194. * Creating a default HemiLight only on controllers. (default: true)
  72195. */
  72196. defaultLightingOnControllers?: boolean;
  72197. /**
  72198. * If you don't want to use the default VR button of the helper. (default: false)
  72199. */
  72200. useCustomVRButton?: boolean;
  72201. /**
  72202. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  72203. */
  72204. customVRButton?: HTMLButtonElement;
  72205. /**
  72206. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  72207. */
  72208. rayLength?: number;
  72209. /**
  72210. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  72211. */
  72212. defaultHeight?: number;
  72213. /**
  72214. * If multiview should be used if availible (default: false)
  72215. */
  72216. useMultiview?: boolean;
  72217. }
  72218. /**
  72219. * This represents a WebVR camera.
  72220. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  72221. * @example http://doc.babylonjs.com/how_to/webvr_camera
  72222. */
  72223. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  72224. private webVROptions;
  72225. /**
  72226. * @hidden
  72227. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  72228. */
  72229. _vrDevice: any;
  72230. /**
  72231. * The rawPose of the vrDevice.
  72232. */
  72233. rawPose: Nullable<DevicePose>;
  72234. private _onVREnabled;
  72235. private _specsVersion;
  72236. private _attached;
  72237. private _frameData;
  72238. protected _descendants: Array<Node>;
  72239. private _deviceRoomPosition;
  72240. /** @hidden */
  72241. _deviceRoomRotationQuaternion: Quaternion;
  72242. private _standingMatrix;
  72243. /**
  72244. * Represents device position in babylon space.
  72245. */
  72246. devicePosition: Vector3;
  72247. /**
  72248. * Represents device rotation in babylon space.
  72249. */
  72250. deviceRotationQuaternion: Quaternion;
  72251. /**
  72252. * The scale of the device to be used when translating from device space to babylon space.
  72253. */
  72254. deviceScaleFactor: number;
  72255. private _deviceToWorld;
  72256. private _worldToDevice;
  72257. /**
  72258. * References to the webVR controllers for the vrDevice.
  72259. */
  72260. controllers: Array<WebVRController>;
  72261. /**
  72262. * Emits an event when a controller is attached.
  72263. */
  72264. onControllersAttachedObservable: Observable<WebVRController[]>;
  72265. /**
  72266. * Emits an event when a controller's mesh has been loaded;
  72267. */
  72268. onControllerMeshLoadedObservable: Observable<WebVRController>;
  72269. /**
  72270. * Emits an event when the HMD's pose has been updated.
  72271. */
  72272. onPoseUpdatedFromDeviceObservable: Observable<any>;
  72273. private _poseSet;
  72274. /**
  72275. * If the rig cameras be used as parent instead of this camera.
  72276. */
  72277. rigParenting: boolean;
  72278. private _lightOnControllers;
  72279. private _defaultHeight?;
  72280. /**
  72281. * Instantiates a WebVRFreeCamera.
  72282. * @param name The name of the WebVRFreeCamera
  72283. * @param position The starting anchor position for the camera
  72284. * @param scene The scene the camera belongs to
  72285. * @param webVROptions a set of customizable options for the webVRCamera
  72286. */
  72287. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  72288. /**
  72289. * Gets the device distance from the ground in meters.
  72290. * @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.
  72291. */
  72292. deviceDistanceToRoomGround(): number;
  72293. /**
  72294. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72295. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  72296. */
  72297. useStandingMatrix(callback?: (bool: boolean) => void): void;
  72298. /**
  72299. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72300. * @returns A promise with a boolean set to if the standing matrix is supported.
  72301. */
  72302. useStandingMatrixAsync(): Promise<boolean>;
  72303. /**
  72304. * Disposes the camera
  72305. */
  72306. dispose(): void;
  72307. /**
  72308. * Gets a vrController by name.
  72309. * @param name The name of the controller to retreive
  72310. * @returns the controller matching the name specified or null if not found
  72311. */
  72312. getControllerByName(name: string): Nullable<WebVRController>;
  72313. private _leftController;
  72314. /**
  72315. * The controller corrisponding to the users left hand.
  72316. */
  72317. readonly leftController: Nullable<WebVRController>;
  72318. private _rightController;
  72319. /**
  72320. * The controller corrisponding to the users right hand.
  72321. */
  72322. readonly rightController: Nullable<WebVRController>;
  72323. /**
  72324. * Casts a ray forward from the vrCamera's gaze.
  72325. * @param length Length of the ray (default: 100)
  72326. * @returns the ray corrisponding to the gaze
  72327. */
  72328. getForwardRay(length?: number): Ray;
  72329. /**
  72330. * @hidden
  72331. * Updates the camera based on device's frame data
  72332. */
  72333. _checkInputs(): void;
  72334. /**
  72335. * Updates the poseControlled values based on the input device pose.
  72336. * @param poseData Pose coming from the device
  72337. */
  72338. updateFromDevice(poseData: DevicePose): void;
  72339. private _htmlElementAttached;
  72340. private _detachIfAttached;
  72341. /**
  72342. * WebVR's attach control will start broadcasting frames to the device.
  72343. * Note that in certain browsers (chrome for example) this function must be called
  72344. * within a user-interaction callback. Example:
  72345. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  72346. *
  72347. * @param element html element to attach the vrDevice to
  72348. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  72349. */
  72350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72351. /**
  72352. * Detaches the camera from the html element and disables VR
  72353. *
  72354. * @param element html element to detach from
  72355. */
  72356. detachControl(element: HTMLElement): void;
  72357. /**
  72358. * @returns the name of this class
  72359. */
  72360. getClassName(): string;
  72361. /**
  72362. * Calls resetPose on the vrDisplay
  72363. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  72364. */
  72365. resetToCurrentRotation(): void;
  72366. /**
  72367. * @hidden
  72368. * Updates the rig cameras (left and right eye)
  72369. */
  72370. _updateRigCameras(): void;
  72371. private _workingVector;
  72372. private _oneVector;
  72373. private _workingMatrix;
  72374. private updateCacheCalled;
  72375. private _correctPositionIfNotTrackPosition;
  72376. /**
  72377. * @hidden
  72378. * Updates the cached values of the camera
  72379. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  72380. */
  72381. _updateCache(ignoreParentClass?: boolean): void;
  72382. /**
  72383. * @hidden
  72384. * Get current device position in babylon world
  72385. */
  72386. _computeDevicePosition(): void;
  72387. /**
  72388. * Updates the current device position and rotation in the babylon world
  72389. */
  72390. update(): void;
  72391. /**
  72392. * @hidden
  72393. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  72394. * @returns an identity matrix
  72395. */
  72396. _getViewMatrix(): Matrix;
  72397. private _tmpMatrix;
  72398. /**
  72399. * This function is called by the two RIG cameras.
  72400. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  72401. * @hidden
  72402. */
  72403. _getWebVRViewMatrix(): Matrix;
  72404. /** @hidden */
  72405. _getWebVRProjectionMatrix(): Matrix;
  72406. private _onGamepadConnectedObserver;
  72407. private _onGamepadDisconnectedObserver;
  72408. private _updateCacheWhenTrackingDisabledObserver;
  72409. /**
  72410. * Initializes the controllers and their meshes
  72411. */
  72412. initControllers(): void;
  72413. }
  72414. }
  72415. declare module BABYLON {
  72416. /**
  72417. * Size options for a post process
  72418. */
  72419. export type PostProcessOptions = {
  72420. width: number;
  72421. height: number;
  72422. };
  72423. /**
  72424. * PostProcess can be used to apply a shader to a texture after it has been rendered
  72425. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72426. */
  72427. export class PostProcess {
  72428. /** Name of the PostProcess. */
  72429. name: string;
  72430. /**
  72431. * Gets or sets the unique id of the post process
  72432. */
  72433. uniqueId: number;
  72434. /**
  72435. * Width of the texture to apply the post process on
  72436. */
  72437. width: number;
  72438. /**
  72439. * Height of the texture to apply the post process on
  72440. */
  72441. height: number;
  72442. /**
  72443. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  72444. * @hidden
  72445. */
  72446. _outputTexture: Nullable<InternalTexture>;
  72447. /**
  72448. * Sampling mode used by the shader
  72449. * See https://doc.babylonjs.com/classes/3.1/texture
  72450. */
  72451. renderTargetSamplingMode: number;
  72452. /**
  72453. * Clear color to use when screen clearing
  72454. */
  72455. clearColor: Color4;
  72456. /**
  72457. * If the buffer needs to be cleared before applying the post process. (default: true)
  72458. * Should be set to false if shader will overwrite all previous pixels.
  72459. */
  72460. autoClear: boolean;
  72461. /**
  72462. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  72463. */
  72464. alphaMode: number;
  72465. /**
  72466. * Sets the setAlphaBlendConstants of the babylon engine
  72467. */
  72468. alphaConstants: Color4;
  72469. /**
  72470. * Animations to be used for the post processing
  72471. */
  72472. animations: Animation[];
  72473. /**
  72474. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  72475. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  72476. */
  72477. enablePixelPerfectMode: boolean;
  72478. /**
  72479. * Force the postprocess to be applied without taking in account viewport
  72480. */
  72481. forceFullscreenViewport: boolean;
  72482. /**
  72483. * List of inspectable custom properties (used by the Inspector)
  72484. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72485. */
  72486. inspectableCustomProperties: IInspectable[];
  72487. /**
  72488. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  72489. *
  72490. * | Value | Type | Description |
  72491. * | ----- | ----------------------------------- | ----------- |
  72492. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  72493. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  72494. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  72495. *
  72496. */
  72497. scaleMode: number;
  72498. /**
  72499. * Force textures to be a power of two (default: false)
  72500. */
  72501. alwaysForcePOT: boolean;
  72502. private _samples;
  72503. /**
  72504. * Number of sample textures (default: 1)
  72505. */
  72506. samples: number;
  72507. /**
  72508. * Modify the scale of the post process to be the same as the viewport (default: false)
  72509. */
  72510. adaptScaleToCurrentViewport: boolean;
  72511. private _camera;
  72512. private _scene;
  72513. private _engine;
  72514. private _options;
  72515. private _reusable;
  72516. private _textureType;
  72517. /**
  72518. * Smart array of input and output textures for the post process.
  72519. * @hidden
  72520. */
  72521. _textures: SmartArray<InternalTexture>;
  72522. /**
  72523. * The index in _textures that corresponds to the output texture.
  72524. * @hidden
  72525. */
  72526. _currentRenderTextureInd: number;
  72527. private _effect;
  72528. private _samplers;
  72529. private _fragmentUrl;
  72530. private _vertexUrl;
  72531. private _parameters;
  72532. private _scaleRatio;
  72533. protected _indexParameters: any;
  72534. private _shareOutputWithPostProcess;
  72535. private _texelSize;
  72536. private _forcedOutputTexture;
  72537. /**
  72538. * Returns the fragment url or shader name used in the post process.
  72539. * @returns the fragment url or name in the shader store.
  72540. */
  72541. getEffectName(): string;
  72542. /**
  72543. * An event triggered when the postprocess is activated.
  72544. */
  72545. onActivateObservable: Observable<Camera>;
  72546. private _onActivateObserver;
  72547. /**
  72548. * A function that is added to the onActivateObservable
  72549. */
  72550. onActivate: Nullable<(camera: Camera) => void>;
  72551. /**
  72552. * An event triggered when the postprocess changes its size.
  72553. */
  72554. onSizeChangedObservable: Observable<PostProcess>;
  72555. private _onSizeChangedObserver;
  72556. /**
  72557. * A function that is added to the onSizeChangedObservable
  72558. */
  72559. onSizeChanged: (postProcess: PostProcess) => void;
  72560. /**
  72561. * An event triggered when the postprocess applies its effect.
  72562. */
  72563. onApplyObservable: Observable<Effect>;
  72564. private _onApplyObserver;
  72565. /**
  72566. * A function that is added to the onApplyObservable
  72567. */
  72568. onApply: (effect: Effect) => void;
  72569. /**
  72570. * An event triggered before rendering the postprocess
  72571. */
  72572. onBeforeRenderObservable: Observable<Effect>;
  72573. private _onBeforeRenderObserver;
  72574. /**
  72575. * A function that is added to the onBeforeRenderObservable
  72576. */
  72577. onBeforeRender: (effect: Effect) => void;
  72578. /**
  72579. * An event triggered after rendering the postprocess
  72580. */
  72581. onAfterRenderObservable: Observable<Effect>;
  72582. private _onAfterRenderObserver;
  72583. /**
  72584. * A function that is added to the onAfterRenderObservable
  72585. */
  72586. onAfterRender: (efect: Effect) => void;
  72587. /**
  72588. * 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
  72589. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  72590. */
  72591. inputTexture: InternalTexture;
  72592. /**
  72593. * Gets the camera which post process is applied to.
  72594. * @returns The camera the post process is applied to.
  72595. */
  72596. getCamera(): Camera;
  72597. /**
  72598. * Gets the texel size of the postprocess.
  72599. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  72600. */
  72601. readonly texelSize: Vector2;
  72602. /**
  72603. * Creates a new instance PostProcess
  72604. * @param name The name of the PostProcess.
  72605. * @param fragmentUrl The url of the fragment shader to be used.
  72606. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  72607. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  72608. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72609. * @param camera The camera to apply the render pass to.
  72610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72611. * @param engine The engine which the post process will be applied. (default: current engine)
  72612. * @param reusable If the post process can be reused on the same frame. (default: false)
  72613. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  72614. * @param textureType Type of textures used when performing the post process. (default: 0)
  72615. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  72616. * @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
  72617. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  72618. */
  72619. constructor(
  72620. /** Name of the PostProcess. */
  72621. 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);
  72622. /**
  72623. * Gets a string idenfifying the name of the class
  72624. * @returns "PostProcess" string
  72625. */
  72626. getClassName(): string;
  72627. /**
  72628. * Gets the engine which this post process belongs to.
  72629. * @returns The engine the post process was enabled with.
  72630. */
  72631. getEngine(): Engine;
  72632. /**
  72633. * The effect that is created when initializing the post process.
  72634. * @returns The created effect corrisponding the the postprocess.
  72635. */
  72636. getEffect(): Effect;
  72637. /**
  72638. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  72639. * @param postProcess The post process to share the output with.
  72640. * @returns This post process.
  72641. */
  72642. shareOutputWith(postProcess: PostProcess): PostProcess;
  72643. /**
  72644. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  72645. * This should be called if the post process that shares output with this post process is disabled/disposed.
  72646. */
  72647. useOwnOutput(): void;
  72648. /**
  72649. * Updates the effect with the current post process compile time values and recompiles the shader.
  72650. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72651. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72652. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72653. * @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
  72654. * @param onCompiled Called when the shader has been compiled.
  72655. * @param onError Called if there is an error when compiling a shader.
  72656. */
  72657. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72658. /**
  72659. * The post process is reusable if it can be used multiple times within one frame.
  72660. * @returns If the post process is reusable
  72661. */
  72662. isReusable(): boolean;
  72663. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  72664. markTextureDirty(): void;
  72665. /**
  72666. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  72667. * 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.
  72668. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  72669. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  72670. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  72671. * @returns The target texture that was bound to be written to.
  72672. */
  72673. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  72674. /**
  72675. * If the post process is supported.
  72676. */
  72677. readonly isSupported: boolean;
  72678. /**
  72679. * The aspect ratio of the output texture.
  72680. */
  72681. readonly aspectRatio: number;
  72682. /**
  72683. * Get a value indicating if the post-process is ready to be used
  72684. * @returns true if the post-process is ready (shader is compiled)
  72685. */
  72686. isReady(): boolean;
  72687. /**
  72688. * Binds all textures and uniforms to the shader, this will be run on every pass.
  72689. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  72690. */
  72691. apply(): Nullable<Effect>;
  72692. private _disposeTextures;
  72693. /**
  72694. * Disposes the post process.
  72695. * @param camera The camera to dispose the post process on.
  72696. */
  72697. dispose(camera?: Camera): void;
  72698. }
  72699. }
  72700. declare module BABYLON {
  72701. /**
  72702. * PostProcessManager is used to manage one or more post processes or post process pipelines
  72703. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72704. */
  72705. export class PostProcessManager {
  72706. private _scene;
  72707. private _indexBuffer;
  72708. private _vertexBuffers;
  72709. /**
  72710. * Creates a new instance PostProcess
  72711. * @param scene The scene that the post process is associated with.
  72712. */
  72713. constructor(scene: Scene);
  72714. private _prepareBuffers;
  72715. private _buildIndexBuffer;
  72716. /**
  72717. * Rebuilds the vertex buffers of the manager.
  72718. * @hidden
  72719. */
  72720. _rebuild(): void;
  72721. /**
  72722. * Prepares a frame to be run through a post process.
  72723. * @param sourceTexture The input texture to the post procesess. (default: null)
  72724. * @param postProcesses An array of post processes to be run. (default: null)
  72725. * @returns True if the post processes were able to be run.
  72726. * @hidden
  72727. */
  72728. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  72729. /**
  72730. * Manually render a set of post processes to a texture.
  72731. * @param postProcesses An array of post processes to be run.
  72732. * @param targetTexture The target texture to render to.
  72733. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  72734. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  72735. * @param lodLevel defines which lod of the texture to render to
  72736. */
  72737. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  72738. /**
  72739. * Finalize the result of the output of the postprocesses.
  72740. * @param doNotPresent If true the result will not be displayed to the screen.
  72741. * @param targetTexture The target texture to render to.
  72742. * @param faceIndex The index of the face to bind the target texture to.
  72743. * @param postProcesses The array of post processes to render.
  72744. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  72745. * @hidden
  72746. */
  72747. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  72748. /**
  72749. * Disposes of the post process manager.
  72750. */
  72751. dispose(): void;
  72752. }
  72753. }
  72754. declare module BABYLON {
  72755. interface AbstractScene {
  72756. /**
  72757. * The list of layers (background and foreground) of the scene
  72758. */
  72759. layers: Array<Layer>;
  72760. }
  72761. /**
  72762. * Defines the layer scene component responsible to manage any layers
  72763. * in a given scene.
  72764. */
  72765. export class LayerSceneComponent implements ISceneComponent {
  72766. /**
  72767. * The component name helpfull to identify the component in the list of scene components.
  72768. */
  72769. readonly name: string;
  72770. /**
  72771. * The scene the component belongs to.
  72772. */
  72773. scene: Scene;
  72774. private _engine;
  72775. /**
  72776. * Creates a new instance of the component for the given scene
  72777. * @param scene Defines the scene to register the component in
  72778. */
  72779. constructor(scene: Scene);
  72780. /**
  72781. * Registers the component in a given scene
  72782. */
  72783. register(): void;
  72784. /**
  72785. * Rebuilds the elements related to this component in case of
  72786. * context lost for instance.
  72787. */
  72788. rebuild(): void;
  72789. /**
  72790. * Disposes the component and the associated ressources.
  72791. */
  72792. dispose(): void;
  72793. private _draw;
  72794. private _drawCameraPredicate;
  72795. private _drawCameraBackground;
  72796. private _drawCameraForeground;
  72797. private _drawRenderTargetPredicate;
  72798. private _drawRenderTargetBackground;
  72799. private _drawRenderTargetForeground;
  72800. }
  72801. }
  72802. declare module BABYLON {
  72803. /** @hidden */
  72804. export var layerPixelShader: {
  72805. name: string;
  72806. shader: string;
  72807. };
  72808. }
  72809. declare module BABYLON {
  72810. /** @hidden */
  72811. export var layerVertexShader: {
  72812. name: string;
  72813. shader: string;
  72814. };
  72815. }
  72816. declare module BABYLON {
  72817. /**
  72818. * This represents a full screen 2d layer.
  72819. * This can be useful to display a picture in the background of your scene for instance.
  72820. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72821. */
  72822. export class Layer {
  72823. /**
  72824. * Define the name of the layer.
  72825. */
  72826. name: string;
  72827. /**
  72828. * Define the texture the layer should display.
  72829. */
  72830. texture: Nullable<Texture>;
  72831. /**
  72832. * Is the layer in background or foreground.
  72833. */
  72834. isBackground: boolean;
  72835. /**
  72836. * Define the color of the layer (instead of texture).
  72837. */
  72838. color: Color4;
  72839. /**
  72840. * Define the scale of the layer in order to zoom in out of the texture.
  72841. */
  72842. scale: Vector2;
  72843. /**
  72844. * Define an offset for the layer in order to shift the texture.
  72845. */
  72846. offset: Vector2;
  72847. /**
  72848. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  72849. */
  72850. alphaBlendingMode: number;
  72851. /**
  72852. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  72853. * Alpha test will not mix with the background color in case of transparency.
  72854. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  72855. */
  72856. alphaTest: boolean;
  72857. /**
  72858. * Define a mask to restrict the layer to only some of the scene cameras.
  72859. */
  72860. layerMask: number;
  72861. /**
  72862. * Define the list of render target the layer is visible into.
  72863. */
  72864. renderTargetTextures: RenderTargetTexture[];
  72865. /**
  72866. * Define if the layer is only used in renderTarget or if it also
  72867. * renders in the main frame buffer of the canvas.
  72868. */
  72869. renderOnlyInRenderTargetTextures: boolean;
  72870. private _scene;
  72871. private _vertexBuffers;
  72872. private _indexBuffer;
  72873. private _effect;
  72874. private _alphaTestEffect;
  72875. /**
  72876. * An event triggered when the layer is disposed.
  72877. */
  72878. onDisposeObservable: Observable<Layer>;
  72879. private _onDisposeObserver;
  72880. /**
  72881. * Back compatibility with callback before the onDisposeObservable existed.
  72882. * The set callback will be triggered when the layer has been disposed.
  72883. */
  72884. onDispose: () => void;
  72885. /**
  72886. * An event triggered before rendering the scene
  72887. */
  72888. onBeforeRenderObservable: Observable<Layer>;
  72889. private _onBeforeRenderObserver;
  72890. /**
  72891. * Back compatibility with callback before the onBeforeRenderObservable existed.
  72892. * The set callback will be triggered just before rendering the layer.
  72893. */
  72894. onBeforeRender: () => void;
  72895. /**
  72896. * An event triggered after rendering the scene
  72897. */
  72898. onAfterRenderObservable: Observable<Layer>;
  72899. private _onAfterRenderObserver;
  72900. /**
  72901. * Back compatibility with callback before the onAfterRenderObservable existed.
  72902. * The set callback will be triggered just after rendering the layer.
  72903. */
  72904. onAfterRender: () => void;
  72905. /**
  72906. * Instantiates a new layer.
  72907. * This represents a full screen 2d layer.
  72908. * This can be useful to display a picture in the background of your scene for instance.
  72909. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72910. * @param name Define the name of the layer in the scene
  72911. * @param imgUrl Define the url of the texture to display in the layer
  72912. * @param scene Define the scene the layer belongs to
  72913. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  72914. * @param color Defines a color for the layer
  72915. */
  72916. constructor(
  72917. /**
  72918. * Define the name of the layer.
  72919. */
  72920. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  72921. private _createIndexBuffer;
  72922. /** @hidden */
  72923. _rebuild(): void;
  72924. /**
  72925. * Renders the layer in the scene.
  72926. */
  72927. render(): void;
  72928. /**
  72929. * Disposes and releases the associated ressources.
  72930. */
  72931. dispose(): void;
  72932. }
  72933. }
  72934. declare module BABYLON {
  72935. interface AbstractScene {
  72936. /**
  72937. * The list of procedural textures added to the scene
  72938. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72939. */
  72940. proceduralTextures: Array<ProceduralTexture>;
  72941. }
  72942. /**
  72943. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  72944. * in a given scene.
  72945. */
  72946. export class ProceduralTextureSceneComponent implements ISceneComponent {
  72947. /**
  72948. * The component name helpfull to identify the component in the list of scene components.
  72949. */
  72950. readonly name: string;
  72951. /**
  72952. * The scene the component belongs to.
  72953. */
  72954. scene: Scene;
  72955. /**
  72956. * Creates a new instance of the component for the given scene
  72957. * @param scene Defines the scene to register the component in
  72958. */
  72959. constructor(scene: Scene);
  72960. /**
  72961. * Registers the component in a given scene
  72962. */
  72963. register(): void;
  72964. /**
  72965. * Rebuilds the elements related to this component in case of
  72966. * context lost for instance.
  72967. */
  72968. rebuild(): void;
  72969. /**
  72970. * Disposes the component and the associated ressources.
  72971. */
  72972. dispose(): void;
  72973. private _beforeClear;
  72974. }
  72975. }
  72976. declare module BABYLON {
  72977. /** @hidden */
  72978. export var proceduralVertexShader: {
  72979. name: string;
  72980. shader: string;
  72981. };
  72982. }
  72983. declare module BABYLON {
  72984. /**
  72985. * 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.
  72986. * This is the base class of any Procedural texture and contains most of the shareable code.
  72987. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72988. */
  72989. export class ProceduralTexture extends Texture {
  72990. isCube: boolean;
  72991. /**
  72992. * Define if the texture is enabled or not (disabled texture will not render)
  72993. */
  72994. isEnabled: boolean;
  72995. /**
  72996. * Define if the texture must be cleared before rendering (default is true)
  72997. */
  72998. autoClear: boolean;
  72999. /**
  73000. * Callback called when the texture is generated
  73001. */
  73002. onGenerated: () => void;
  73003. /**
  73004. * Event raised when the texture is generated
  73005. */
  73006. onGeneratedObservable: Observable<ProceduralTexture>;
  73007. /** @hidden */
  73008. _generateMipMaps: boolean;
  73009. /** @hidden **/
  73010. _effect: Effect;
  73011. /** @hidden */
  73012. _textures: {
  73013. [key: string]: Texture;
  73014. };
  73015. private _size;
  73016. private _currentRefreshId;
  73017. private _refreshRate;
  73018. private _vertexBuffers;
  73019. private _indexBuffer;
  73020. private _uniforms;
  73021. private _samplers;
  73022. private _fragment;
  73023. private _floats;
  73024. private _ints;
  73025. private _floatsArrays;
  73026. private _colors3;
  73027. private _colors4;
  73028. private _vectors2;
  73029. private _vectors3;
  73030. private _matrices;
  73031. private _fallbackTexture;
  73032. private _fallbackTextureUsed;
  73033. private _engine;
  73034. private _cachedDefines;
  73035. private _contentUpdateId;
  73036. private _contentData;
  73037. /**
  73038. * Instantiates a new procedural texture.
  73039. * 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.
  73040. * This is the base class of any Procedural texture and contains most of the shareable code.
  73041. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73042. * @param name Define the name of the texture
  73043. * @param size Define the size of the texture to create
  73044. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  73045. * @param scene Define the scene the texture belongs to
  73046. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  73047. * @param generateMipMaps Define if the texture should creates mip maps or not
  73048. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  73049. */
  73050. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  73051. /**
  73052. * The effect that is created when initializing the post process.
  73053. * @returns The created effect corrisponding the the postprocess.
  73054. */
  73055. getEffect(): Effect;
  73056. /**
  73057. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  73058. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  73059. */
  73060. getContent(): Nullable<ArrayBufferView>;
  73061. private _createIndexBuffer;
  73062. /** @hidden */
  73063. _rebuild(): void;
  73064. /**
  73065. * Resets the texture in order to recreate its associated resources.
  73066. * This can be called in case of context loss
  73067. */
  73068. reset(): void;
  73069. protected _getDefines(): string;
  73070. /**
  73071. * Is the texture ready to be used ? (rendered at least once)
  73072. * @returns true if ready, otherwise, false.
  73073. */
  73074. isReady(): boolean;
  73075. /**
  73076. * Resets the refresh counter of the texture and start bak from scratch.
  73077. * Could be useful to regenerate the texture if it is setup to render only once.
  73078. */
  73079. resetRefreshCounter(): void;
  73080. /**
  73081. * Set the fragment shader to use in order to render the texture.
  73082. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  73083. */
  73084. setFragment(fragment: any): void;
  73085. /**
  73086. * Define the refresh rate of the texture or the rendering frequency.
  73087. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73088. */
  73089. refreshRate: number;
  73090. /** @hidden */
  73091. _shouldRender(): boolean;
  73092. /**
  73093. * Get the size the texture is rendering at.
  73094. * @returns the size (texture is always squared)
  73095. */
  73096. getRenderSize(): number;
  73097. /**
  73098. * Resize the texture to new value.
  73099. * @param size Define the new size the texture should have
  73100. * @param generateMipMaps Define whether the new texture should create mip maps
  73101. */
  73102. resize(size: number, generateMipMaps: boolean): void;
  73103. private _checkUniform;
  73104. /**
  73105. * Set a texture in the shader program used to render.
  73106. * @param name Define the name of the uniform samplers as defined in the shader
  73107. * @param texture Define the texture to bind to this sampler
  73108. * @return the texture itself allowing "fluent" like uniform updates
  73109. */
  73110. setTexture(name: string, texture: Texture): ProceduralTexture;
  73111. /**
  73112. * Set a float in the shader.
  73113. * @param name Define the name of the uniform as defined in the shader
  73114. * @param value Define the value to give to the uniform
  73115. * @return the texture itself allowing "fluent" like uniform updates
  73116. */
  73117. setFloat(name: string, value: number): ProceduralTexture;
  73118. /**
  73119. * Set a int in the shader.
  73120. * @param name Define the name of the uniform as defined in the shader
  73121. * @param value Define the value to give to the uniform
  73122. * @return the texture itself allowing "fluent" like uniform updates
  73123. */
  73124. setInt(name: string, value: number): ProceduralTexture;
  73125. /**
  73126. * Set an array of floats in the shader.
  73127. * @param name Define the name of the uniform as defined in the shader
  73128. * @param value Define the value to give to the uniform
  73129. * @return the texture itself allowing "fluent" like uniform updates
  73130. */
  73131. setFloats(name: string, value: number[]): ProceduralTexture;
  73132. /**
  73133. * Set a vec3 in the shader from a Color3.
  73134. * @param name Define the name of the uniform as defined in the shader
  73135. * @param value Define the value to give to the uniform
  73136. * @return the texture itself allowing "fluent" like uniform updates
  73137. */
  73138. setColor3(name: string, value: Color3): ProceduralTexture;
  73139. /**
  73140. * Set a vec4 in the shader from a Color4.
  73141. * @param name Define the name of the uniform as defined in the shader
  73142. * @param value Define the value to give to the uniform
  73143. * @return the texture itself allowing "fluent" like uniform updates
  73144. */
  73145. setColor4(name: string, value: Color4): ProceduralTexture;
  73146. /**
  73147. * Set a vec2 in the shader from a Vector2.
  73148. * @param name Define the name of the uniform as defined in the shader
  73149. * @param value Define the value to give to the uniform
  73150. * @return the texture itself allowing "fluent" like uniform updates
  73151. */
  73152. setVector2(name: string, value: Vector2): ProceduralTexture;
  73153. /**
  73154. * Set a vec3 in the shader from a Vector3.
  73155. * @param name Define the name of the uniform as defined in the shader
  73156. * @param value Define the value to give to the uniform
  73157. * @return the texture itself allowing "fluent" like uniform updates
  73158. */
  73159. setVector3(name: string, value: Vector3): ProceduralTexture;
  73160. /**
  73161. * Set a mat4 in the shader from a MAtrix.
  73162. * @param name Define the name of the uniform as defined in the shader
  73163. * @param value Define the value to give to the uniform
  73164. * @return the texture itself allowing "fluent" like uniform updates
  73165. */
  73166. setMatrix(name: string, value: Matrix): ProceduralTexture;
  73167. /**
  73168. * Render the texture to its associated render target.
  73169. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  73170. */
  73171. render(useCameraPostProcess?: boolean): void;
  73172. /**
  73173. * Clone the texture.
  73174. * @returns the cloned texture
  73175. */
  73176. clone(): ProceduralTexture;
  73177. /**
  73178. * Dispose the texture and release its asoociated resources.
  73179. */
  73180. dispose(): void;
  73181. }
  73182. }
  73183. declare module BABYLON {
  73184. /**
  73185. * This represents the base class for particle system in Babylon.
  73186. * 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.
  73187. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73188. * @example https://doc.babylonjs.com/babylon101/particles
  73189. */
  73190. export class BaseParticleSystem {
  73191. /**
  73192. * Source color is added to the destination color without alpha affecting the result
  73193. */
  73194. static BLENDMODE_ONEONE: number;
  73195. /**
  73196. * Blend current color and particle color using particle’s alpha
  73197. */
  73198. static BLENDMODE_STANDARD: number;
  73199. /**
  73200. * Add current color and particle color multiplied by particle’s alpha
  73201. */
  73202. static BLENDMODE_ADD: number;
  73203. /**
  73204. * Multiply current color with particle color
  73205. */
  73206. static BLENDMODE_MULTIPLY: number;
  73207. /**
  73208. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  73209. */
  73210. static BLENDMODE_MULTIPLYADD: number;
  73211. /**
  73212. * List of animations used by the particle system.
  73213. */
  73214. animations: Animation[];
  73215. /**
  73216. * The id of the Particle system.
  73217. */
  73218. id: string;
  73219. /**
  73220. * The friendly name of the Particle system.
  73221. */
  73222. name: string;
  73223. /**
  73224. * The rendering group used by the Particle system to chose when to render.
  73225. */
  73226. renderingGroupId: number;
  73227. /**
  73228. * The emitter represents the Mesh or position we are attaching the particle system to.
  73229. */
  73230. emitter: Nullable<AbstractMesh | Vector3>;
  73231. /**
  73232. * The maximum number of particles to emit per frame
  73233. */
  73234. emitRate: number;
  73235. /**
  73236. * If you want to launch only a few particles at once, that can be done, as well.
  73237. */
  73238. manualEmitCount: number;
  73239. /**
  73240. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73241. */
  73242. updateSpeed: number;
  73243. /**
  73244. * The amount of time the particle system is running (depends of the overall update speed).
  73245. */
  73246. targetStopDuration: number;
  73247. /**
  73248. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73249. */
  73250. disposeOnStop: boolean;
  73251. /**
  73252. * Minimum power of emitting particles.
  73253. */
  73254. minEmitPower: number;
  73255. /**
  73256. * Maximum power of emitting particles.
  73257. */
  73258. maxEmitPower: number;
  73259. /**
  73260. * Minimum life time of emitting particles.
  73261. */
  73262. minLifeTime: number;
  73263. /**
  73264. * Maximum life time of emitting particles.
  73265. */
  73266. maxLifeTime: number;
  73267. /**
  73268. * Minimum Size of emitting particles.
  73269. */
  73270. minSize: number;
  73271. /**
  73272. * Maximum Size of emitting particles.
  73273. */
  73274. maxSize: number;
  73275. /**
  73276. * Minimum scale of emitting particles on X axis.
  73277. */
  73278. minScaleX: number;
  73279. /**
  73280. * Maximum scale of emitting particles on X axis.
  73281. */
  73282. maxScaleX: number;
  73283. /**
  73284. * Minimum scale of emitting particles on Y axis.
  73285. */
  73286. minScaleY: number;
  73287. /**
  73288. * Maximum scale of emitting particles on Y axis.
  73289. */
  73290. maxScaleY: number;
  73291. /**
  73292. * Gets or sets the minimal initial rotation in radians.
  73293. */
  73294. minInitialRotation: number;
  73295. /**
  73296. * Gets or sets the maximal initial rotation in radians.
  73297. */
  73298. maxInitialRotation: number;
  73299. /**
  73300. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73301. */
  73302. minAngularSpeed: number;
  73303. /**
  73304. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73305. */
  73306. maxAngularSpeed: number;
  73307. /**
  73308. * The texture used to render each particle. (this can be a spritesheet)
  73309. */
  73310. particleTexture: Nullable<Texture>;
  73311. /**
  73312. * The layer mask we are rendering the particles through.
  73313. */
  73314. layerMask: number;
  73315. /**
  73316. * This can help using your own shader to render the particle system.
  73317. * The according effect will be created
  73318. */
  73319. customShader: any;
  73320. /**
  73321. * By default particle system starts as soon as they are created. This prevents the
  73322. * automatic start to happen and let you decide when to start emitting particles.
  73323. */
  73324. preventAutoStart: boolean;
  73325. private _noiseTexture;
  73326. /**
  73327. * Gets or sets a texture used to add random noise to particle positions
  73328. */
  73329. noiseTexture: Nullable<ProceduralTexture>;
  73330. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73331. noiseStrength: Vector3;
  73332. /**
  73333. * Callback triggered when the particle animation is ending.
  73334. */
  73335. onAnimationEnd: Nullable<() => void>;
  73336. /**
  73337. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  73338. */
  73339. blendMode: number;
  73340. /**
  73341. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  73342. * to override the particles.
  73343. */
  73344. forceDepthWrite: boolean;
  73345. /** 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 */
  73346. preWarmCycles: number;
  73347. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  73348. preWarmStepOffset: number;
  73349. /**
  73350. * 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)
  73351. */
  73352. spriteCellChangeSpeed: number;
  73353. /**
  73354. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73355. */
  73356. startSpriteCellID: number;
  73357. /**
  73358. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73359. */
  73360. endSpriteCellID: number;
  73361. /**
  73362. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73363. */
  73364. spriteCellWidth: number;
  73365. /**
  73366. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73367. */
  73368. spriteCellHeight: number;
  73369. /**
  73370. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73371. */
  73372. spriteRandomStartCell: boolean;
  73373. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73374. translationPivot: Vector2;
  73375. /** @hidden */
  73376. protected _isAnimationSheetEnabled: boolean;
  73377. /**
  73378. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73379. */
  73380. beginAnimationOnStart: boolean;
  73381. /**
  73382. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73383. */
  73384. beginAnimationFrom: number;
  73385. /**
  73386. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73387. */
  73388. beginAnimationTo: number;
  73389. /**
  73390. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73391. */
  73392. beginAnimationLoop: boolean;
  73393. /**
  73394. * Gets or sets a world offset applied to all particles
  73395. */
  73396. worldOffset: Vector3;
  73397. /**
  73398. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  73399. */
  73400. isAnimationSheetEnabled: boolean;
  73401. /**
  73402. * Get hosting scene
  73403. * @returns the scene
  73404. */
  73405. getScene(): Scene;
  73406. /**
  73407. * You can use gravity if you want to give an orientation to your particles.
  73408. */
  73409. gravity: Vector3;
  73410. protected _colorGradients: Nullable<Array<ColorGradient>>;
  73411. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  73412. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  73413. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  73414. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  73415. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  73416. protected _dragGradients: Nullable<Array<FactorGradient>>;
  73417. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  73418. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  73419. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  73420. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  73421. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  73422. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  73423. /**
  73424. * Defines the delay in milliseconds before starting the system (0 by default)
  73425. */
  73426. startDelay: number;
  73427. /**
  73428. * Gets the current list of drag gradients.
  73429. * You must use addDragGradient and removeDragGradient to udpate this list
  73430. * @returns the list of drag gradients
  73431. */
  73432. getDragGradients(): Nullable<Array<FactorGradient>>;
  73433. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73434. limitVelocityDamping: number;
  73435. /**
  73436. * Gets the current list of limit velocity gradients.
  73437. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73438. * @returns the list of limit velocity gradients
  73439. */
  73440. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73441. /**
  73442. * Gets the current list of color gradients.
  73443. * You must use addColorGradient and removeColorGradient to udpate this list
  73444. * @returns the list of color gradients
  73445. */
  73446. getColorGradients(): Nullable<Array<ColorGradient>>;
  73447. /**
  73448. * Gets the current list of size gradients.
  73449. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73450. * @returns the list of size gradients
  73451. */
  73452. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73453. /**
  73454. * Gets the current list of color remap gradients.
  73455. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73456. * @returns the list of color remap gradients
  73457. */
  73458. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73459. /**
  73460. * Gets the current list of alpha remap gradients.
  73461. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73462. * @returns the list of alpha remap gradients
  73463. */
  73464. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73465. /**
  73466. * Gets the current list of life time gradients.
  73467. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73468. * @returns the list of life time gradients
  73469. */
  73470. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73471. /**
  73472. * Gets the current list of angular speed gradients.
  73473. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73474. * @returns the list of angular speed gradients
  73475. */
  73476. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73477. /**
  73478. * Gets the current list of velocity gradients.
  73479. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73480. * @returns the list of velocity gradients
  73481. */
  73482. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73483. /**
  73484. * Gets the current list of start size gradients.
  73485. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73486. * @returns the list of start size gradients
  73487. */
  73488. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73489. /**
  73490. * Gets the current list of emit rate gradients.
  73491. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73492. * @returns the list of emit rate gradients
  73493. */
  73494. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73495. /**
  73496. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73497. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73498. */
  73499. direction1: Vector3;
  73500. /**
  73501. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73502. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73503. */
  73504. direction2: Vector3;
  73505. /**
  73506. * 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.
  73507. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73508. */
  73509. minEmitBox: Vector3;
  73510. /**
  73511. * 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.
  73512. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73513. */
  73514. maxEmitBox: Vector3;
  73515. /**
  73516. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73517. */
  73518. color1: Color4;
  73519. /**
  73520. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73521. */
  73522. color2: Color4;
  73523. /**
  73524. * Color the particle will have at the end of its lifetime
  73525. */
  73526. colorDead: Color4;
  73527. /**
  73528. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  73529. */
  73530. textureMask: Color4;
  73531. /**
  73532. * The particle emitter type defines the emitter used by the particle system.
  73533. * It can be for example box, sphere, or cone...
  73534. */
  73535. particleEmitterType: IParticleEmitterType;
  73536. /** @hidden */
  73537. _isSubEmitter: boolean;
  73538. /**
  73539. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73540. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73541. */
  73542. billboardMode: number;
  73543. protected _isBillboardBased: boolean;
  73544. /**
  73545. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73546. */
  73547. isBillboardBased: boolean;
  73548. /**
  73549. * The scene the particle system belongs to.
  73550. */
  73551. protected _scene: Scene;
  73552. /**
  73553. * Local cache of defines for image processing.
  73554. */
  73555. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  73556. /**
  73557. * Default configuration related to image processing available in the standard Material.
  73558. */
  73559. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  73560. /**
  73561. * Gets the image processing configuration used either in this material.
  73562. */
  73563. /**
  73564. * Sets the Default image processing configuration used either in the this material.
  73565. *
  73566. * If sets to null, the scene one is in use.
  73567. */
  73568. imageProcessingConfiguration: ImageProcessingConfiguration;
  73569. /**
  73570. * Attaches a new image processing configuration to the Standard Material.
  73571. * @param configuration
  73572. */
  73573. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  73574. /** @hidden */
  73575. protected _reset(): void;
  73576. /** @hidden */
  73577. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  73578. /**
  73579. * Instantiates a particle system.
  73580. * 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.
  73581. * @param name The name of the particle system
  73582. */
  73583. constructor(name: string);
  73584. /**
  73585. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73586. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73587. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73588. * @returns the emitter
  73589. */
  73590. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73591. /**
  73592. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73593. * @param radius The radius of the hemisphere to emit from
  73594. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73595. * @returns the emitter
  73596. */
  73597. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  73598. /**
  73599. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73600. * @param radius The radius of the sphere to emit from
  73601. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73602. * @returns the emitter
  73603. */
  73604. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  73605. /**
  73606. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73607. * @param radius The radius of the sphere to emit from
  73608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73610. * @returns the emitter
  73611. */
  73612. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  73613. /**
  73614. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73615. * @param radius The radius of the emission cylinder
  73616. * @param height The height of the emission cylinder
  73617. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73618. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73619. * @returns the emitter
  73620. */
  73621. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  73622. /**
  73623. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73624. * @param radius The radius of the cylinder to emit from
  73625. * @param height The height of the emission cylinder
  73626. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73629. * @returns the emitter
  73630. */
  73631. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  73632. /**
  73633. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73634. * @param radius The radius of the cone to emit from
  73635. * @param angle The base angle of the cone
  73636. * @returns the emitter
  73637. */
  73638. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  73639. /**
  73640. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73641. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73642. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73643. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73644. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73645. * @returns the emitter
  73646. */
  73647. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73648. }
  73649. }
  73650. declare module BABYLON {
  73651. /**
  73652. * Type of sub emitter
  73653. */
  73654. export enum SubEmitterType {
  73655. /**
  73656. * Attached to the particle over it's lifetime
  73657. */
  73658. ATTACHED = 0,
  73659. /**
  73660. * Created when the particle dies
  73661. */
  73662. END = 1
  73663. }
  73664. /**
  73665. * Sub emitter class used to emit particles from an existing particle
  73666. */
  73667. export class SubEmitter {
  73668. /**
  73669. * the particle system to be used by the sub emitter
  73670. */
  73671. particleSystem: ParticleSystem;
  73672. /**
  73673. * Type of the submitter (Default: END)
  73674. */
  73675. type: SubEmitterType;
  73676. /**
  73677. * 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)
  73678. * Note: This only is supported when using an emitter of type Mesh
  73679. */
  73680. inheritDirection: boolean;
  73681. /**
  73682. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  73683. */
  73684. inheritedVelocityAmount: number;
  73685. /**
  73686. * Creates a sub emitter
  73687. * @param particleSystem the particle system to be used by the sub emitter
  73688. */
  73689. constructor(
  73690. /**
  73691. * the particle system to be used by the sub emitter
  73692. */
  73693. particleSystem: ParticleSystem);
  73694. /**
  73695. * Clones the sub emitter
  73696. * @returns the cloned sub emitter
  73697. */
  73698. clone(): SubEmitter;
  73699. /**
  73700. * Serialize current object to a JSON object
  73701. * @returns the serialized object
  73702. */
  73703. serialize(): any;
  73704. /** @hidden */
  73705. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  73706. /**
  73707. * Creates a new SubEmitter from a serialized JSON version
  73708. * @param serializationObject defines the JSON object to read from
  73709. * @param scene defines the hosting scene
  73710. * @param rootUrl defines the rootUrl for data loading
  73711. * @returns a new SubEmitter
  73712. */
  73713. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  73714. /** Release associated resources */
  73715. dispose(): void;
  73716. }
  73717. }
  73718. declare module BABYLON {
  73719. /** @hidden */
  73720. export var clipPlaneFragmentDeclaration: {
  73721. name: string;
  73722. shader: string;
  73723. };
  73724. }
  73725. declare module BABYLON {
  73726. /** @hidden */
  73727. export var imageProcessingDeclaration: {
  73728. name: string;
  73729. shader: string;
  73730. };
  73731. }
  73732. declare module BABYLON {
  73733. /** @hidden */
  73734. export var imageProcessingFunctions: {
  73735. name: string;
  73736. shader: string;
  73737. };
  73738. }
  73739. declare module BABYLON {
  73740. /** @hidden */
  73741. export var clipPlaneFragment: {
  73742. name: string;
  73743. shader: string;
  73744. };
  73745. }
  73746. declare module BABYLON {
  73747. /** @hidden */
  73748. export var particlesPixelShader: {
  73749. name: string;
  73750. shader: string;
  73751. };
  73752. }
  73753. declare module BABYLON {
  73754. /** @hidden */
  73755. export var clipPlaneVertexDeclaration: {
  73756. name: string;
  73757. shader: string;
  73758. };
  73759. }
  73760. declare module BABYLON {
  73761. /** @hidden */
  73762. export var clipPlaneVertex: {
  73763. name: string;
  73764. shader: string;
  73765. };
  73766. }
  73767. declare module BABYLON {
  73768. /** @hidden */
  73769. export var particlesVertexShader: {
  73770. name: string;
  73771. shader: string;
  73772. };
  73773. }
  73774. declare module BABYLON {
  73775. /**
  73776. * This represents a particle system in Babylon.
  73777. * 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.
  73778. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73779. * @example https://doc.babylonjs.com/babylon101/particles
  73780. */
  73781. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  73782. /**
  73783. * Billboard mode will only apply to Y axis
  73784. */
  73785. static readonly BILLBOARDMODE_Y: number;
  73786. /**
  73787. * Billboard mode will apply to all axes
  73788. */
  73789. static readonly BILLBOARDMODE_ALL: number;
  73790. /**
  73791. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73792. */
  73793. static readonly BILLBOARDMODE_STRETCHED: number;
  73794. /**
  73795. * This function can be defined to provide custom update for active particles.
  73796. * This function will be called instead of regular update (age, position, color, etc.).
  73797. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  73798. */
  73799. updateFunction: (particles: Particle[]) => void;
  73800. private _emitterWorldMatrix;
  73801. /**
  73802. * This function can be defined to specify initial direction for every new particle.
  73803. * It by default use the emitterType defined function
  73804. */
  73805. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  73806. /**
  73807. * This function can be defined to specify initial position for every new particle.
  73808. * It by default use the emitterType defined function
  73809. */
  73810. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  73811. /**
  73812. * @hidden
  73813. */
  73814. _inheritedVelocityOffset: Vector3;
  73815. /**
  73816. * An event triggered when the system is disposed
  73817. */
  73818. onDisposeObservable: Observable<ParticleSystem>;
  73819. private _onDisposeObserver;
  73820. /**
  73821. * Sets a callback that will be triggered when the system is disposed
  73822. */
  73823. onDispose: () => void;
  73824. private _particles;
  73825. private _epsilon;
  73826. private _capacity;
  73827. private _stockParticles;
  73828. private _newPartsExcess;
  73829. private _vertexData;
  73830. private _vertexBuffer;
  73831. private _vertexBuffers;
  73832. private _spriteBuffer;
  73833. private _indexBuffer;
  73834. private _effect;
  73835. private _customEffect;
  73836. private _cachedDefines;
  73837. private _scaledColorStep;
  73838. private _colorDiff;
  73839. private _scaledDirection;
  73840. private _scaledGravity;
  73841. private _currentRenderId;
  73842. private _alive;
  73843. private _useInstancing;
  73844. private _started;
  73845. private _stopped;
  73846. private _actualFrame;
  73847. private _scaledUpdateSpeed;
  73848. private _vertexBufferSize;
  73849. /** @hidden */
  73850. _currentEmitRateGradient: Nullable<FactorGradient>;
  73851. /** @hidden */
  73852. _currentEmitRate1: number;
  73853. /** @hidden */
  73854. _currentEmitRate2: number;
  73855. /** @hidden */
  73856. _currentStartSizeGradient: Nullable<FactorGradient>;
  73857. /** @hidden */
  73858. _currentStartSize1: number;
  73859. /** @hidden */
  73860. _currentStartSize2: number;
  73861. private readonly _rawTextureWidth;
  73862. private _rampGradientsTexture;
  73863. private _useRampGradients;
  73864. /** Gets or sets a boolean indicating that ramp gradients must be used
  73865. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73866. */
  73867. useRampGradients: boolean;
  73868. /**
  73869. * 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.
  73870. * 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: [])
  73871. */
  73872. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  73873. private _subEmitters;
  73874. /**
  73875. * @hidden
  73876. * If the particle systems emitter should be disposed when the particle system is disposed
  73877. */
  73878. _disposeEmitterOnDispose: boolean;
  73879. /**
  73880. * The current active Sub-systems, this property is used by the root particle system only.
  73881. */
  73882. activeSubSystems: Array<ParticleSystem>;
  73883. private _rootParticleSystem;
  73884. /**
  73885. * Gets the current list of active particles
  73886. */
  73887. readonly particles: Particle[];
  73888. /**
  73889. * Returns the string "ParticleSystem"
  73890. * @returns a string containing the class name
  73891. */
  73892. getClassName(): string;
  73893. /**
  73894. * Instantiates a particle system.
  73895. * 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.
  73896. * @param name The name of the particle system
  73897. * @param capacity The max number of particles alive at the same time
  73898. * @param scene The scene the particle system belongs to
  73899. * @param customEffect a custom effect used to change the way particles are rendered by default
  73900. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73901. * @param epsilon Offset used to render the particles
  73902. */
  73903. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  73904. private _addFactorGradient;
  73905. private _removeFactorGradient;
  73906. /**
  73907. * Adds a new life time gradient
  73908. * @param gradient defines the gradient to use (between 0 and 1)
  73909. * @param factor defines the life time factor to affect to the specified gradient
  73910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73911. * @returns the current particle system
  73912. */
  73913. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73914. /**
  73915. * Remove a specific life time gradient
  73916. * @param gradient defines the gradient to remove
  73917. * @returns the current particle system
  73918. */
  73919. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73920. /**
  73921. * Adds a new size gradient
  73922. * @param gradient defines the gradient to use (between 0 and 1)
  73923. * @param factor defines the size factor to affect to the specified gradient
  73924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73925. * @returns the current particle system
  73926. */
  73927. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73928. /**
  73929. * Remove a specific size gradient
  73930. * @param gradient defines the gradient to remove
  73931. * @returns the current particle system
  73932. */
  73933. removeSizeGradient(gradient: number): IParticleSystem;
  73934. /**
  73935. * Adds a new color remap gradient
  73936. * @param gradient defines the gradient to use (between 0 and 1)
  73937. * @param min defines the color remap minimal range
  73938. * @param max defines the color remap maximal range
  73939. * @returns the current particle system
  73940. */
  73941. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73942. /**
  73943. * Remove a specific color remap gradient
  73944. * @param gradient defines the gradient to remove
  73945. * @returns the current particle system
  73946. */
  73947. removeColorRemapGradient(gradient: number): IParticleSystem;
  73948. /**
  73949. * Adds a new alpha remap gradient
  73950. * @param gradient defines the gradient to use (between 0 and 1)
  73951. * @param min defines the alpha remap minimal range
  73952. * @param max defines the alpha remap maximal range
  73953. * @returns the current particle system
  73954. */
  73955. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73956. /**
  73957. * Remove a specific alpha remap gradient
  73958. * @param gradient defines the gradient to remove
  73959. * @returns the current particle system
  73960. */
  73961. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  73962. /**
  73963. * Adds a new angular speed gradient
  73964. * @param gradient defines the gradient to use (between 0 and 1)
  73965. * @param factor defines the angular speed to affect to the specified gradient
  73966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73967. * @returns the current particle system
  73968. */
  73969. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73970. /**
  73971. * Remove a specific angular speed gradient
  73972. * @param gradient defines the gradient to remove
  73973. * @returns the current particle system
  73974. */
  73975. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73976. /**
  73977. * Adds a new velocity gradient
  73978. * @param gradient defines the gradient to use (between 0 and 1)
  73979. * @param factor defines the velocity to affect to the specified gradient
  73980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73981. * @returns the current particle system
  73982. */
  73983. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73984. /**
  73985. * Remove a specific velocity gradient
  73986. * @param gradient defines the gradient to remove
  73987. * @returns the current particle system
  73988. */
  73989. removeVelocityGradient(gradient: number): IParticleSystem;
  73990. /**
  73991. * Adds a new limit velocity gradient
  73992. * @param gradient defines the gradient to use (between 0 and 1)
  73993. * @param factor defines the limit velocity value to affect to the specified gradient
  73994. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73995. * @returns the current particle system
  73996. */
  73997. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73998. /**
  73999. * Remove a specific limit velocity gradient
  74000. * @param gradient defines the gradient to remove
  74001. * @returns the current particle system
  74002. */
  74003. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74004. /**
  74005. * Adds a new drag gradient
  74006. * @param gradient defines the gradient to use (between 0 and 1)
  74007. * @param factor defines the drag value to affect to the specified gradient
  74008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74009. * @returns the current particle system
  74010. */
  74011. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74012. /**
  74013. * Remove a specific drag gradient
  74014. * @param gradient defines the gradient to remove
  74015. * @returns the current particle system
  74016. */
  74017. removeDragGradient(gradient: number): IParticleSystem;
  74018. /**
  74019. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74020. * @param gradient defines the gradient to use (between 0 and 1)
  74021. * @param factor defines the emit rate value to affect to the specified gradient
  74022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74023. * @returns the current particle system
  74024. */
  74025. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74026. /**
  74027. * Remove a specific emit rate gradient
  74028. * @param gradient defines the gradient to remove
  74029. * @returns the current particle system
  74030. */
  74031. removeEmitRateGradient(gradient: number): IParticleSystem;
  74032. /**
  74033. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74034. * @param gradient defines the gradient to use (between 0 and 1)
  74035. * @param factor defines the start size value to affect to the specified gradient
  74036. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74037. * @returns the current particle system
  74038. */
  74039. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74040. /**
  74041. * Remove a specific start size gradient
  74042. * @param gradient defines the gradient to remove
  74043. * @returns the current particle system
  74044. */
  74045. removeStartSizeGradient(gradient: number): IParticleSystem;
  74046. private _createRampGradientTexture;
  74047. /**
  74048. * Gets the current list of ramp gradients.
  74049. * You must use addRampGradient and removeRampGradient to udpate this list
  74050. * @returns the list of ramp gradients
  74051. */
  74052. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74053. /**
  74054. * Adds a new ramp gradient used to remap particle colors
  74055. * @param gradient defines the gradient to use (between 0 and 1)
  74056. * @param color defines the color to affect to the specified gradient
  74057. * @returns the current particle system
  74058. */
  74059. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  74060. /**
  74061. * Remove a specific ramp gradient
  74062. * @param gradient defines the gradient to remove
  74063. * @returns the current particle system
  74064. */
  74065. removeRampGradient(gradient: number): ParticleSystem;
  74066. /**
  74067. * Adds a new color gradient
  74068. * @param gradient defines the gradient to use (between 0 and 1)
  74069. * @param color1 defines the color to affect to the specified gradient
  74070. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74071. * @returns this particle system
  74072. */
  74073. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74074. /**
  74075. * Remove a specific color gradient
  74076. * @param gradient defines the gradient to remove
  74077. * @returns this particle system
  74078. */
  74079. removeColorGradient(gradient: number): IParticleSystem;
  74080. private _fetchR;
  74081. protected _reset(): void;
  74082. private _resetEffect;
  74083. private _createVertexBuffers;
  74084. private _createIndexBuffer;
  74085. /**
  74086. * Gets the maximum number of particles active at the same time.
  74087. * @returns The max number of active particles.
  74088. */
  74089. getCapacity(): number;
  74090. /**
  74091. * Gets whether there are still active particles in the system.
  74092. * @returns True if it is alive, otherwise false.
  74093. */
  74094. isAlive(): boolean;
  74095. /**
  74096. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74097. * @returns True if it has been started, otherwise false.
  74098. */
  74099. isStarted(): boolean;
  74100. private _prepareSubEmitterInternalArray;
  74101. /**
  74102. * Starts the particle system and begins to emit
  74103. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  74104. */
  74105. start(delay?: number): void;
  74106. /**
  74107. * Stops the particle system.
  74108. * @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.
  74109. */
  74110. stop(stopSubEmitters?: boolean): void;
  74111. /**
  74112. * Remove all active particles
  74113. */
  74114. reset(): void;
  74115. /**
  74116. * @hidden (for internal use only)
  74117. */
  74118. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  74119. /**
  74120. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  74121. * Its lifetime will start back at 0.
  74122. */
  74123. recycleParticle: (particle: Particle) => void;
  74124. private _stopSubEmitters;
  74125. private _createParticle;
  74126. private _removeFromRoot;
  74127. private _emitFromParticle;
  74128. private _update;
  74129. /** @hidden */
  74130. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  74131. /** @hidden */
  74132. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  74133. /** @hidden */
  74134. private _getEffect;
  74135. /**
  74136. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  74137. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  74138. */
  74139. animate(preWarmOnly?: boolean): void;
  74140. private _appendParticleVertices;
  74141. /**
  74142. * Rebuilds the particle system.
  74143. */
  74144. rebuild(): void;
  74145. /**
  74146. * Is this system ready to be used/rendered
  74147. * @return true if the system is ready
  74148. */
  74149. isReady(): boolean;
  74150. private _render;
  74151. /**
  74152. * Renders the particle system in its current state.
  74153. * @returns the current number of particles
  74154. */
  74155. render(): number;
  74156. /**
  74157. * Disposes the particle system and free the associated resources
  74158. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74159. */
  74160. dispose(disposeTexture?: boolean): void;
  74161. /**
  74162. * Clones the particle system.
  74163. * @param name The name of the cloned object
  74164. * @param newEmitter The new emitter to use
  74165. * @returns the cloned particle system
  74166. */
  74167. clone(name: string, newEmitter: any): ParticleSystem;
  74168. /**
  74169. * Serializes the particle system to a JSON object.
  74170. * @returns the JSON object
  74171. */
  74172. serialize(): any;
  74173. /** @hidden */
  74174. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  74175. /** @hidden */
  74176. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  74177. /**
  74178. * Parses a JSON object to create a particle system.
  74179. * @param parsedParticleSystem The JSON object to parse
  74180. * @param scene The scene to create the particle system in
  74181. * @param rootUrl The root url to use to load external dependencies like texture
  74182. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  74183. * @returns the Parsed particle system
  74184. */
  74185. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  74186. }
  74187. }
  74188. declare module BABYLON {
  74189. /**
  74190. * A particle represents one of the element emitted by a particle system.
  74191. * This is mainly define by its coordinates, direction, velocity and age.
  74192. */
  74193. export class Particle {
  74194. /**
  74195. * The particle system the particle belongs to.
  74196. */
  74197. particleSystem: ParticleSystem;
  74198. private static _Count;
  74199. /**
  74200. * Unique ID of the particle
  74201. */
  74202. id: number;
  74203. /**
  74204. * The world position of the particle in the scene.
  74205. */
  74206. position: Vector3;
  74207. /**
  74208. * The world direction of the particle in the scene.
  74209. */
  74210. direction: Vector3;
  74211. /**
  74212. * The color of the particle.
  74213. */
  74214. color: Color4;
  74215. /**
  74216. * The color change of the particle per step.
  74217. */
  74218. colorStep: Color4;
  74219. /**
  74220. * Defines how long will the life of the particle be.
  74221. */
  74222. lifeTime: number;
  74223. /**
  74224. * The current age of the particle.
  74225. */
  74226. age: number;
  74227. /**
  74228. * The current size of the particle.
  74229. */
  74230. size: number;
  74231. /**
  74232. * The current scale of the particle.
  74233. */
  74234. scale: Vector2;
  74235. /**
  74236. * The current angle of the particle.
  74237. */
  74238. angle: number;
  74239. /**
  74240. * Defines how fast is the angle changing.
  74241. */
  74242. angularSpeed: number;
  74243. /**
  74244. * Defines the cell index used by the particle to be rendered from a sprite.
  74245. */
  74246. cellIndex: number;
  74247. /**
  74248. * The information required to support color remapping
  74249. */
  74250. remapData: Vector4;
  74251. /** @hidden */
  74252. _randomCellOffset?: number;
  74253. /** @hidden */
  74254. _initialDirection: Nullable<Vector3>;
  74255. /** @hidden */
  74256. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  74257. /** @hidden */
  74258. _initialStartSpriteCellID: number;
  74259. /** @hidden */
  74260. _initialEndSpriteCellID: number;
  74261. /** @hidden */
  74262. _currentColorGradient: Nullable<ColorGradient>;
  74263. /** @hidden */
  74264. _currentColor1: Color4;
  74265. /** @hidden */
  74266. _currentColor2: Color4;
  74267. /** @hidden */
  74268. _currentSizeGradient: Nullable<FactorGradient>;
  74269. /** @hidden */
  74270. _currentSize1: number;
  74271. /** @hidden */
  74272. _currentSize2: number;
  74273. /** @hidden */
  74274. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  74275. /** @hidden */
  74276. _currentAngularSpeed1: number;
  74277. /** @hidden */
  74278. _currentAngularSpeed2: number;
  74279. /** @hidden */
  74280. _currentVelocityGradient: Nullable<FactorGradient>;
  74281. /** @hidden */
  74282. _currentVelocity1: number;
  74283. /** @hidden */
  74284. _currentVelocity2: number;
  74285. /** @hidden */
  74286. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  74287. /** @hidden */
  74288. _currentLimitVelocity1: number;
  74289. /** @hidden */
  74290. _currentLimitVelocity2: number;
  74291. /** @hidden */
  74292. _currentDragGradient: Nullable<FactorGradient>;
  74293. /** @hidden */
  74294. _currentDrag1: number;
  74295. /** @hidden */
  74296. _currentDrag2: number;
  74297. /** @hidden */
  74298. _randomNoiseCoordinates1: Vector3;
  74299. /** @hidden */
  74300. _randomNoiseCoordinates2: Vector3;
  74301. /**
  74302. * Creates a new instance Particle
  74303. * @param particleSystem the particle system the particle belongs to
  74304. */
  74305. constructor(
  74306. /**
  74307. * The particle system the particle belongs to.
  74308. */
  74309. particleSystem: ParticleSystem);
  74310. private updateCellInfoFromSystem;
  74311. /**
  74312. * Defines how the sprite cell index is updated for the particle
  74313. */
  74314. updateCellIndex(): void;
  74315. /** @hidden */
  74316. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  74317. /** @hidden */
  74318. _inheritParticleInfoToSubEmitters(): void;
  74319. /** @hidden */
  74320. _reset(): void;
  74321. /**
  74322. * Copy the properties of particle to another one.
  74323. * @param other the particle to copy the information to.
  74324. */
  74325. copyTo(other: Particle): void;
  74326. }
  74327. }
  74328. declare module BABYLON {
  74329. /**
  74330. * Particle emitter represents a volume emitting particles.
  74331. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  74332. */
  74333. export interface IParticleEmitterType {
  74334. /**
  74335. * Called by the particle System when the direction is computed for the created particle.
  74336. * @param worldMatrix is the world matrix of the particle system
  74337. * @param directionToUpdate is the direction vector to update with the result
  74338. * @param particle is the particle we are computed the direction for
  74339. */
  74340. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74341. /**
  74342. * Called by the particle System when the position is computed for the created particle.
  74343. * @param worldMatrix is the world matrix of the particle system
  74344. * @param positionToUpdate is the position vector to update with the result
  74345. * @param particle is the particle we are computed the position for
  74346. */
  74347. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74348. /**
  74349. * Clones the current emitter and returns a copy of it
  74350. * @returns the new emitter
  74351. */
  74352. clone(): IParticleEmitterType;
  74353. /**
  74354. * Called by the GPUParticleSystem to setup the update shader
  74355. * @param effect defines the update shader
  74356. */
  74357. applyToShader(effect: Effect): void;
  74358. /**
  74359. * Returns a string to use to update the GPU particles update shader
  74360. * @returns the effect defines string
  74361. */
  74362. getEffectDefines(): string;
  74363. /**
  74364. * Returns a string representing the class name
  74365. * @returns a string containing the class name
  74366. */
  74367. getClassName(): string;
  74368. /**
  74369. * Serializes the particle system to a JSON object.
  74370. * @returns the JSON object
  74371. */
  74372. serialize(): any;
  74373. /**
  74374. * Parse properties from a JSON object
  74375. * @param serializationObject defines the JSON object
  74376. */
  74377. parse(serializationObject: any): void;
  74378. }
  74379. }
  74380. declare module BABYLON {
  74381. /**
  74382. * Particle emitter emitting particles from the inside of a box.
  74383. * It emits the particles randomly between 2 given directions.
  74384. */
  74385. export class BoxParticleEmitter implements IParticleEmitterType {
  74386. /**
  74387. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74388. */
  74389. direction1: Vector3;
  74390. /**
  74391. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74392. */
  74393. direction2: Vector3;
  74394. /**
  74395. * 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.
  74396. */
  74397. minEmitBox: Vector3;
  74398. /**
  74399. * 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.
  74400. */
  74401. maxEmitBox: Vector3;
  74402. /**
  74403. * Creates a new instance BoxParticleEmitter
  74404. */
  74405. constructor();
  74406. /**
  74407. * Called by the particle System when the direction is computed for the created particle.
  74408. * @param worldMatrix is the world matrix of the particle system
  74409. * @param directionToUpdate is the direction vector to update with the result
  74410. * @param particle is the particle we are computed the direction for
  74411. */
  74412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74413. /**
  74414. * Called by the particle System when the position is computed for the created particle.
  74415. * @param worldMatrix is the world matrix of the particle system
  74416. * @param positionToUpdate is the position vector to update with the result
  74417. * @param particle is the particle we are computed the position for
  74418. */
  74419. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74420. /**
  74421. * Clones the current emitter and returns a copy of it
  74422. * @returns the new emitter
  74423. */
  74424. clone(): BoxParticleEmitter;
  74425. /**
  74426. * Called by the GPUParticleSystem to setup the update shader
  74427. * @param effect defines the update shader
  74428. */
  74429. applyToShader(effect: Effect): void;
  74430. /**
  74431. * Returns a string to use to update the GPU particles update shader
  74432. * @returns a string containng the defines string
  74433. */
  74434. getEffectDefines(): string;
  74435. /**
  74436. * Returns the string "BoxParticleEmitter"
  74437. * @returns a string containing the class name
  74438. */
  74439. getClassName(): string;
  74440. /**
  74441. * Serializes the particle system to a JSON object.
  74442. * @returns the JSON object
  74443. */
  74444. serialize(): any;
  74445. /**
  74446. * Parse properties from a JSON object
  74447. * @param serializationObject defines the JSON object
  74448. */
  74449. parse(serializationObject: any): void;
  74450. }
  74451. }
  74452. declare module BABYLON {
  74453. /**
  74454. * Particle emitter emitting particles from the inside of a cone.
  74455. * It emits the particles alongside the cone volume from the base to the particle.
  74456. * The emission direction might be randomized.
  74457. */
  74458. export class ConeParticleEmitter implements IParticleEmitterType {
  74459. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74460. directionRandomizer: number;
  74461. private _radius;
  74462. private _angle;
  74463. private _height;
  74464. /**
  74465. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  74466. */
  74467. radiusRange: number;
  74468. /**
  74469. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  74470. */
  74471. heightRange: number;
  74472. /**
  74473. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  74474. */
  74475. emitFromSpawnPointOnly: boolean;
  74476. /**
  74477. * Gets or sets the radius of the emission cone
  74478. */
  74479. radius: number;
  74480. /**
  74481. * Gets or sets the angle of the emission cone
  74482. */
  74483. angle: number;
  74484. private _buildHeight;
  74485. /**
  74486. * Creates a new instance ConeParticleEmitter
  74487. * @param radius the radius of the emission cone (1 by default)
  74488. * @param angle the cone base angle (PI by default)
  74489. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  74490. */
  74491. constructor(radius?: number, angle?: number,
  74492. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74493. directionRandomizer?: number);
  74494. /**
  74495. * Called by the particle System when the direction is computed for the created particle.
  74496. * @param worldMatrix is the world matrix of the particle system
  74497. * @param directionToUpdate is the direction vector to update with the result
  74498. * @param particle is the particle we are computed the direction for
  74499. */
  74500. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74501. /**
  74502. * Called by the particle System when the position is computed for the created particle.
  74503. * @param worldMatrix is the world matrix of the particle system
  74504. * @param positionToUpdate is the position vector to update with the result
  74505. * @param particle is the particle we are computed the position for
  74506. */
  74507. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74508. /**
  74509. * Clones the current emitter and returns a copy of it
  74510. * @returns the new emitter
  74511. */
  74512. clone(): ConeParticleEmitter;
  74513. /**
  74514. * Called by the GPUParticleSystem to setup the update shader
  74515. * @param effect defines the update shader
  74516. */
  74517. applyToShader(effect: Effect): void;
  74518. /**
  74519. * Returns a string to use to update the GPU particles update shader
  74520. * @returns a string containng the defines string
  74521. */
  74522. getEffectDefines(): string;
  74523. /**
  74524. * Returns the string "ConeParticleEmitter"
  74525. * @returns a string containing the class name
  74526. */
  74527. getClassName(): string;
  74528. /**
  74529. * Serializes the particle system to a JSON object.
  74530. * @returns the JSON object
  74531. */
  74532. serialize(): any;
  74533. /**
  74534. * Parse properties from a JSON object
  74535. * @param serializationObject defines the JSON object
  74536. */
  74537. parse(serializationObject: any): void;
  74538. }
  74539. }
  74540. declare module BABYLON {
  74541. /**
  74542. * Particle emitter emitting particles from the inside of a cylinder.
  74543. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  74544. */
  74545. export class CylinderParticleEmitter implements IParticleEmitterType {
  74546. /**
  74547. * The radius of the emission cylinder.
  74548. */
  74549. radius: number;
  74550. /**
  74551. * The height of the emission cylinder.
  74552. */
  74553. height: number;
  74554. /**
  74555. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74556. */
  74557. radiusRange: number;
  74558. /**
  74559. * How much to randomize the particle direction [0-1].
  74560. */
  74561. directionRandomizer: number;
  74562. /**
  74563. * Creates a new instance CylinderParticleEmitter
  74564. * @param radius the radius of the emission cylinder (1 by default)
  74565. * @param height the height of the emission cylinder (1 by default)
  74566. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74567. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74568. */
  74569. constructor(
  74570. /**
  74571. * The radius of the emission cylinder.
  74572. */
  74573. radius?: number,
  74574. /**
  74575. * The height of the emission cylinder.
  74576. */
  74577. height?: number,
  74578. /**
  74579. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74580. */
  74581. radiusRange?: number,
  74582. /**
  74583. * How much to randomize the particle direction [0-1].
  74584. */
  74585. directionRandomizer?: number);
  74586. /**
  74587. * Called by the particle System when the direction is computed for the created particle.
  74588. * @param worldMatrix is the world matrix of the particle system
  74589. * @param directionToUpdate is the direction vector to update with the result
  74590. * @param particle is the particle we are computed the direction for
  74591. */
  74592. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74593. /**
  74594. * Called by the particle System when the position is computed for the created particle.
  74595. * @param worldMatrix is the world matrix of the particle system
  74596. * @param positionToUpdate is the position vector to update with the result
  74597. * @param particle is the particle we are computed the position for
  74598. */
  74599. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74600. /**
  74601. * Clones the current emitter and returns a copy of it
  74602. * @returns the new emitter
  74603. */
  74604. clone(): CylinderParticleEmitter;
  74605. /**
  74606. * Called by the GPUParticleSystem to setup the update shader
  74607. * @param effect defines the update shader
  74608. */
  74609. applyToShader(effect: Effect): void;
  74610. /**
  74611. * Returns a string to use to update the GPU particles update shader
  74612. * @returns a string containng the defines string
  74613. */
  74614. getEffectDefines(): string;
  74615. /**
  74616. * Returns the string "CylinderParticleEmitter"
  74617. * @returns a string containing the class name
  74618. */
  74619. getClassName(): string;
  74620. /**
  74621. * Serializes the particle system to a JSON object.
  74622. * @returns the JSON object
  74623. */
  74624. serialize(): any;
  74625. /**
  74626. * Parse properties from a JSON object
  74627. * @param serializationObject defines the JSON object
  74628. */
  74629. parse(serializationObject: any): void;
  74630. }
  74631. /**
  74632. * Particle emitter emitting particles from the inside of a cylinder.
  74633. * It emits the particles randomly between two vectors.
  74634. */
  74635. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  74636. /**
  74637. * The min limit of the emission direction.
  74638. */
  74639. direction1: Vector3;
  74640. /**
  74641. * The max limit of the emission direction.
  74642. */
  74643. direction2: Vector3;
  74644. /**
  74645. * Creates a new instance CylinderDirectedParticleEmitter
  74646. * @param radius the radius of the emission cylinder (1 by default)
  74647. * @param height the height of the emission cylinder (1 by default)
  74648. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74649. * @param direction1 the min limit of the emission direction (up vector by default)
  74650. * @param direction2 the max limit of the emission direction (up vector by default)
  74651. */
  74652. constructor(radius?: number, height?: number, radiusRange?: number,
  74653. /**
  74654. * The min limit of the emission direction.
  74655. */
  74656. direction1?: Vector3,
  74657. /**
  74658. * The max limit of the emission direction.
  74659. */
  74660. direction2?: Vector3);
  74661. /**
  74662. * Called by the particle System when the direction is computed for the created particle.
  74663. * @param worldMatrix is the world matrix of the particle system
  74664. * @param directionToUpdate is the direction vector to update with the result
  74665. * @param particle is the particle we are computed the direction for
  74666. */
  74667. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74668. /**
  74669. * Clones the current emitter and returns a copy of it
  74670. * @returns the new emitter
  74671. */
  74672. clone(): CylinderDirectedParticleEmitter;
  74673. /**
  74674. * Called by the GPUParticleSystem to setup the update shader
  74675. * @param effect defines the update shader
  74676. */
  74677. applyToShader(effect: Effect): void;
  74678. /**
  74679. * Returns a string to use to update the GPU particles update shader
  74680. * @returns a string containng the defines string
  74681. */
  74682. getEffectDefines(): string;
  74683. /**
  74684. * Returns the string "CylinderDirectedParticleEmitter"
  74685. * @returns a string containing the class name
  74686. */
  74687. getClassName(): string;
  74688. /**
  74689. * Serializes the particle system to a JSON object.
  74690. * @returns the JSON object
  74691. */
  74692. serialize(): any;
  74693. /**
  74694. * Parse properties from a JSON object
  74695. * @param serializationObject defines the JSON object
  74696. */
  74697. parse(serializationObject: any): void;
  74698. }
  74699. }
  74700. declare module BABYLON {
  74701. /**
  74702. * Particle emitter emitting particles from the inside of a hemisphere.
  74703. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  74704. */
  74705. export class HemisphericParticleEmitter implements IParticleEmitterType {
  74706. /**
  74707. * The radius of the emission hemisphere.
  74708. */
  74709. radius: number;
  74710. /**
  74711. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74712. */
  74713. radiusRange: number;
  74714. /**
  74715. * How much to randomize the particle direction [0-1].
  74716. */
  74717. directionRandomizer: number;
  74718. /**
  74719. * Creates a new instance HemisphericParticleEmitter
  74720. * @param radius the radius of the emission hemisphere (1 by default)
  74721. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74722. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74723. */
  74724. constructor(
  74725. /**
  74726. * The radius of the emission hemisphere.
  74727. */
  74728. radius?: number,
  74729. /**
  74730. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74731. */
  74732. radiusRange?: number,
  74733. /**
  74734. * How much to randomize the particle direction [0-1].
  74735. */
  74736. directionRandomizer?: number);
  74737. /**
  74738. * Called by the particle System when the direction is computed for the created particle.
  74739. * @param worldMatrix is the world matrix of the particle system
  74740. * @param directionToUpdate is the direction vector to update with the result
  74741. * @param particle is the particle we are computed the direction for
  74742. */
  74743. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74744. /**
  74745. * Called by the particle System when the position is computed for the created particle.
  74746. * @param worldMatrix is the world matrix of the particle system
  74747. * @param positionToUpdate is the position vector to update with the result
  74748. * @param particle is the particle we are computed the position for
  74749. */
  74750. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74751. /**
  74752. * Clones the current emitter and returns a copy of it
  74753. * @returns the new emitter
  74754. */
  74755. clone(): HemisphericParticleEmitter;
  74756. /**
  74757. * Called by the GPUParticleSystem to setup the update shader
  74758. * @param effect defines the update shader
  74759. */
  74760. applyToShader(effect: Effect): void;
  74761. /**
  74762. * Returns a string to use to update the GPU particles update shader
  74763. * @returns a string containng the defines string
  74764. */
  74765. getEffectDefines(): string;
  74766. /**
  74767. * Returns the string "HemisphericParticleEmitter"
  74768. * @returns a string containing the class name
  74769. */
  74770. getClassName(): string;
  74771. /**
  74772. * Serializes the particle system to a JSON object.
  74773. * @returns the JSON object
  74774. */
  74775. serialize(): any;
  74776. /**
  74777. * Parse properties from a JSON object
  74778. * @param serializationObject defines the JSON object
  74779. */
  74780. parse(serializationObject: any): void;
  74781. }
  74782. }
  74783. declare module BABYLON {
  74784. /**
  74785. * Particle emitter emitting particles from a point.
  74786. * It emits the particles randomly between 2 given directions.
  74787. */
  74788. export class PointParticleEmitter implements IParticleEmitterType {
  74789. /**
  74790. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74791. */
  74792. direction1: Vector3;
  74793. /**
  74794. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74795. */
  74796. direction2: Vector3;
  74797. /**
  74798. * Creates a new instance PointParticleEmitter
  74799. */
  74800. constructor();
  74801. /**
  74802. * Called by the particle System when the direction is computed for the created particle.
  74803. * @param worldMatrix is the world matrix of the particle system
  74804. * @param directionToUpdate is the direction vector to update with the result
  74805. * @param particle is the particle we are computed the direction for
  74806. */
  74807. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74808. /**
  74809. * Called by the particle System when the position is computed for the created particle.
  74810. * @param worldMatrix is the world matrix of the particle system
  74811. * @param positionToUpdate is the position vector to update with the result
  74812. * @param particle is the particle we are computed the position for
  74813. */
  74814. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74815. /**
  74816. * Clones the current emitter and returns a copy of it
  74817. * @returns the new emitter
  74818. */
  74819. clone(): PointParticleEmitter;
  74820. /**
  74821. * Called by the GPUParticleSystem to setup the update shader
  74822. * @param effect defines the update shader
  74823. */
  74824. applyToShader(effect: Effect): void;
  74825. /**
  74826. * Returns a string to use to update the GPU particles update shader
  74827. * @returns a string containng the defines string
  74828. */
  74829. getEffectDefines(): string;
  74830. /**
  74831. * Returns the string "PointParticleEmitter"
  74832. * @returns a string containing the class name
  74833. */
  74834. getClassName(): string;
  74835. /**
  74836. * Serializes the particle system to a JSON object.
  74837. * @returns the JSON object
  74838. */
  74839. serialize(): any;
  74840. /**
  74841. * Parse properties from a JSON object
  74842. * @param serializationObject defines the JSON object
  74843. */
  74844. parse(serializationObject: any): void;
  74845. }
  74846. }
  74847. declare module BABYLON {
  74848. /**
  74849. * Particle emitter emitting particles from the inside of a sphere.
  74850. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  74851. */
  74852. export class SphereParticleEmitter implements IParticleEmitterType {
  74853. /**
  74854. * The radius of the emission sphere.
  74855. */
  74856. radius: number;
  74857. /**
  74858. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74859. */
  74860. radiusRange: number;
  74861. /**
  74862. * How much to randomize the particle direction [0-1].
  74863. */
  74864. directionRandomizer: number;
  74865. /**
  74866. * Creates a new instance SphereParticleEmitter
  74867. * @param radius the radius of the emission sphere (1 by default)
  74868. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74869. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74870. */
  74871. constructor(
  74872. /**
  74873. * The radius of the emission sphere.
  74874. */
  74875. radius?: number,
  74876. /**
  74877. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74878. */
  74879. radiusRange?: number,
  74880. /**
  74881. * How much to randomize the particle direction [0-1].
  74882. */
  74883. directionRandomizer?: number);
  74884. /**
  74885. * Called by the particle System when the direction is computed for the created particle.
  74886. * @param worldMatrix is the world matrix of the particle system
  74887. * @param directionToUpdate is the direction vector to update with the result
  74888. * @param particle is the particle we are computed the direction for
  74889. */
  74890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74891. /**
  74892. * Called by the particle System when the position is computed for the created particle.
  74893. * @param worldMatrix is the world matrix of the particle system
  74894. * @param positionToUpdate is the position vector to update with the result
  74895. * @param particle is the particle we are computed the position for
  74896. */
  74897. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74898. /**
  74899. * Clones the current emitter and returns a copy of it
  74900. * @returns the new emitter
  74901. */
  74902. clone(): SphereParticleEmitter;
  74903. /**
  74904. * Called by the GPUParticleSystem to setup the update shader
  74905. * @param effect defines the update shader
  74906. */
  74907. applyToShader(effect: Effect): void;
  74908. /**
  74909. * Returns a string to use to update the GPU particles update shader
  74910. * @returns a string containng the defines string
  74911. */
  74912. getEffectDefines(): string;
  74913. /**
  74914. * Returns the string "SphereParticleEmitter"
  74915. * @returns a string containing the class name
  74916. */
  74917. getClassName(): string;
  74918. /**
  74919. * Serializes the particle system to a JSON object.
  74920. * @returns the JSON object
  74921. */
  74922. serialize(): any;
  74923. /**
  74924. * Parse properties from a JSON object
  74925. * @param serializationObject defines the JSON object
  74926. */
  74927. parse(serializationObject: any): void;
  74928. }
  74929. /**
  74930. * Particle emitter emitting particles from the inside of a sphere.
  74931. * It emits the particles randomly between two vectors.
  74932. */
  74933. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  74934. /**
  74935. * The min limit of the emission direction.
  74936. */
  74937. direction1: Vector3;
  74938. /**
  74939. * The max limit of the emission direction.
  74940. */
  74941. direction2: Vector3;
  74942. /**
  74943. * Creates a new instance SphereDirectedParticleEmitter
  74944. * @param radius the radius of the emission sphere (1 by default)
  74945. * @param direction1 the min limit of the emission direction (up vector by default)
  74946. * @param direction2 the max limit of the emission direction (up vector by default)
  74947. */
  74948. constructor(radius?: number,
  74949. /**
  74950. * The min limit of the emission direction.
  74951. */
  74952. direction1?: Vector3,
  74953. /**
  74954. * The max limit of the emission direction.
  74955. */
  74956. direction2?: Vector3);
  74957. /**
  74958. * Called by the particle System when the direction is computed for the created particle.
  74959. * @param worldMatrix is the world matrix of the particle system
  74960. * @param directionToUpdate is the direction vector to update with the result
  74961. * @param particle is the particle we are computed the direction for
  74962. */
  74963. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74964. /**
  74965. * Clones the current emitter and returns a copy of it
  74966. * @returns the new emitter
  74967. */
  74968. clone(): SphereDirectedParticleEmitter;
  74969. /**
  74970. * Called by the GPUParticleSystem to setup the update shader
  74971. * @param effect defines the update shader
  74972. */
  74973. applyToShader(effect: Effect): void;
  74974. /**
  74975. * Returns a string to use to update the GPU particles update shader
  74976. * @returns a string containng the defines string
  74977. */
  74978. getEffectDefines(): string;
  74979. /**
  74980. * Returns the string "SphereDirectedParticleEmitter"
  74981. * @returns a string containing the class name
  74982. */
  74983. getClassName(): string;
  74984. /**
  74985. * Serializes the particle system to a JSON object.
  74986. * @returns the JSON object
  74987. */
  74988. serialize(): any;
  74989. /**
  74990. * Parse properties from a JSON object
  74991. * @param serializationObject defines the JSON object
  74992. */
  74993. parse(serializationObject: any): void;
  74994. }
  74995. }
  74996. declare module BABYLON {
  74997. /**
  74998. * Interface representing a particle system in Babylon.js.
  74999. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  75000. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  75001. */
  75002. export interface IParticleSystem {
  75003. /**
  75004. * List of animations used by the particle system.
  75005. */
  75006. animations: Animation[];
  75007. /**
  75008. * The id of the Particle system.
  75009. */
  75010. id: string;
  75011. /**
  75012. * The name of the Particle system.
  75013. */
  75014. name: string;
  75015. /**
  75016. * The emitter represents the Mesh or position we are attaching the particle system to.
  75017. */
  75018. emitter: Nullable<AbstractMesh | Vector3>;
  75019. /**
  75020. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  75021. */
  75022. isBillboardBased: boolean;
  75023. /**
  75024. * The rendering group used by the Particle system to chose when to render.
  75025. */
  75026. renderingGroupId: number;
  75027. /**
  75028. * The layer mask we are rendering the particles through.
  75029. */
  75030. layerMask: number;
  75031. /**
  75032. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  75033. */
  75034. updateSpeed: number;
  75035. /**
  75036. * The amount of time the particle system is running (depends of the overall update speed).
  75037. */
  75038. targetStopDuration: number;
  75039. /**
  75040. * The texture used to render each particle. (this can be a spritesheet)
  75041. */
  75042. particleTexture: Nullable<Texture>;
  75043. /**
  75044. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  75045. */
  75046. blendMode: number;
  75047. /**
  75048. * Minimum life time of emitting particles.
  75049. */
  75050. minLifeTime: number;
  75051. /**
  75052. * Maximum life time of emitting particles.
  75053. */
  75054. maxLifeTime: number;
  75055. /**
  75056. * Minimum Size of emitting particles.
  75057. */
  75058. minSize: number;
  75059. /**
  75060. * Maximum Size of emitting particles.
  75061. */
  75062. maxSize: number;
  75063. /**
  75064. * Minimum scale of emitting particles on X axis.
  75065. */
  75066. minScaleX: number;
  75067. /**
  75068. * Maximum scale of emitting particles on X axis.
  75069. */
  75070. maxScaleX: number;
  75071. /**
  75072. * Minimum scale of emitting particles on Y axis.
  75073. */
  75074. minScaleY: number;
  75075. /**
  75076. * Maximum scale of emitting particles on Y axis.
  75077. */
  75078. maxScaleY: number;
  75079. /**
  75080. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75081. */
  75082. color1: Color4;
  75083. /**
  75084. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75085. */
  75086. color2: Color4;
  75087. /**
  75088. * Color the particle will have at the end of its lifetime.
  75089. */
  75090. colorDead: Color4;
  75091. /**
  75092. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  75093. */
  75094. emitRate: number;
  75095. /**
  75096. * You can use gravity if you want to give an orientation to your particles.
  75097. */
  75098. gravity: Vector3;
  75099. /**
  75100. * Minimum power of emitting particles.
  75101. */
  75102. minEmitPower: number;
  75103. /**
  75104. * Maximum power of emitting particles.
  75105. */
  75106. maxEmitPower: number;
  75107. /**
  75108. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  75109. */
  75110. minAngularSpeed: number;
  75111. /**
  75112. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  75113. */
  75114. maxAngularSpeed: number;
  75115. /**
  75116. * Gets or sets the minimal initial rotation in radians.
  75117. */
  75118. minInitialRotation: number;
  75119. /**
  75120. * Gets or sets the maximal initial rotation in radians.
  75121. */
  75122. maxInitialRotation: number;
  75123. /**
  75124. * The particle emitter type defines the emitter used by the particle system.
  75125. * It can be for example box, sphere, or cone...
  75126. */
  75127. particleEmitterType: Nullable<IParticleEmitterType>;
  75128. /**
  75129. * Defines the delay in milliseconds before starting the system (0 by default)
  75130. */
  75131. startDelay: number;
  75132. /**
  75133. * 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
  75134. */
  75135. preWarmCycles: number;
  75136. /**
  75137. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  75138. */
  75139. preWarmStepOffset: number;
  75140. /**
  75141. * 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)
  75142. */
  75143. spriteCellChangeSpeed: number;
  75144. /**
  75145. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  75146. */
  75147. startSpriteCellID: number;
  75148. /**
  75149. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  75150. */
  75151. endSpriteCellID: number;
  75152. /**
  75153. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  75154. */
  75155. spriteCellWidth: number;
  75156. /**
  75157. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  75158. */
  75159. spriteCellHeight: number;
  75160. /**
  75161. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  75162. */
  75163. spriteRandomStartCell: boolean;
  75164. /**
  75165. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  75166. */
  75167. isAnimationSheetEnabled: boolean;
  75168. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  75169. translationPivot: Vector2;
  75170. /**
  75171. * Gets or sets a texture used to add random noise to particle positions
  75172. */
  75173. noiseTexture: Nullable<BaseTexture>;
  75174. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  75175. noiseStrength: Vector3;
  75176. /**
  75177. * Gets or sets the billboard mode to use when isBillboardBased = true.
  75178. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  75179. */
  75180. billboardMode: number;
  75181. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  75182. limitVelocityDamping: number;
  75183. /**
  75184. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  75185. */
  75186. beginAnimationOnStart: boolean;
  75187. /**
  75188. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  75189. */
  75190. beginAnimationFrom: number;
  75191. /**
  75192. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  75193. */
  75194. beginAnimationTo: number;
  75195. /**
  75196. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  75197. */
  75198. beginAnimationLoop: boolean;
  75199. /**
  75200. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  75201. */
  75202. disposeOnStop: boolean;
  75203. /**
  75204. * Gets the maximum number of particles active at the same time.
  75205. * @returns The max number of active particles.
  75206. */
  75207. getCapacity(): number;
  75208. /**
  75209. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75210. * @returns True if it has been started, otherwise false.
  75211. */
  75212. isStarted(): boolean;
  75213. /**
  75214. * Animates the particle system for this frame.
  75215. */
  75216. animate(): void;
  75217. /**
  75218. * Renders the particle system in its current state.
  75219. * @returns the current number of particles
  75220. */
  75221. render(): number;
  75222. /**
  75223. * Dispose the particle system and frees its associated resources.
  75224. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75225. */
  75226. dispose(disposeTexture?: boolean): void;
  75227. /**
  75228. * Clones the particle system.
  75229. * @param name The name of the cloned object
  75230. * @param newEmitter The new emitter to use
  75231. * @returns the cloned particle system
  75232. */
  75233. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  75234. /**
  75235. * Serializes the particle system to a JSON object.
  75236. * @returns the JSON object
  75237. */
  75238. serialize(): any;
  75239. /**
  75240. * Rebuild the particle system
  75241. */
  75242. rebuild(): void;
  75243. /**
  75244. * Starts the particle system and begins to emit
  75245. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  75246. */
  75247. start(delay?: number): void;
  75248. /**
  75249. * Stops the particle system.
  75250. */
  75251. stop(): void;
  75252. /**
  75253. * Remove all active particles
  75254. */
  75255. reset(): void;
  75256. /**
  75257. * Is this system ready to be used/rendered
  75258. * @return true if the system is ready
  75259. */
  75260. isReady(): boolean;
  75261. /**
  75262. * Adds a new color gradient
  75263. * @param gradient defines the gradient to use (between 0 and 1)
  75264. * @param color1 defines the color to affect to the specified gradient
  75265. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75266. * @returns the current particle system
  75267. */
  75268. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75269. /**
  75270. * Remove a specific color gradient
  75271. * @param gradient defines the gradient to remove
  75272. * @returns the current particle system
  75273. */
  75274. removeColorGradient(gradient: number): IParticleSystem;
  75275. /**
  75276. * Adds a new size gradient
  75277. * @param gradient defines the gradient to use (between 0 and 1)
  75278. * @param factor defines the size factor to affect to the specified gradient
  75279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75280. * @returns the current particle system
  75281. */
  75282. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75283. /**
  75284. * Remove a specific size gradient
  75285. * @param gradient defines the gradient to remove
  75286. * @returns the current particle system
  75287. */
  75288. removeSizeGradient(gradient: number): IParticleSystem;
  75289. /**
  75290. * Gets the current list of color gradients.
  75291. * You must use addColorGradient and removeColorGradient to udpate this list
  75292. * @returns the list of color gradients
  75293. */
  75294. getColorGradients(): Nullable<Array<ColorGradient>>;
  75295. /**
  75296. * Gets the current list of size gradients.
  75297. * You must use addSizeGradient and removeSizeGradient to udpate this list
  75298. * @returns the list of size gradients
  75299. */
  75300. getSizeGradients(): Nullable<Array<FactorGradient>>;
  75301. /**
  75302. * Gets the current list of angular speed gradients.
  75303. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  75304. * @returns the list of angular speed gradients
  75305. */
  75306. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  75307. /**
  75308. * Adds a new angular speed gradient
  75309. * @param gradient defines the gradient to use (between 0 and 1)
  75310. * @param factor defines the angular speed to affect to the specified gradient
  75311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75312. * @returns the current particle system
  75313. */
  75314. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75315. /**
  75316. * Remove a specific angular speed gradient
  75317. * @param gradient defines the gradient to remove
  75318. * @returns the current particle system
  75319. */
  75320. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75321. /**
  75322. * Gets the current list of velocity gradients.
  75323. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  75324. * @returns the list of velocity gradients
  75325. */
  75326. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  75327. /**
  75328. * Adds a new velocity gradient
  75329. * @param gradient defines the gradient to use (between 0 and 1)
  75330. * @param factor defines the velocity to affect to the specified gradient
  75331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75332. * @returns the current particle system
  75333. */
  75334. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75335. /**
  75336. * Remove a specific velocity gradient
  75337. * @param gradient defines the gradient to remove
  75338. * @returns the current particle system
  75339. */
  75340. removeVelocityGradient(gradient: number): IParticleSystem;
  75341. /**
  75342. * Gets the current list of limit velocity gradients.
  75343. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  75344. * @returns the list of limit velocity gradients
  75345. */
  75346. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  75347. /**
  75348. * Adds a new limit velocity gradient
  75349. * @param gradient defines the gradient to use (between 0 and 1)
  75350. * @param factor defines the limit velocity to affect to the specified gradient
  75351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75352. * @returns the current particle system
  75353. */
  75354. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75355. /**
  75356. * Remove a specific limit velocity gradient
  75357. * @param gradient defines the gradient to remove
  75358. * @returns the current particle system
  75359. */
  75360. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75361. /**
  75362. * Adds a new drag gradient
  75363. * @param gradient defines the gradient to use (between 0 and 1)
  75364. * @param factor defines the drag to affect to the specified gradient
  75365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75366. * @returns the current particle system
  75367. */
  75368. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75369. /**
  75370. * Remove a specific drag gradient
  75371. * @param gradient defines the gradient to remove
  75372. * @returns the current particle system
  75373. */
  75374. removeDragGradient(gradient: number): IParticleSystem;
  75375. /**
  75376. * Gets the current list of drag gradients.
  75377. * You must use addDragGradient and removeDragGradient to udpate this list
  75378. * @returns the list of drag gradients
  75379. */
  75380. getDragGradients(): Nullable<Array<FactorGradient>>;
  75381. /**
  75382. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75383. * @param gradient defines the gradient to use (between 0 and 1)
  75384. * @param factor defines the emit rate to affect to the specified gradient
  75385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75386. * @returns the current particle system
  75387. */
  75388. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75389. /**
  75390. * Remove a specific emit rate gradient
  75391. * @param gradient defines the gradient to remove
  75392. * @returns the current particle system
  75393. */
  75394. removeEmitRateGradient(gradient: number): IParticleSystem;
  75395. /**
  75396. * Gets the current list of emit rate gradients.
  75397. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  75398. * @returns the list of emit rate gradients
  75399. */
  75400. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  75401. /**
  75402. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75403. * @param gradient defines the gradient to use (between 0 and 1)
  75404. * @param factor defines the start size to affect to the specified gradient
  75405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75406. * @returns the current particle system
  75407. */
  75408. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75409. /**
  75410. * Remove a specific start size gradient
  75411. * @param gradient defines the gradient to remove
  75412. * @returns the current particle system
  75413. */
  75414. removeStartSizeGradient(gradient: number): IParticleSystem;
  75415. /**
  75416. * Gets the current list of start size gradients.
  75417. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  75418. * @returns the list of start size gradients
  75419. */
  75420. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  75421. /**
  75422. * Adds a new life time gradient
  75423. * @param gradient defines the gradient to use (between 0 and 1)
  75424. * @param factor defines the life time factor to affect to the specified gradient
  75425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75426. * @returns the current particle system
  75427. */
  75428. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75429. /**
  75430. * Remove a specific life time gradient
  75431. * @param gradient defines the gradient to remove
  75432. * @returns the current particle system
  75433. */
  75434. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75435. /**
  75436. * Gets the current list of life time gradients.
  75437. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  75438. * @returns the list of life time gradients
  75439. */
  75440. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  75441. /**
  75442. * Gets the current list of color gradients.
  75443. * You must use addColorGradient and removeColorGradient to udpate this list
  75444. * @returns the list of color gradients
  75445. */
  75446. getColorGradients(): Nullable<Array<ColorGradient>>;
  75447. /**
  75448. * Adds a new ramp gradient used to remap particle colors
  75449. * @param gradient defines the gradient to use (between 0 and 1)
  75450. * @param color defines the color to affect to the specified gradient
  75451. * @returns the current particle system
  75452. */
  75453. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75454. /**
  75455. * Gets the current list of ramp gradients.
  75456. * You must use addRampGradient and removeRampGradient to udpate this list
  75457. * @returns the list of ramp gradients
  75458. */
  75459. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75460. /** Gets or sets a boolean indicating that ramp gradients must be used
  75461. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75462. */
  75463. useRampGradients: boolean;
  75464. /**
  75465. * Adds a new color remap gradient
  75466. * @param gradient defines the gradient to use (between 0 and 1)
  75467. * @param min defines the color remap minimal range
  75468. * @param max defines the color remap maximal range
  75469. * @returns the current particle system
  75470. */
  75471. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75472. /**
  75473. * Gets the current list of color remap gradients.
  75474. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  75475. * @returns the list of color remap gradients
  75476. */
  75477. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  75478. /**
  75479. * Adds a new alpha remap gradient
  75480. * @param gradient defines the gradient to use (between 0 and 1)
  75481. * @param min defines the alpha remap minimal range
  75482. * @param max defines the alpha remap maximal range
  75483. * @returns the current particle system
  75484. */
  75485. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75486. /**
  75487. * Gets the current list of alpha remap gradients.
  75488. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  75489. * @returns the list of alpha remap gradients
  75490. */
  75491. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  75492. /**
  75493. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  75494. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75495. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75496. * @returns the emitter
  75497. */
  75498. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  75499. /**
  75500. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  75501. * @param radius The radius of the hemisphere to emit from
  75502. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75503. * @returns the emitter
  75504. */
  75505. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  75506. /**
  75507. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  75508. * @param radius The radius of the sphere to emit from
  75509. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75510. * @returns the emitter
  75511. */
  75512. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  75513. /**
  75514. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  75515. * @param radius The radius of the sphere to emit from
  75516. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  75517. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  75518. * @returns the emitter
  75519. */
  75520. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75521. /**
  75522. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  75523. * @param radius The radius of the emission cylinder
  75524. * @param height The height of the emission cylinder
  75525. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  75526. * @param directionRandomizer How much to randomize the particle direction [0-1]
  75527. * @returns the emitter
  75528. */
  75529. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  75530. /**
  75531. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  75532. * @param radius The radius of the cylinder to emit from
  75533. * @param height The height of the emission cylinder
  75534. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75535. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  75536. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  75537. * @returns the emitter
  75538. */
  75539. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75540. /**
  75541. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  75542. * @param radius The radius of the cone to emit from
  75543. * @param angle The base angle of the cone
  75544. * @returns the emitter
  75545. */
  75546. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  75547. /**
  75548. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  75549. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75550. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75551. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75552. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75553. * @returns the emitter
  75554. */
  75555. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  75556. /**
  75557. * Get hosting scene
  75558. * @returns the scene
  75559. */
  75560. getScene(): Scene;
  75561. }
  75562. }
  75563. declare module BABYLON {
  75564. /**
  75565. * Creates an instance based on a source mesh.
  75566. */
  75567. export class InstancedMesh extends AbstractMesh {
  75568. private _sourceMesh;
  75569. private _currentLOD;
  75570. /** @hidden */
  75571. _indexInSourceMeshInstanceArray: number;
  75572. constructor(name: string, source: Mesh);
  75573. /**
  75574. * Returns the string "InstancedMesh".
  75575. */
  75576. getClassName(): string;
  75577. /**
  75578. * If the source mesh receives shadows
  75579. */
  75580. readonly receiveShadows: boolean;
  75581. /**
  75582. * The material of the source mesh
  75583. */
  75584. readonly material: Nullable<Material>;
  75585. /**
  75586. * Visibility of the source mesh
  75587. */
  75588. readonly visibility: number;
  75589. /**
  75590. * Skeleton of the source mesh
  75591. */
  75592. readonly skeleton: Nullable<Skeleton>;
  75593. /**
  75594. * Rendering ground id of the source mesh
  75595. */
  75596. renderingGroupId: number;
  75597. /**
  75598. * Returns the total number of vertices (integer).
  75599. */
  75600. getTotalVertices(): number;
  75601. /**
  75602. * Returns a positive integer : the total number of indices in this mesh geometry.
  75603. * @returns the numner of indices or zero if the mesh has no geometry.
  75604. */
  75605. getTotalIndices(): number;
  75606. /**
  75607. * The source mesh of the instance
  75608. */
  75609. readonly sourceMesh: Mesh;
  75610. /**
  75611. * Is this node ready to be used/rendered
  75612. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75613. * @return {boolean} is it ready
  75614. */
  75615. isReady(completeCheck?: boolean): boolean;
  75616. /**
  75617. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75618. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75619. * @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.
  75620. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75621. */
  75622. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75623. /**
  75624. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75625. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75626. * The `data` are either a numeric array either a Float32Array.
  75627. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75628. * 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).
  75629. * Note that a new underlying VertexBuffer object is created each call.
  75630. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75631. *
  75632. * Possible `kind` values :
  75633. * - VertexBuffer.PositionKind
  75634. * - VertexBuffer.UVKind
  75635. * - VertexBuffer.UV2Kind
  75636. * - VertexBuffer.UV3Kind
  75637. * - VertexBuffer.UV4Kind
  75638. * - VertexBuffer.UV5Kind
  75639. * - VertexBuffer.UV6Kind
  75640. * - VertexBuffer.ColorKind
  75641. * - VertexBuffer.MatricesIndicesKind
  75642. * - VertexBuffer.MatricesIndicesExtraKind
  75643. * - VertexBuffer.MatricesWeightsKind
  75644. * - VertexBuffer.MatricesWeightsExtraKind
  75645. *
  75646. * Returns the Mesh.
  75647. */
  75648. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75649. /**
  75650. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75651. * If the mesh has no geometry, it is simply returned as it is.
  75652. * The `data` are either a numeric array either a Float32Array.
  75653. * No new underlying VertexBuffer object is created.
  75654. * 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.
  75655. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75656. *
  75657. * Possible `kind` values :
  75658. * - VertexBuffer.PositionKind
  75659. * - VertexBuffer.UVKind
  75660. * - VertexBuffer.UV2Kind
  75661. * - VertexBuffer.UV3Kind
  75662. * - VertexBuffer.UV4Kind
  75663. * - VertexBuffer.UV5Kind
  75664. * - VertexBuffer.UV6Kind
  75665. * - VertexBuffer.ColorKind
  75666. * - VertexBuffer.MatricesIndicesKind
  75667. * - VertexBuffer.MatricesIndicesExtraKind
  75668. * - VertexBuffer.MatricesWeightsKind
  75669. * - VertexBuffer.MatricesWeightsExtraKind
  75670. *
  75671. * Returns the Mesh.
  75672. */
  75673. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75674. /**
  75675. * Sets the mesh indices.
  75676. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75677. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75678. * This method creates a new index buffer each call.
  75679. * Returns the Mesh.
  75680. */
  75681. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75682. /**
  75683. * Boolean : True if the mesh owns the requested kind of data.
  75684. */
  75685. isVerticesDataPresent(kind: string): boolean;
  75686. /**
  75687. * Returns an array of indices (IndicesArray).
  75688. */
  75689. getIndices(): Nullable<IndicesArray>;
  75690. readonly _positions: Nullable<Vector3[]>;
  75691. /**
  75692. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75693. * This means the mesh underlying bounding box and sphere are recomputed.
  75694. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75695. * @returns the current mesh
  75696. */
  75697. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75698. /** @hidden */
  75699. _preActivate(): InstancedMesh;
  75700. /** @hidden */
  75701. _activate(renderId: number): InstancedMesh;
  75702. /**
  75703. * Returns the current associated LOD AbstractMesh.
  75704. */
  75705. getLOD(camera: Camera): AbstractMesh;
  75706. /** @hidden */
  75707. _syncSubMeshes(): InstancedMesh;
  75708. /** @hidden */
  75709. _generatePointsArray(): boolean;
  75710. /**
  75711. * Creates a new InstancedMesh from the current mesh.
  75712. * - name (string) : the cloned mesh name
  75713. * - newParent (optional Node) : the optional Node to parent the clone to.
  75714. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  75715. *
  75716. * Returns the clone.
  75717. */
  75718. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  75719. /**
  75720. * Disposes the InstancedMesh.
  75721. * Returns nothing.
  75722. */
  75723. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75724. }
  75725. }
  75726. declare module BABYLON {
  75727. /**
  75728. * Defines the options associated with the creation of a shader material.
  75729. */
  75730. export interface IShaderMaterialOptions {
  75731. /**
  75732. * Does the material work in alpha blend mode
  75733. */
  75734. needAlphaBlending: boolean;
  75735. /**
  75736. * Does the material work in alpha test mode
  75737. */
  75738. needAlphaTesting: boolean;
  75739. /**
  75740. * The list of attribute names used in the shader
  75741. */
  75742. attributes: string[];
  75743. /**
  75744. * The list of unifrom names used in the shader
  75745. */
  75746. uniforms: string[];
  75747. /**
  75748. * The list of UBO names used in the shader
  75749. */
  75750. uniformBuffers: string[];
  75751. /**
  75752. * The list of sampler names used in the shader
  75753. */
  75754. samplers: string[];
  75755. /**
  75756. * The list of defines used in the shader
  75757. */
  75758. defines: string[];
  75759. }
  75760. /**
  75761. * 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.
  75762. *
  75763. * This returned material effects how the mesh will look based on the code in the shaders.
  75764. *
  75765. * @see http://doc.babylonjs.com/how_to/shader_material
  75766. */
  75767. export class ShaderMaterial extends Material {
  75768. private _shaderPath;
  75769. private _options;
  75770. private _textures;
  75771. private _textureArrays;
  75772. private _floats;
  75773. private _ints;
  75774. private _floatsArrays;
  75775. private _colors3;
  75776. private _colors3Arrays;
  75777. private _colors4;
  75778. private _vectors2;
  75779. private _vectors3;
  75780. private _vectors4;
  75781. private _matrices;
  75782. private _matrices3x3;
  75783. private _matrices2x2;
  75784. private _vectors2Arrays;
  75785. private _vectors3Arrays;
  75786. private _cachedWorldViewMatrix;
  75787. private _renderId;
  75788. /**
  75789. * Instantiate a new shader material.
  75790. * 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.
  75791. * This returned material effects how the mesh will look based on the code in the shaders.
  75792. * @see http://doc.babylonjs.com/how_to/shader_material
  75793. * @param name Define the name of the material in the scene
  75794. * @param scene Define the scene the material belongs to
  75795. * @param shaderPath Defines the route to the shader code in one of three ways:
  75796. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75797. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75798. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75799. * @param options Define the options used to create the shader
  75800. */
  75801. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75802. /**
  75803. * Gets the options used to compile the shader.
  75804. * They can be modified to trigger a new compilation
  75805. */
  75806. readonly options: IShaderMaterialOptions;
  75807. /**
  75808. * Gets the current class name of the material e.g. "ShaderMaterial"
  75809. * Mainly use in serialization.
  75810. * @returns the class name
  75811. */
  75812. getClassName(): string;
  75813. /**
  75814. * Specifies if the material will require alpha blending
  75815. * @returns a boolean specifying if alpha blending is needed
  75816. */
  75817. needAlphaBlending(): boolean;
  75818. /**
  75819. * Specifies if this material should be rendered in alpha test mode
  75820. * @returns a boolean specifying if an alpha test is needed.
  75821. */
  75822. needAlphaTesting(): boolean;
  75823. private _checkUniform;
  75824. /**
  75825. * Set a texture in the shader.
  75826. * @param name Define the name of the uniform samplers as defined in the shader
  75827. * @param texture Define the texture to bind to this sampler
  75828. * @return the material itself allowing "fluent" like uniform updates
  75829. */
  75830. setTexture(name: string, texture: Texture): ShaderMaterial;
  75831. /**
  75832. * Set a texture array in the shader.
  75833. * @param name Define the name of the uniform sampler array as defined in the shader
  75834. * @param textures Define the list of textures to bind to this sampler
  75835. * @return the material itself allowing "fluent" like uniform updates
  75836. */
  75837. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75838. /**
  75839. * Set a float in the shader.
  75840. * @param name Define the name of the uniform as defined in the shader
  75841. * @param value Define the value to give to the uniform
  75842. * @return the material itself allowing "fluent" like uniform updates
  75843. */
  75844. setFloat(name: string, value: number): ShaderMaterial;
  75845. /**
  75846. * Set a int in the shader.
  75847. * @param name Define the name of the uniform as defined in the shader
  75848. * @param value Define the value to give to the uniform
  75849. * @return the material itself allowing "fluent" like uniform updates
  75850. */
  75851. setInt(name: string, value: number): ShaderMaterial;
  75852. /**
  75853. * Set an array of floats in the shader.
  75854. * @param name Define the name of the uniform as defined in the shader
  75855. * @param value Define the value to give to the uniform
  75856. * @return the material itself allowing "fluent" like uniform updates
  75857. */
  75858. setFloats(name: string, value: number[]): ShaderMaterial;
  75859. /**
  75860. * Set a vec3 in the shader from a Color3.
  75861. * @param name Define the name of the uniform as defined in the shader
  75862. * @param value Define the value to give to the uniform
  75863. * @return the material itself allowing "fluent" like uniform updates
  75864. */
  75865. setColor3(name: string, value: Color3): ShaderMaterial;
  75866. /**
  75867. * Set a vec3 array in the shader from a Color3 array.
  75868. * @param name Define the name of the uniform as defined in the shader
  75869. * @param value Define the value to give to the uniform
  75870. * @return the material itself allowing "fluent" like uniform updates
  75871. */
  75872. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75873. /**
  75874. * Set a vec4 in the shader from a Color4.
  75875. * @param name Define the name of the uniform as defined in the shader
  75876. * @param value Define the value to give to the uniform
  75877. * @return the material itself allowing "fluent" like uniform updates
  75878. */
  75879. setColor4(name: string, value: Color4): ShaderMaterial;
  75880. /**
  75881. * Set a vec2 in the shader from a Vector2.
  75882. * @param name Define the name of the uniform as defined in the shader
  75883. * @param value Define the value to give to the uniform
  75884. * @return the material itself allowing "fluent" like uniform updates
  75885. */
  75886. setVector2(name: string, value: Vector2): ShaderMaterial;
  75887. /**
  75888. * Set a vec3 in the shader from a Vector3.
  75889. * @param name Define the name of the uniform as defined in the shader
  75890. * @param value Define the value to give to the uniform
  75891. * @return the material itself allowing "fluent" like uniform updates
  75892. */
  75893. setVector3(name: string, value: Vector3): ShaderMaterial;
  75894. /**
  75895. * Set a vec4 in the shader from a Vector4.
  75896. * @param name Define the name of the uniform as defined in the shader
  75897. * @param value Define the value to give to the uniform
  75898. * @return the material itself allowing "fluent" like uniform updates
  75899. */
  75900. setVector4(name: string, value: Vector4): ShaderMaterial;
  75901. /**
  75902. * Set a mat4 in the shader from a Matrix.
  75903. * @param name Define the name of the uniform as defined in the shader
  75904. * @param value Define the value to give to the uniform
  75905. * @return the material itself allowing "fluent" like uniform updates
  75906. */
  75907. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75908. /**
  75909. * Set a mat3 in the shader from a Float32Array.
  75910. * @param name Define the name of the uniform as defined in the shader
  75911. * @param value Define the value to give to the uniform
  75912. * @return the material itself allowing "fluent" like uniform updates
  75913. */
  75914. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75915. /**
  75916. * Set a mat2 in the shader from a Float32Array.
  75917. * @param name Define the name of the uniform as defined in the shader
  75918. * @param value Define the value to give to the uniform
  75919. * @return the material itself allowing "fluent" like uniform updates
  75920. */
  75921. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75922. /**
  75923. * Set a vec2 array in the shader from a number array.
  75924. * @param name Define the name of the uniform as defined in the shader
  75925. * @param value Define the value to give to the uniform
  75926. * @return the material itself allowing "fluent" like uniform updates
  75927. */
  75928. setArray2(name: string, value: number[]): ShaderMaterial;
  75929. /**
  75930. * Set a vec3 array in the shader from a number array.
  75931. * @param name Define the name of the uniform as defined in the shader
  75932. * @param value Define the value to give to the uniform
  75933. * @return the material itself allowing "fluent" like uniform updates
  75934. */
  75935. setArray3(name: string, value: number[]): ShaderMaterial;
  75936. private _checkCache;
  75937. /**
  75938. * Specifies that the submesh is ready to be used
  75939. * @param mesh defines the mesh to check
  75940. * @param subMesh defines which submesh to check
  75941. * @param useInstances specifies that instances should be used
  75942. * @returns a boolean indicating that the submesh is ready or not
  75943. */
  75944. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75945. /**
  75946. * Checks if the material is ready to render the requested mesh
  75947. * @param mesh Define the mesh to render
  75948. * @param useInstances Define whether or not the material is used with instances
  75949. * @returns true if ready, otherwise false
  75950. */
  75951. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75952. /**
  75953. * Binds the world matrix to the material
  75954. * @param world defines the world transformation matrix
  75955. */
  75956. bindOnlyWorldMatrix(world: Matrix): void;
  75957. /**
  75958. * Binds the material to the mesh
  75959. * @param world defines the world transformation matrix
  75960. * @param mesh defines the mesh to bind the material to
  75961. */
  75962. bind(world: Matrix, mesh?: Mesh): void;
  75963. /**
  75964. * Gets the active textures from the material
  75965. * @returns an array of textures
  75966. */
  75967. getActiveTextures(): BaseTexture[];
  75968. /**
  75969. * Specifies if the material uses a texture
  75970. * @param texture defines the texture to check against the material
  75971. * @returns a boolean specifying if the material uses the texture
  75972. */
  75973. hasTexture(texture: BaseTexture): boolean;
  75974. /**
  75975. * Makes a duplicate of the material, and gives it a new name
  75976. * @param name defines the new name for the duplicated material
  75977. * @returns the cloned material
  75978. */
  75979. clone(name: string): ShaderMaterial;
  75980. /**
  75981. * Disposes the material
  75982. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75983. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75984. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75985. */
  75986. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75987. /**
  75988. * Serializes this material in a JSON representation
  75989. * @returns the serialized material object
  75990. */
  75991. serialize(): any;
  75992. /**
  75993. * Creates a shader material from parsed shader material data
  75994. * @param source defines the JSON represnetation of the material
  75995. * @param scene defines the hosting scene
  75996. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75997. * @returns a new material
  75998. */
  75999. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  76000. }
  76001. }
  76002. declare module BABYLON {
  76003. /** @hidden */
  76004. export var colorPixelShader: {
  76005. name: string;
  76006. shader: string;
  76007. };
  76008. }
  76009. declare module BABYLON {
  76010. /** @hidden */
  76011. export var colorVertexShader: {
  76012. name: string;
  76013. shader: string;
  76014. };
  76015. }
  76016. declare module BABYLON {
  76017. /**
  76018. * Line mesh
  76019. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  76020. */
  76021. export class LinesMesh extends Mesh {
  76022. /**
  76023. * If vertex color should be applied to the mesh
  76024. */
  76025. useVertexColor?: boolean | undefined;
  76026. /**
  76027. * If vertex alpha should be applied to the mesh
  76028. */
  76029. useVertexAlpha?: boolean | undefined;
  76030. /**
  76031. * Color of the line (Default: White)
  76032. */
  76033. color: Color3;
  76034. /**
  76035. * Alpha of the line (Default: 1)
  76036. */
  76037. alpha: number;
  76038. /**
  76039. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76040. * This margin is expressed in world space coordinates, so its value may vary.
  76041. * Default value is 0.1
  76042. */
  76043. intersectionThreshold: number;
  76044. private _colorShader;
  76045. /**
  76046. * Creates a new LinesMesh
  76047. * @param name defines the name
  76048. * @param scene defines the hosting scene
  76049. * @param parent defines the parent mesh if any
  76050. * @param source defines the optional source LinesMesh used to clone data from
  76051. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76052. * When false, achieved by calling a clone(), also passing False.
  76053. * This will make creation of children, recursive.
  76054. * @param useVertexColor defines if this LinesMesh supports vertex color
  76055. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  76056. */
  76057. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  76058. /**
  76059. * If vertex color should be applied to the mesh
  76060. */
  76061. useVertexColor?: boolean | undefined,
  76062. /**
  76063. * If vertex alpha should be applied to the mesh
  76064. */
  76065. useVertexAlpha?: boolean | undefined);
  76066. private _addClipPlaneDefine;
  76067. private _removeClipPlaneDefine;
  76068. isReady(): boolean;
  76069. /**
  76070. * Returns the string "LineMesh"
  76071. */
  76072. getClassName(): string;
  76073. /**
  76074. * @hidden
  76075. */
  76076. /**
  76077. * @hidden
  76078. */
  76079. material: Material;
  76080. /**
  76081. * @hidden
  76082. */
  76083. readonly checkCollisions: boolean;
  76084. /** @hidden */
  76085. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  76086. /** @hidden */
  76087. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  76088. /**
  76089. * Disposes of the line mesh
  76090. * @param doNotRecurse If children should be disposed
  76091. */
  76092. dispose(doNotRecurse?: boolean): void;
  76093. /**
  76094. * Returns a new LineMesh object cloned from the current one.
  76095. */
  76096. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  76097. /**
  76098. * Creates a new InstancedLinesMesh object from the mesh model.
  76099. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76100. * @param name defines the name of the new instance
  76101. * @returns a new InstancedLinesMesh
  76102. */
  76103. createInstance(name: string): InstancedLinesMesh;
  76104. }
  76105. /**
  76106. * Creates an instance based on a source LinesMesh
  76107. */
  76108. export class InstancedLinesMesh extends InstancedMesh {
  76109. /**
  76110. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76111. * This margin is expressed in world space coordinates, so its value may vary.
  76112. * Initilized with the intersectionThreshold value of the source LinesMesh
  76113. */
  76114. intersectionThreshold: number;
  76115. constructor(name: string, source: LinesMesh);
  76116. /**
  76117. * Returns the string "InstancedLinesMesh".
  76118. */
  76119. getClassName(): string;
  76120. }
  76121. }
  76122. declare module BABYLON {
  76123. /** @hidden */
  76124. export var linePixelShader: {
  76125. name: string;
  76126. shader: string;
  76127. };
  76128. }
  76129. declare module BABYLON {
  76130. /** @hidden */
  76131. export var lineVertexShader: {
  76132. name: string;
  76133. shader: string;
  76134. };
  76135. }
  76136. declare module BABYLON {
  76137. interface AbstractMesh {
  76138. /**
  76139. * Disables the mesh edge rendering mode
  76140. * @returns the currentAbstractMesh
  76141. */
  76142. disableEdgesRendering(): AbstractMesh;
  76143. /**
  76144. * Enables the edge rendering mode on the mesh.
  76145. * This mode makes the mesh edges visible
  76146. * @param epsilon defines the maximal distance between two angles to detect a face
  76147. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76148. * @returns the currentAbstractMesh
  76149. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76150. */
  76151. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76152. /**
  76153. * Gets the edgesRenderer associated with the mesh
  76154. */
  76155. edgesRenderer: Nullable<EdgesRenderer>;
  76156. }
  76157. interface LinesMesh {
  76158. /**
  76159. * Enables the edge rendering mode on the mesh.
  76160. * This mode makes the mesh edges visible
  76161. * @param epsilon defines the maximal distance between two angles to detect a face
  76162. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76163. * @returns the currentAbstractMesh
  76164. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76165. */
  76166. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76167. }
  76168. interface InstancedLinesMesh {
  76169. /**
  76170. * Enables the edge rendering mode on the mesh.
  76171. * This mode makes the mesh edges visible
  76172. * @param epsilon defines the maximal distance between two angles to detect a face
  76173. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76174. * @returns the current InstancedLinesMesh
  76175. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76176. */
  76177. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  76178. }
  76179. /**
  76180. * Defines the minimum contract an Edges renderer should follow.
  76181. */
  76182. export interface IEdgesRenderer extends IDisposable {
  76183. /**
  76184. * Gets or sets a boolean indicating if the edgesRenderer is active
  76185. */
  76186. isEnabled: boolean;
  76187. /**
  76188. * Renders the edges of the attached mesh,
  76189. */
  76190. render(): void;
  76191. /**
  76192. * Checks wether or not the edges renderer is ready to render.
  76193. * @return true if ready, otherwise false.
  76194. */
  76195. isReady(): boolean;
  76196. }
  76197. /**
  76198. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  76199. */
  76200. export class EdgesRenderer implements IEdgesRenderer {
  76201. /**
  76202. * Define the size of the edges with an orthographic camera
  76203. */
  76204. edgesWidthScalerForOrthographic: number;
  76205. /**
  76206. * Define the size of the edges with a perspective camera
  76207. */
  76208. edgesWidthScalerForPerspective: number;
  76209. protected _source: AbstractMesh;
  76210. protected _linesPositions: number[];
  76211. protected _linesNormals: number[];
  76212. protected _linesIndices: number[];
  76213. protected _epsilon: number;
  76214. protected _indicesCount: number;
  76215. protected _lineShader: ShaderMaterial;
  76216. protected _ib: WebGLBuffer;
  76217. protected _buffers: {
  76218. [key: string]: Nullable<VertexBuffer>;
  76219. };
  76220. protected _checkVerticesInsteadOfIndices: boolean;
  76221. private _meshRebuildObserver;
  76222. private _meshDisposeObserver;
  76223. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  76224. isEnabled: boolean;
  76225. /**
  76226. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  76227. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  76228. * @param source Mesh used to create edges
  76229. * @param epsilon sum of angles in adjacency to check for edge
  76230. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  76231. * @param generateEdgesLines - should generate Lines or only prepare resources.
  76232. */
  76233. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  76234. protected _prepareRessources(): void;
  76235. /** @hidden */
  76236. _rebuild(): void;
  76237. /**
  76238. * Releases the required resources for the edges renderer
  76239. */
  76240. dispose(): void;
  76241. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  76242. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  76243. /**
  76244. * Checks if the pair of p0 and p1 is en edge
  76245. * @param faceIndex
  76246. * @param edge
  76247. * @param faceNormals
  76248. * @param p0
  76249. * @param p1
  76250. * @private
  76251. */
  76252. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  76253. /**
  76254. * push line into the position, normal and index buffer
  76255. * @protected
  76256. */
  76257. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  76258. /**
  76259. * Generates lines edges from adjacencjes
  76260. * @private
  76261. */
  76262. _generateEdgesLines(): void;
  76263. /**
  76264. * Checks wether or not the edges renderer is ready to render.
  76265. * @return true if ready, otherwise false.
  76266. */
  76267. isReady(): boolean;
  76268. /**
  76269. * Renders the edges of the attached mesh,
  76270. */
  76271. render(): void;
  76272. }
  76273. /**
  76274. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  76275. */
  76276. export class LineEdgesRenderer extends EdgesRenderer {
  76277. /**
  76278. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  76279. * @param source LineMesh used to generate edges
  76280. * @param epsilon not important (specified angle for edge detection)
  76281. * @param checkVerticesInsteadOfIndices not important for LineMesh
  76282. */
  76283. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  76284. /**
  76285. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  76286. */
  76287. _generateEdgesLines(): void;
  76288. }
  76289. }
  76290. declare module BABYLON {
  76291. /**
  76292. * This represents the object necessary to create a rendering group.
  76293. * This is exclusively used and created by the rendering manager.
  76294. * To modify the behavior, you use the available helpers in your scene or meshes.
  76295. * @hidden
  76296. */
  76297. export class RenderingGroup {
  76298. index: number;
  76299. private _scene;
  76300. private _opaqueSubMeshes;
  76301. private _transparentSubMeshes;
  76302. private _alphaTestSubMeshes;
  76303. private _depthOnlySubMeshes;
  76304. private _particleSystems;
  76305. private _spriteManagers;
  76306. private _opaqueSortCompareFn;
  76307. private _alphaTestSortCompareFn;
  76308. private _transparentSortCompareFn;
  76309. private _renderOpaque;
  76310. private _renderAlphaTest;
  76311. private _renderTransparent;
  76312. private _edgesRenderers;
  76313. onBeforeTransparentRendering: () => void;
  76314. /**
  76315. * Set the opaque sort comparison function.
  76316. * If null the sub meshes will be render in the order they were created
  76317. */
  76318. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76319. /**
  76320. * Set the alpha test sort comparison function.
  76321. * If null the sub meshes will be render in the order they were created
  76322. */
  76323. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76324. /**
  76325. * Set the transparent sort comparison function.
  76326. * If null the sub meshes will be render in the order they were created
  76327. */
  76328. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76329. /**
  76330. * Creates a new rendering group.
  76331. * @param index The rendering group index
  76332. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  76333. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  76334. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  76335. */
  76336. 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>);
  76337. /**
  76338. * Render all the sub meshes contained in the group.
  76339. * @param customRenderFunction Used to override the default render behaviour of the group.
  76340. * @returns true if rendered some submeshes.
  76341. */
  76342. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  76343. /**
  76344. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  76345. * @param subMeshes The submeshes to render
  76346. */
  76347. private renderOpaqueSorted;
  76348. /**
  76349. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  76350. * @param subMeshes The submeshes to render
  76351. */
  76352. private renderAlphaTestSorted;
  76353. /**
  76354. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  76355. * @param subMeshes The submeshes to render
  76356. */
  76357. private renderTransparentSorted;
  76358. /**
  76359. * Renders the submeshes in a specified order.
  76360. * @param subMeshes The submeshes to sort before render
  76361. * @param sortCompareFn The comparison function use to sort
  76362. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  76363. * @param transparent Specifies to activate blending if true
  76364. */
  76365. private static renderSorted;
  76366. /**
  76367. * Renders the submeshes in the order they were dispatched (no sort applied).
  76368. * @param subMeshes The submeshes to render
  76369. */
  76370. private static renderUnsorted;
  76371. /**
  76372. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76373. * are rendered back to front if in the same alpha index.
  76374. *
  76375. * @param a The first submesh
  76376. * @param b The second submesh
  76377. * @returns The result of the comparison
  76378. */
  76379. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  76380. /**
  76381. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76382. * are rendered back to front.
  76383. *
  76384. * @param a The first submesh
  76385. * @param b The second submesh
  76386. * @returns The result of the comparison
  76387. */
  76388. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  76389. /**
  76390. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76391. * are rendered front to back (prevent overdraw).
  76392. *
  76393. * @param a The first submesh
  76394. * @param b The second submesh
  76395. * @returns The result of the comparison
  76396. */
  76397. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  76398. /**
  76399. * Resets the different lists of submeshes to prepare a new frame.
  76400. */
  76401. prepare(): void;
  76402. dispose(): void;
  76403. /**
  76404. * Inserts the submesh in its correct queue depending on its material.
  76405. * @param subMesh The submesh to dispatch
  76406. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76407. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76408. */
  76409. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76410. dispatchSprites(spriteManager: ISpriteManager): void;
  76411. dispatchParticles(particleSystem: IParticleSystem): void;
  76412. private _renderParticles;
  76413. private _renderSprites;
  76414. }
  76415. }
  76416. declare module BABYLON {
  76417. /**
  76418. * Interface describing the different options available in the rendering manager
  76419. * regarding Auto Clear between groups.
  76420. */
  76421. export interface IRenderingManagerAutoClearSetup {
  76422. /**
  76423. * Defines whether or not autoclear is enable.
  76424. */
  76425. autoClear: boolean;
  76426. /**
  76427. * Defines whether or not to autoclear the depth buffer.
  76428. */
  76429. depth: boolean;
  76430. /**
  76431. * Defines whether or not to autoclear the stencil buffer.
  76432. */
  76433. stencil: boolean;
  76434. }
  76435. /**
  76436. * This class is used by the onRenderingGroupObservable
  76437. */
  76438. export class RenderingGroupInfo {
  76439. /**
  76440. * The Scene that being rendered
  76441. */
  76442. scene: Scene;
  76443. /**
  76444. * The camera currently used for the rendering pass
  76445. */
  76446. camera: Nullable<Camera>;
  76447. /**
  76448. * The ID of the renderingGroup being processed
  76449. */
  76450. renderingGroupId: number;
  76451. }
  76452. /**
  76453. * This is the manager responsible of all the rendering for meshes sprites and particles.
  76454. * It is enable to manage the different groups as well as the different necessary sort functions.
  76455. * This should not be used directly aside of the few static configurations
  76456. */
  76457. export class RenderingManager {
  76458. /**
  76459. * The max id used for rendering groups (not included)
  76460. */
  76461. static MAX_RENDERINGGROUPS: number;
  76462. /**
  76463. * The min id used for rendering groups (included)
  76464. */
  76465. static MIN_RENDERINGGROUPS: number;
  76466. /**
  76467. * Used to globally prevent autoclearing scenes.
  76468. */
  76469. static AUTOCLEAR: boolean;
  76470. /**
  76471. * @hidden
  76472. */
  76473. _useSceneAutoClearSetup: boolean;
  76474. private _scene;
  76475. private _renderingGroups;
  76476. private _depthStencilBufferAlreadyCleaned;
  76477. private _autoClearDepthStencil;
  76478. private _customOpaqueSortCompareFn;
  76479. private _customAlphaTestSortCompareFn;
  76480. private _customTransparentSortCompareFn;
  76481. private _renderingGroupInfo;
  76482. /**
  76483. * Instantiates a new rendering group for a particular scene
  76484. * @param scene Defines the scene the groups belongs to
  76485. */
  76486. constructor(scene: Scene);
  76487. private _clearDepthStencilBuffer;
  76488. /**
  76489. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  76490. * @hidden
  76491. */
  76492. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  76493. /**
  76494. * Resets the different information of the group to prepare a new frame
  76495. * @hidden
  76496. */
  76497. reset(): void;
  76498. /**
  76499. * Dispose and release the group and its associated resources.
  76500. * @hidden
  76501. */
  76502. dispose(): void;
  76503. /**
  76504. * Clear the info related to rendering groups preventing retention points during dispose.
  76505. */
  76506. freeRenderingGroups(): void;
  76507. private _prepareRenderingGroup;
  76508. /**
  76509. * Add a sprite manager to the rendering manager in order to render it this frame.
  76510. * @param spriteManager Define the sprite manager to render
  76511. */
  76512. dispatchSprites(spriteManager: ISpriteManager): void;
  76513. /**
  76514. * Add a particle system to the rendering manager in order to render it this frame.
  76515. * @param particleSystem Define the particle system to render
  76516. */
  76517. dispatchParticles(particleSystem: IParticleSystem): void;
  76518. /**
  76519. * Add a submesh to the manager in order to render it this frame
  76520. * @param subMesh The submesh to dispatch
  76521. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76522. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76523. */
  76524. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76525. /**
  76526. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76527. * This allowed control for front to back rendering or reversly depending of the special needs.
  76528. *
  76529. * @param renderingGroupId The rendering group id corresponding to its index
  76530. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76531. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76532. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76533. */
  76534. 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;
  76535. /**
  76536. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76537. *
  76538. * @param renderingGroupId The rendering group id corresponding to its index
  76539. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76540. * @param depth Automatically clears depth between groups if true and autoClear is true.
  76541. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  76542. */
  76543. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  76544. /**
  76545. * Gets the current auto clear configuration for one rendering group of the rendering
  76546. * manager.
  76547. * @param index the rendering group index to get the information for
  76548. * @returns The auto clear setup for the requested rendering group
  76549. */
  76550. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  76551. }
  76552. }
  76553. declare module BABYLON {
  76554. /**
  76555. * This Helps creating a texture that will be created from a camera in your scene.
  76556. * It is basically a dynamic texture that could be used to create special effects for instance.
  76557. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  76558. */
  76559. export class RenderTargetTexture extends Texture {
  76560. isCube: boolean;
  76561. /**
  76562. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  76563. */
  76564. static readonly REFRESHRATE_RENDER_ONCE: number;
  76565. /**
  76566. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  76567. */
  76568. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  76569. /**
  76570. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  76571. * the central point of your effect and can save a lot of performances.
  76572. */
  76573. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  76574. /**
  76575. * Use this predicate to dynamically define the list of mesh you want to render.
  76576. * If set, the renderList property will be overwritten.
  76577. */
  76578. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  76579. private _renderList;
  76580. /**
  76581. * Use this list to define the list of mesh you want to render.
  76582. */
  76583. renderList: Nullable<Array<AbstractMesh>>;
  76584. private _hookArray;
  76585. /**
  76586. * Define if particles should be rendered in your texture.
  76587. */
  76588. renderParticles: boolean;
  76589. /**
  76590. * Define if sprites should be rendered in your texture.
  76591. */
  76592. renderSprites: boolean;
  76593. /**
  76594. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  76595. */
  76596. coordinatesMode: number;
  76597. /**
  76598. * Define the camera used to render the texture.
  76599. */
  76600. activeCamera: Nullable<Camera>;
  76601. /**
  76602. * Override the render function of the texture with your own one.
  76603. */
  76604. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  76605. /**
  76606. * Define if camera post processes should be use while rendering the texture.
  76607. */
  76608. useCameraPostProcesses: boolean;
  76609. /**
  76610. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  76611. */
  76612. ignoreCameraViewport: boolean;
  76613. private _postProcessManager;
  76614. private _postProcesses;
  76615. private _resizeObserver;
  76616. /**
  76617. * An event triggered when the texture is unbind.
  76618. */
  76619. onBeforeBindObservable: Observable<RenderTargetTexture>;
  76620. /**
  76621. * An event triggered when the texture is unbind.
  76622. */
  76623. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  76624. private _onAfterUnbindObserver;
  76625. /**
  76626. * Set a after unbind callback in the texture.
  76627. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  76628. */
  76629. onAfterUnbind: () => void;
  76630. /**
  76631. * An event triggered before rendering the texture
  76632. */
  76633. onBeforeRenderObservable: Observable<number>;
  76634. private _onBeforeRenderObserver;
  76635. /**
  76636. * Set a before render callback in the texture.
  76637. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  76638. */
  76639. onBeforeRender: (faceIndex: number) => void;
  76640. /**
  76641. * An event triggered after rendering the texture
  76642. */
  76643. onAfterRenderObservable: Observable<number>;
  76644. private _onAfterRenderObserver;
  76645. /**
  76646. * Set a after render callback in the texture.
  76647. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  76648. */
  76649. onAfterRender: (faceIndex: number) => void;
  76650. /**
  76651. * An event triggered after the texture clear
  76652. */
  76653. onClearObservable: Observable<Engine>;
  76654. private _onClearObserver;
  76655. /**
  76656. * Set a clear callback in the texture.
  76657. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  76658. */
  76659. onClear: (Engine: Engine) => void;
  76660. /**
  76661. * Define the clear color of the Render Target if it should be different from the scene.
  76662. */
  76663. clearColor: Color4;
  76664. protected _size: number | {
  76665. width: number;
  76666. height: number;
  76667. };
  76668. protected _initialSizeParameter: number | {
  76669. width: number;
  76670. height: number;
  76671. } | {
  76672. ratio: number;
  76673. };
  76674. protected _sizeRatio: Nullable<number>;
  76675. /** @hidden */
  76676. _generateMipMaps: boolean;
  76677. protected _renderingManager: RenderingManager;
  76678. /** @hidden */
  76679. _waitingRenderList: string[];
  76680. protected _doNotChangeAspectRatio: boolean;
  76681. protected _currentRefreshId: number;
  76682. protected _refreshRate: number;
  76683. protected _textureMatrix: Matrix;
  76684. protected _samples: number;
  76685. protected _renderTargetOptions: RenderTargetCreationOptions;
  76686. /**
  76687. * Gets render target creation options that were used.
  76688. */
  76689. readonly renderTargetOptions: RenderTargetCreationOptions;
  76690. protected _engine: Engine;
  76691. protected _onRatioRescale(): void;
  76692. /**
  76693. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  76694. * It must define where the camera used to render the texture is set
  76695. */
  76696. boundingBoxPosition: Vector3;
  76697. private _boundingBoxSize;
  76698. /**
  76699. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  76700. * When defined, the cubemap will switch to local mode
  76701. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76702. * @example https://www.babylonjs-playground.com/#RNASML
  76703. */
  76704. boundingBoxSize: Vector3;
  76705. /**
  76706. * In case the RTT has been created with a depth texture, get the associated
  76707. * depth texture.
  76708. * Otherwise, return null.
  76709. */
  76710. depthStencilTexture: Nullable<InternalTexture>;
  76711. /**
  76712. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  76713. * or used a shadow, depth texture...
  76714. * @param name The friendly name of the texture
  76715. * @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)
  76716. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  76717. * @param generateMipMaps True if mip maps need to be generated after render.
  76718. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  76719. * @param type The type of the buffer in the RTT (int, half float, float...)
  76720. * @param isCube True if a cube texture needs to be created
  76721. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  76722. * @param generateDepthBuffer True to generate a depth buffer
  76723. * @param generateStencilBuffer True to generate a stencil buffer
  76724. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  76725. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  76726. * @param delayAllocation if the texture allocation should be delayed (default: false)
  76727. */
  76728. constructor(name: string, size: number | {
  76729. width: number;
  76730. height: number;
  76731. } | {
  76732. ratio: number;
  76733. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  76734. /**
  76735. * Creates a depth stencil texture.
  76736. * This is only available in WebGL 2 or with the depth texture extension available.
  76737. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  76738. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  76739. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  76740. */
  76741. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  76742. private _processSizeParameter;
  76743. /**
  76744. * Define the number of samples to use in case of MSAA.
  76745. * It defaults to one meaning no MSAA has been enabled.
  76746. */
  76747. samples: number;
  76748. /**
  76749. * Resets the refresh counter of the texture and start bak from scratch.
  76750. * Could be useful to regenerate the texture if it is setup to render only once.
  76751. */
  76752. resetRefreshCounter(): void;
  76753. /**
  76754. * Define the refresh rate of the texture or the rendering frequency.
  76755. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  76756. */
  76757. refreshRate: number;
  76758. /**
  76759. * Adds a post process to the render target rendering passes.
  76760. * @param postProcess define the post process to add
  76761. */
  76762. addPostProcess(postProcess: PostProcess): void;
  76763. /**
  76764. * Clear all the post processes attached to the render target
  76765. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  76766. */
  76767. clearPostProcesses(dispose?: boolean): void;
  76768. /**
  76769. * Remove one of the post process from the list of attached post processes to the texture
  76770. * @param postProcess define the post process to remove from the list
  76771. */
  76772. removePostProcess(postProcess: PostProcess): void;
  76773. /** @hidden */
  76774. _shouldRender(): boolean;
  76775. /**
  76776. * Gets the actual render size of the texture.
  76777. * @returns the width of the render size
  76778. */
  76779. getRenderSize(): number;
  76780. /**
  76781. * Gets the actual render width of the texture.
  76782. * @returns the width of the render size
  76783. */
  76784. getRenderWidth(): number;
  76785. /**
  76786. * Gets the actual render height of the texture.
  76787. * @returns the height of the render size
  76788. */
  76789. getRenderHeight(): number;
  76790. /**
  76791. * Get if the texture can be rescaled or not.
  76792. */
  76793. readonly canRescale: boolean;
  76794. /**
  76795. * Resize the texture using a ratio.
  76796. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  76797. */
  76798. scale(ratio: number): void;
  76799. /**
  76800. * Get the texture reflection matrix used to rotate/transform the reflection.
  76801. * @returns the reflection matrix
  76802. */
  76803. getReflectionTextureMatrix(): Matrix;
  76804. /**
  76805. * Resize the texture to a new desired size.
  76806. * Be carrefull as it will recreate all the data in the new texture.
  76807. * @param size Define the new size. It can be:
  76808. * - a number for squared texture,
  76809. * - an object containing { width: number, height: number }
  76810. * - or an object containing a ratio { ratio: number }
  76811. */
  76812. resize(size: number | {
  76813. width: number;
  76814. height: number;
  76815. } | {
  76816. ratio: number;
  76817. }): void;
  76818. /**
  76819. * Renders all the objects from the render list into the texture.
  76820. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  76821. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  76822. */
  76823. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  76824. private _bestReflectionRenderTargetDimension;
  76825. /**
  76826. * @hidden
  76827. * @param faceIndex face index to bind to if this is a cubetexture
  76828. */
  76829. _bindFrameBuffer(faceIndex?: number): void;
  76830. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  76831. private renderToTarget;
  76832. /**
  76833. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76834. * This allowed control for front to back rendering or reversly depending of the special needs.
  76835. *
  76836. * @param renderingGroupId The rendering group id corresponding to its index
  76837. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76838. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76839. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76840. */
  76841. 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;
  76842. /**
  76843. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76844. *
  76845. * @param renderingGroupId The rendering group id corresponding to its index
  76846. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76847. */
  76848. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  76849. /**
  76850. * Clones the texture.
  76851. * @returns the cloned texture
  76852. */
  76853. clone(): RenderTargetTexture;
  76854. /**
  76855. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76856. * @returns The JSON representation of the texture
  76857. */
  76858. serialize(): any;
  76859. /**
  76860. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  76861. */
  76862. disposeFramebufferObjects(): void;
  76863. /**
  76864. * Dispose the texture and release its associated resources.
  76865. */
  76866. dispose(): void;
  76867. /** @hidden */
  76868. _rebuild(): void;
  76869. /**
  76870. * Clear the info related to rendering groups preventing retention point in material dispose.
  76871. */
  76872. freeRenderingGroups(): void;
  76873. /**
  76874. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  76875. * @returns the view count
  76876. */
  76877. getViewCount(): number;
  76878. }
  76879. }
  76880. declare module BABYLON {
  76881. /**
  76882. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76883. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76884. * You can then easily use it as a reflectionTexture on a flat surface.
  76885. * In case the surface is not a plane, please consider relying on reflection probes.
  76886. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76887. */
  76888. export class MirrorTexture extends RenderTargetTexture {
  76889. private scene;
  76890. /**
  76891. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  76892. * 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.
  76893. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76894. */
  76895. mirrorPlane: Plane;
  76896. /**
  76897. * Define the blur ratio used to blur the reflection if needed.
  76898. */
  76899. blurRatio: number;
  76900. /**
  76901. * Define the adaptive blur kernel used to blur the reflection if needed.
  76902. * This will autocompute the closest best match for the `blurKernel`
  76903. */
  76904. adaptiveBlurKernel: number;
  76905. /**
  76906. * Define the blur kernel used to blur the reflection if needed.
  76907. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76908. */
  76909. blurKernel: number;
  76910. /**
  76911. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  76912. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76913. */
  76914. blurKernelX: number;
  76915. /**
  76916. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  76917. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76918. */
  76919. blurKernelY: number;
  76920. private _autoComputeBlurKernel;
  76921. protected _onRatioRescale(): void;
  76922. private _updateGammaSpace;
  76923. private _imageProcessingConfigChangeObserver;
  76924. private _transformMatrix;
  76925. private _mirrorMatrix;
  76926. private _savedViewMatrix;
  76927. private _blurX;
  76928. private _blurY;
  76929. private _adaptiveBlurKernel;
  76930. private _blurKernelX;
  76931. private _blurKernelY;
  76932. private _blurRatio;
  76933. /**
  76934. * Instantiates a Mirror Texture.
  76935. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76936. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76937. * You can then easily use it as a reflectionTexture on a flat surface.
  76938. * In case the surface is not a plane, please consider relying on reflection probes.
  76939. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76940. * @param name
  76941. * @param size
  76942. * @param scene
  76943. * @param generateMipMaps
  76944. * @param type
  76945. * @param samplingMode
  76946. * @param generateDepthBuffer
  76947. */
  76948. constructor(name: string, size: number | {
  76949. width: number;
  76950. height: number;
  76951. } | {
  76952. ratio: number;
  76953. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  76954. private _preparePostProcesses;
  76955. /**
  76956. * Clone the mirror texture.
  76957. * @returns the cloned texture
  76958. */
  76959. clone(): MirrorTexture;
  76960. /**
  76961. * Serialize the texture to a JSON representation you could use in Parse later on
  76962. * @returns the serialized JSON representation
  76963. */
  76964. serialize(): any;
  76965. /**
  76966. * Dispose the texture and release its associated resources.
  76967. */
  76968. dispose(): void;
  76969. }
  76970. }
  76971. declare module BABYLON {
  76972. /**
  76973. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76974. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76975. */
  76976. export class Texture extends BaseTexture {
  76977. /** @hidden */
  76978. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  76979. /** @hidden */
  76980. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  76981. /** @hidden */
  76982. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  76983. /** nearest is mag = nearest and min = nearest and mip = linear */
  76984. static readonly NEAREST_SAMPLINGMODE: number;
  76985. /** nearest is mag = nearest and min = nearest and mip = linear */
  76986. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  76987. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76988. static readonly BILINEAR_SAMPLINGMODE: number;
  76989. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76990. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  76991. /** Trilinear is mag = linear and min = linear and mip = linear */
  76992. static readonly TRILINEAR_SAMPLINGMODE: number;
  76993. /** Trilinear is mag = linear and min = linear and mip = linear */
  76994. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  76995. /** mag = nearest and min = nearest and mip = nearest */
  76996. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  76997. /** mag = nearest and min = linear and mip = nearest */
  76998. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  76999. /** mag = nearest and min = linear and mip = linear */
  77000. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  77001. /** mag = nearest and min = linear and mip = none */
  77002. static readonly NEAREST_LINEAR: number;
  77003. /** mag = nearest and min = nearest and mip = none */
  77004. static readonly NEAREST_NEAREST: number;
  77005. /** mag = linear and min = nearest and mip = nearest */
  77006. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  77007. /** mag = linear and min = nearest and mip = linear */
  77008. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  77009. /** mag = linear and min = linear and mip = none */
  77010. static readonly LINEAR_LINEAR: number;
  77011. /** mag = linear and min = nearest and mip = none */
  77012. static readonly LINEAR_NEAREST: number;
  77013. /** Explicit coordinates mode */
  77014. static readonly EXPLICIT_MODE: number;
  77015. /** Spherical coordinates mode */
  77016. static readonly SPHERICAL_MODE: number;
  77017. /** Planar coordinates mode */
  77018. static readonly PLANAR_MODE: number;
  77019. /** Cubic coordinates mode */
  77020. static readonly CUBIC_MODE: number;
  77021. /** Projection coordinates mode */
  77022. static readonly PROJECTION_MODE: number;
  77023. /** Inverse Cubic coordinates mode */
  77024. static readonly SKYBOX_MODE: number;
  77025. /** Inverse Cubic coordinates mode */
  77026. static readonly INVCUBIC_MODE: number;
  77027. /** Equirectangular coordinates mode */
  77028. static readonly EQUIRECTANGULAR_MODE: number;
  77029. /** Equirectangular Fixed coordinates mode */
  77030. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  77031. /** Equirectangular Fixed Mirrored coordinates mode */
  77032. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77033. /** Texture is not repeating outside of 0..1 UVs */
  77034. static readonly CLAMP_ADDRESSMODE: number;
  77035. /** Texture is repeating outside of 0..1 UVs */
  77036. static readonly WRAP_ADDRESSMODE: number;
  77037. /** Texture is repeating and mirrored */
  77038. static readonly MIRROR_ADDRESSMODE: number;
  77039. /**
  77040. * 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
  77041. */
  77042. static UseSerializedUrlIfAny: boolean;
  77043. /**
  77044. * Define the url of the texture.
  77045. */
  77046. url: Nullable<string>;
  77047. /**
  77048. * Define an offset on the texture to offset the u coordinates of the UVs
  77049. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77050. */
  77051. uOffset: number;
  77052. /**
  77053. * Define an offset on the texture to offset the v coordinates of the UVs
  77054. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77055. */
  77056. vOffset: number;
  77057. /**
  77058. * Define an offset on the texture to scale the u coordinates of the UVs
  77059. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77060. */
  77061. uScale: number;
  77062. /**
  77063. * Define an offset on the texture to scale the v coordinates of the UVs
  77064. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77065. */
  77066. vScale: number;
  77067. /**
  77068. * Define an offset on the texture to rotate around the u coordinates of the UVs
  77069. * @see http://doc.babylonjs.com/how_to/more_materials
  77070. */
  77071. uAng: number;
  77072. /**
  77073. * Define an offset on the texture to rotate around the v coordinates of the UVs
  77074. * @see http://doc.babylonjs.com/how_to/more_materials
  77075. */
  77076. vAng: number;
  77077. /**
  77078. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  77079. * @see http://doc.babylonjs.com/how_to/more_materials
  77080. */
  77081. wAng: number;
  77082. /**
  77083. * Defines the center of rotation (U)
  77084. */
  77085. uRotationCenter: number;
  77086. /**
  77087. * Defines the center of rotation (V)
  77088. */
  77089. vRotationCenter: number;
  77090. /**
  77091. * Defines the center of rotation (W)
  77092. */
  77093. wRotationCenter: number;
  77094. /**
  77095. * Are mip maps generated for this texture or not.
  77096. */
  77097. readonly noMipmap: boolean;
  77098. /**
  77099. * List of inspectable custom properties (used by the Inspector)
  77100. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77101. */
  77102. inspectableCustomProperties: IInspectable[];
  77103. private _noMipmap;
  77104. /** @hidden */
  77105. _invertY: boolean;
  77106. private _rowGenerationMatrix;
  77107. private _cachedTextureMatrix;
  77108. private _projectionModeMatrix;
  77109. private _t0;
  77110. private _t1;
  77111. private _t2;
  77112. private _cachedUOffset;
  77113. private _cachedVOffset;
  77114. private _cachedUScale;
  77115. private _cachedVScale;
  77116. private _cachedUAng;
  77117. private _cachedVAng;
  77118. private _cachedWAng;
  77119. private _cachedProjectionMatrixId;
  77120. private _cachedCoordinatesMode;
  77121. /** @hidden */
  77122. protected _initialSamplingMode: number;
  77123. /** @hidden */
  77124. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  77125. private _deleteBuffer;
  77126. protected _format: Nullable<number>;
  77127. private _delayedOnLoad;
  77128. private _delayedOnError;
  77129. /**
  77130. * Observable triggered once the texture has been loaded.
  77131. */
  77132. onLoadObservable: Observable<Texture>;
  77133. protected _isBlocking: boolean;
  77134. /**
  77135. * Is the texture preventing material to render while loading.
  77136. * If false, a default texture will be used instead of the loading one during the preparation step.
  77137. */
  77138. isBlocking: boolean;
  77139. /**
  77140. * Get the current sampling mode associated with the texture.
  77141. */
  77142. readonly samplingMode: number;
  77143. /**
  77144. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  77145. */
  77146. readonly invertY: boolean;
  77147. /**
  77148. * Instantiates a new texture.
  77149. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77150. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77151. * @param url define the url of the picture to load as a texture
  77152. * @param scene define the scene the texture will belong to
  77153. * @param noMipmap define if the texture will require mip maps or not
  77154. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77155. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77156. * @param onLoad define a callback triggered when the texture has been loaded
  77157. * @param onError define a callback triggered when an error occurred during the loading session
  77158. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77159. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77160. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77161. */
  77162. 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);
  77163. /**
  77164. * Update the url (and optional buffer) of this texture if url was null during construction.
  77165. * @param url the url of the texture
  77166. * @param buffer the buffer of the texture (defaults to null)
  77167. * @param onLoad callback called when the texture is loaded (defaults to null)
  77168. */
  77169. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  77170. /**
  77171. * Finish the loading sequence of a texture flagged as delayed load.
  77172. * @hidden
  77173. */
  77174. delayLoad(): void;
  77175. private _prepareRowForTextureGeneration;
  77176. /**
  77177. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  77178. * @returns the transform matrix of the texture.
  77179. */
  77180. getTextureMatrix(): Matrix;
  77181. /**
  77182. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  77183. * @returns The reflection texture transform
  77184. */
  77185. getReflectionTextureMatrix(): Matrix;
  77186. /**
  77187. * Clones the texture.
  77188. * @returns the cloned texture
  77189. */
  77190. clone(): Texture;
  77191. /**
  77192. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77193. * @returns The JSON representation of the texture
  77194. */
  77195. serialize(): any;
  77196. /**
  77197. * Get the current class name of the texture useful for serialization or dynamic coding.
  77198. * @returns "Texture"
  77199. */
  77200. getClassName(): string;
  77201. /**
  77202. * Dispose the texture and release its associated resources.
  77203. */
  77204. dispose(): void;
  77205. /**
  77206. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  77207. * @param parsedTexture Define the JSON representation of the texture
  77208. * @param scene Define the scene the parsed texture should be instantiated in
  77209. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  77210. * @returns The parsed texture if successful
  77211. */
  77212. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  77213. /**
  77214. * Creates a texture from its base 64 representation.
  77215. * @param data Define the base64 payload without the data: prefix
  77216. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77217. * @param scene Define the scene the texture should belong to
  77218. * @param noMipmap Forces the texture to not create mip map information if true
  77219. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77220. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77221. * @param onLoad define a callback triggered when the texture has been loaded
  77222. * @param onError define a callback triggered when an error occurred during the loading session
  77223. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77224. * @returns the created texture
  77225. */
  77226. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  77227. /**
  77228. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  77229. * @param data Define the base64 payload without the data: prefix
  77230. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77231. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77232. * @param scene Define the scene the texture should belong to
  77233. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77234. * @param noMipmap Forces the texture to not create mip map information if true
  77235. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77236. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77237. * @param onLoad define a callback triggered when the texture has been loaded
  77238. * @param onError define a callback triggered when an error occurred during the loading session
  77239. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77240. * @returns the created texture
  77241. */
  77242. 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;
  77243. }
  77244. }
  77245. declare module BABYLON {
  77246. /**
  77247. * Raw texture can help creating a texture directly from an array of data.
  77248. * This can be super useful if you either get the data from an uncompressed source or
  77249. * if you wish to create your texture pixel by pixel.
  77250. */
  77251. export class RawTexture extends Texture {
  77252. /**
  77253. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77254. */
  77255. format: number;
  77256. private _engine;
  77257. /**
  77258. * Instantiates a new RawTexture.
  77259. * Raw texture can help creating a texture directly from an array of data.
  77260. * This can be super useful if you either get the data from an uncompressed source or
  77261. * if you wish to create your texture pixel by pixel.
  77262. * @param data define the array of data to use to create the texture
  77263. * @param width define the width of the texture
  77264. * @param height define the height of the texture
  77265. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77266. * @param scene define the scene the texture belongs to
  77267. * @param generateMipMaps define whether mip maps should be generated or not
  77268. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77269. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77270. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77271. */
  77272. constructor(data: ArrayBufferView, width: number, height: number,
  77273. /**
  77274. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77275. */
  77276. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77277. /**
  77278. * Updates the texture underlying data.
  77279. * @param data Define the new data of the texture
  77280. */
  77281. update(data: ArrayBufferView): void;
  77282. /**
  77283. * Creates a luminance texture from some data.
  77284. * @param data Define the texture data
  77285. * @param width Define the width of the texture
  77286. * @param height Define the height of the texture
  77287. * @param scene Define the scene the texture belongs to
  77288. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77289. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77290. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77291. * @returns the luminance texture
  77292. */
  77293. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77294. /**
  77295. * Creates a luminance alpha texture from some data.
  77296. * @param data Define the texture data
  77297. * @param width Define the width of the texture
  77298. * @param height Define the height of the texture
  77299. * @param scene Define the scene the texture belongs to
  77300. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77301. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77302. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77303. * @returns the luminance alpha texture
  77304. */
  77305. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77306. /**
  77307. * Creates an alpha texture from some data.
  77308. * @param data Define the texture data
  77309. * @param width Define the width of the texture
  77310. * @param height Define the height of the texture
  77311. * @param scene Define the scene the texture belongs to
  77312. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77313. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77314. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77315. * @returns the alpha texture
  77316. */
  77317. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77318. /**
  77319. * Creates a RGB texture from some data.
  77320. * @param data Define the texture data
  77321. * @param width Define the width of the texture
  77322. * @param height Define the height of the texture
  77323. * @param scene Define the scene the texture belongs to
  77324. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77325. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77326. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77327. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77328. * @returns the RGB alpha texture
  77329. */
  77330. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77331. /**
  77332. * Creates a RGBA texture from some data.
  77333. * @param data Define the texture data
  77334. * @param width Define the width of the texture
  77335. * @param height Define the height of the texture
  77336. * @param scene Define the scene the texture belongs to
  77337. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77338. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77339. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77340. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77341. * @returns the RGBA texture
  77342. */
  77343. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77344. /**
  77345. * Creates a R texture from some data.
  77346. * @param data Define the texture data
  77347. * @param width Define the width of the texture
  77348. * @param height Define the height of the texture
  77349. * @param scene Define the scene the texture belongs to
  77350. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77351. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77352. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77353. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77354. * @returns the R texture
  77355. */
  77356. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77357. }
  77358. }
  77359. declare module BABYLON {
  77360. /**
  77361. * Defines a runtime animation
  77362. */
  77363. export class RuntimeAnimation {
  77364. private _events;
  77365. /**
  77366. * The current frame of the runtime animation
  77367. */
  77368. private _currentFrame;
  77369. /**
  77370. * The animation used by the runtime animation
  77371. */
  77372. private _animation;
  77373. /**
  77374. * The target of the runtime animation
  77375. */
  77376. private _target;
  77377. /**
  77378. * The initiating animatable
  77379. */
  77380. private _host;
  77381. /**
  77382. * The original value of the runtime animation
  77383. */
  77384. private _originalValue;
  77385. /**
  77386. * The original blend value of the runtime animation
  77387. */
  77388. private _originalBlendValue;
  77389. /**
  77390. * The offsets cache of the runtime animation
  77391. */
  77392. private _offsetsCache;
  77393. /**
  77394. * The high limits cache of the runtime animation
  77395. */
  77396. private _highLimitsCache;
  77397. /**
  77398. * Specifies if the runtime animation has been stopped
  77399. */
  77400. private _stopped;
  77401. /**
  77402. * The blending factor of the runtime animation
  77403. */
  77404. private _blendingFactor;
  77405. /**
  77406. * The BabylonJS scene
  77407. */
  77408. private _scene;
  77409. /**
  77410. * The current value of the runtime animation
  77411. */
  77412. private _currentValue;
  77413. /** @hidden */
  77414. _workValue: any;
  77415. /**
  77416. * The active target of the runtime animation
  77417. */
  77418. private _activeTarget;
  77419. /**
  77420. * The target path of the runtime animation
  77421. */
  77422. private _targetPath;
  77423. /**
  77424. * The weight of the runtime animation
  77425. */
  77426. private _weight;
  77427. /**
  77428. * The ratio offset of the runtime animation
  77429. */
  77430. private _ratioOffset;
  77431. /**
  77432. * The previous delay of the runtime animation
  77433. */
  77434. private _previousDelay;
  77435. /**
  77436. * The previous ratio of the runtime animation
  77437. */
  77438. private _previousRatio;
  77439. /**
  77440. * Gets the current frame of the runtime animation
  77441. */
  77442. readonly currentFrame: number;
  77443. /**
  77444. * Gets the weight of the runtime animation
  77445. */
  77446. readonly weight: number;
  77447. /**
  77448. * Gets the current value of the runtime animation
  77449. */
  77450. readonly currentValue: any;
  77451. /**
  77452. * Gets the target path of the runtime animation
  77453. */
  77454. readonly targetPath: string;
  77455. /**
  77456. * Gets the actual target of the runtime animation
  77457. */
  77458. readonly target: any;
  77459. /**
  77460. * Create a new RuntimeAnimation object
  77461. * @param target defines the target of the animation
  77462. * @param animation defines the source animation object
  77463. * @param scene defines the hosting scene
  77464. * @param host defines the initiating Animatable
  77465. */
  77466. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77467. /**
  77468. * Gets the animation from the runtime animation
  77469. */
  77470. readonly animation: Animation;
  77471. /**
  77472. * Resets the runtime animation to the beginning
  77473. * @param restoreOriginal defines whether to restore the target property to the original value
  77474. */
  77475. reset(restoreOriginal?: boolean): void;
  77476. /**
  77477. * Specifies if the runtime animation is stopped
  77478. * @returns Boolean specifying if the runtime animation is stopped
  77479. */
  77480. isStopped(): boolean;
  77481. /**
  77482. * Disposes of the runtime animation
  77483. */
  77484. dispose(): void;
  77485. /**
  77486. * Interpolates the animation from the current frame
  77487. * @param currentFrame The frame to interpolate the animation to
  77488. * @param repeatCount The number of times that the animation should loop
  77489. * @param loopMode The type of looping mode to use
  77490. * @param offsetValue Animation offset value
  77491. * @param highLimitValue The high limit value
  77492. * @returns The interpolated value
  77493. */
  77494. private _interpolate;
  77495. /**
  77496. * Apply the interpolated value to the target
  77497. * @param currentValue defines the value computed by the animation
  77498. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77499. */
  77500. setValue(currentValue: any, weight?: number): void;
  77501. private _setValue;
  77502. /**
  77503. * Gets the loop pmode of the runtime animation
  77504. * @returns Loop Mode
  77505. */
  77506. private _getCorrectLoopMode;
  77507. /**
  77508. * Move the current animation to a given frame
  77509. * @param frame defines the frame to move to
  77510. */
  77511. goToFrame(frame: number): void;
  77512. /**
  77513. * @hidden Internal use only
  77514. */
  77515. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77516. /**
  77517. * Execute the current animation
  77518. * @param delay defines the delay to add to the current frame
  77519. * @param from defines the lower bound of the animation range
  77520. * @param to defines the upper bound of the animation range
  77521. * @param loop defines if the current animation must loop
  77522. * @param speedRatio defines the current speed ratio
  77523. * @param weight defines the weight of the animation (default is -1 so no weight)
  77524. * @param onLoop optional callback called when animation loops
  77525. * @returns a boolean indicating if the animation is running
  77526. */
  77527. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  77528. }
  77529. }
  77530. declare module BABYLON {
  77531. /**
  77532. * Class used to store an actual running animation
  77533. */
  77534. export class Animatable {
  77535. /** defines the target object */
  77536. target: any;
  77537. /** defines the starting frame number (default is 0) */
  77538. fromFrame: number;
  77539. /** defines the ending frame number (default is 100) */
  77540. toFrame: number;
  77541. /** defines if the animation must loop (default is false) */
  77542. loopAnimation: boolean;
  77543. /** defines a callback to call when animation ends if it is not looping */
  77544. onAnimationEnd?: (() => void) | null | undefined;
  77545. /** defines a callback to call when animation loops */
  77546. onAnimationLoop?: (() => void) | null | undefined;
  77547. private _localDelayOffset;
  77548. private _pausedDelay;
  77549. private _runtimeAnimations;
  77550. private _paused;
  77551. private _scene;
  77552. private _speedRatio;
  77553. private _weight;
  77554. private _syncRoot;
  77555. /**
  77556. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77557. * This will only apply for non looping animation (default is true)
  77558. */
  77559. disposeOnEnd: boolean;
  77560. /**
  77561. * Gets a boolean indicating if the animation has started
  77562. */
  77563. animationStarted: boolean;
  77564. /**
  77565. * Observer raised when the animation ends
  77566. */
  77567. onAnimationEndObservable: Observable<Animatable>;
  77568. /**
  77569. * Observer raised when the animation loops
  77570. */
  77571. onAnimationLoopObservable: Observable<Animatable>;
  77572. /**
  77573. * Gets the root Animatable used to synchronize and normalize animations
  77574. */
  77575. readonly syncRoot: Animatable;
  77576. /**
  77577. * Gets the current frame of the first RuntimeAnimation
  77578. * Used to synchronize Animatables
  77579. */
  77580. readonly masterFrame: number;
  77581. /**
  77582. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77583. */
  77584. weight: number;
  77585. /**
  77586. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77587. */
  77588. speedRatio: number;
  77589. /**
  77590. * Creates a new Animatable
  77591. * @param scene defines the hosting scene
  77592. * @param target defines the target object
  77593. * @param fromFrame defines the starting frame number (default is 0)
  77594. * @param toFrame defines the ending frame number (default is 100)
  77595. * @param loopAnimation defines if the animation must loop (default is false)
  77596. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77597. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77598. * @param animations defines a group of animation to add to the new Animatable
  77599. * @param onAnimationLoop defines a callback to call when animation loops
  77600. */
  77601. constructor(scene: Scene,
  77602. /** defines the target object */
  77603. target: any,
  77604. /** defines the starting frame number (default is 0) */
  77605. fromFrame?: number,
  77606. /** defines the ending frame number (default is 100) */
  77607. toFrame?: number,
  77608. /** defines if the animation must loop (default is false) */
  77609. loopAnimation?: boolean, speedRatio?: number,
  77610. /** defines a callback to call when animation ends if it is not looping */
  77611. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77612. /** defines a callback to call when animation loops */
  77613. onAnimationLoop?: (() => void) | null | undefined);
  77614. /**
  77615. * Synchronize and normalize current Animatable with a source Animatable
  77616. * This is useful when using animation weights and when animations are not of the same length
  77617. * @param root defines the root Animatable to synchronize with
  77618. * @returns the current Animatable
  77619. */
  77620. syncWith(root: Animatable): Animatable;
  77621. /**
  77622. * Gets the list of runtime animations
  77623. * @returns an array of RuntimeAnimation
  77624. */
  77625. getAnimations(): RuntimeAnimation[];
  77626. /**
  77627. * Adds more animations to the current animatable
  77628. * @param target defines the target of the animations
  77629. * @param animations defines the new animations to add
  77630. */
  77631. appendAnimations(target: any, animations: Animation[]): void;
  77632. /**
  77633. * Gets the source animation for a specific property
  77634. * @param property defines the propertyu to look for
  77635. * @returns null or the source animation for the given property
  77636. */
  77637. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77638. /**
  77639. * Gets the runtime animation for a specific property
  77640. * @param property defines the propertyu to look for
  77641. * @returns null or the runtime animation for the given property
  77642. */
  77643. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77644. /**
  77645. * Resets the animatable to its original state
  77646. */
  77647. reset(): void;
  77648. /**
  77649. * Allows the animatable to blend with current running animations
  77650. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77651. * @param blendingSpeed defines the blending speed to use
  77652. */
  77653. enableBlending(blendingSpeed: number): void;
  77654. /**
  77655. * Disable animation blending
  77656. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77657. */
  77658. disableBlending(): void;
  77659. /**
  77660. * Jump directly to a given frame
  77661. * @param frame defines the frame to jump to
  77662. */
  77663. goToFrame(frame: number): void;
  77664. /**
  77665. * Pause the animation
  77666. */
  77667. pause(): void;
  77668. /**
  77669. * Restart the animation
  77670. */
  77671. restart(): void;
  77672. private _raiseOnAnimationEnd;
  77673. /**
  77674. * Stop and delete the current animation
  77675. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77676. * @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)
  77677. */
  77678. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77679. /**
  77680. * Wait asynchronously for the animation to end
  77681. * @returns a promise which will be fullfilled when the animation ends
  77682. */
  77683. waitAsync(): Promise<Animatable>;
  77684. /** @hidden */
  77685. _animate(delay: number): boolean;
  77686. }
  77687. interface Scene {
  77688. /** @hidden */
  77689. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77690. /** @hidden */
  77691. _processLateAnimationBindingsForMatrices(holder: {
  77692. totalWeight: number;
  77693. animations: RuntimeAnimation[];
  77694. originalValue: Matrix;
  77695. }): any;
  77696. /** @hidden */
  77697. _processLateAnimationBindingsForQuaternions(holder: {
  77698. totalWeight: number;
  77699. animations: RuntimeAnimation[];
  77700. originalValue: Quaternion;
  77701. }, refQuaternion: Quaternion): Quaternion;
  77702. /** @hidden */
  77703. _processLateAnimationBindings(): void;
  77704. /**
  77705. * Will start the animation sequence of a given target
  77706. * @param target defines the target
  77707. * @param from defines from which frame should animation start
  77708. * @param to defines until which frame should animation run.
  77709. * @param weight defines the weight to apply to the animation (1.0 by default)
  77710. * @param loop defines if the animation loops
  77711. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77712. * @param onAnimationEnd defines the function to be executed when the animation ends
  77713. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77714. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77715. * @param onAnimationLoop defines the callback to call when an animation loops
  77716. * @returns the animatable object created for this animation
  77717. */
  77718. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77719. /**
  77720. * Will start the animation sequence of a given target
  77721. * @param target defines the target
  77722. * @param from defines from which frame should animation start
  77723. * @param to defines until which frame should animation run.
  77724. * @param loop defines if the animation loops
  77725. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77726. * @param onAnimationEnd defines the function to be executed when the animation ends
  77727. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77728. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77729. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77730. * @param onAnimationLoop defines the callback to call when an animation loops
  77731. * @returns the animatable object created for this animation
  77732. */
  77733. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77734. /**
  77735. * Will start the animation sequence of a given target and its hierarchy
  77736. * @param target defines the target
  77737. * @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.
  77738. * @param from defines from which frame should animation start
  77739. * @param to defines until which frame should animation run.
  77740. * @param loop defines if the animation loops
  77741. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77742. * @param onAnimationEnd defines the function to be executed when the animation ends
  77743. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77744. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77745. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77746. * @param onAnimationLoop defines the callback to call when an animation loops
  77747. * @returns the list of created animatables
  77748. */
  77749. 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[];
  77750. /**
  77751. * Begin a new animation on a given node
  77752. * @param target defines the target where the animation will take place
  77753. * @param animations defines the list of animations to start
  77754. * @param from defines the initial value
  77755. * @param to defines the final value
  77756. * @param loop defines if you want animation to loop (off by default)
  77757. * @param speedRatio defines the speed ratio to apply to all animations
  77758. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77759. * @param onAnimationLoop defines the callback to call when an animation loops
  77760. * @returns the list of created animatables
  77761. */
  77762. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77763. /**
  77764. * Begin a new animation on a given node and its hierarchy
  77765. * @param target defines the root node where the animation will take place
  77766. * @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.
  77767. * @param animations defines the list of animations to start
  77768. * @param from defines the initial value
  77769. * @param to defines the final value
  77770. * @param loop defines if you want animation to loop (off by default)
  77771. * @param speedRatio defines the speed ratio to apply to all animations
  77772. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77773. * @param onAnimationLoop defines the callback to call when an animation loops
  77774. * @returns the list of animatables created for all nodes
  77775. */
  77776. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77777. /**
  77778. * Gets the animatable associated with a specific target
  77779. * @param target defines the target of the animatable
  77780. * @returns the required animatable if found
  77781. */
  77782. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77783. /**
  77784. * Gets all animatables associated with a given target
  77785. * @param target defines the target to look animatables for
  77786. * @returns an array of Animatables
  77787. */
  77788. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77789. /**
  77790. * Will stop the animation of the given target
  77791. * @param target - the target
  77792. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  77793. * @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)
  77794. */
  77795. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  77796. /**
  77797. * Stops and removes all animations that have been applied to the scene
  77798. */
  77799. stopAllAnimations(): void;
  77800. }
  77801. interface Bone {
  77802. /**
  77803. * Copy an animation range from another bone
  77804. * @param source defines the source bone
  77805. * @param rangeName defines the range name to copy
  77806. * @param frameOffset defines the frame offset
  77807. * @param rescaleAsRequired defines if rescaling must be applied if required
  77808. * @param skelDimensionsRatio defines the scaling ratio
  77809. * @returns true if operation was successful
  77810. */
  77811. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77812. }
  77813. }
  77814. declare module BABYLON {
  77815. /**
  77816. * Class used to handle skinning animations
  77817. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77818. */
  77819. export class Skeleton implements IAnimatable {
  77820. /** defines the skeleton name */
  77821. name: string;
  77822. /** defines the skeleton Id */
  77823. id: string;
  77824. /**
  77825. * Defines the list of child bones
  77826. */
  77827. bones: Bone[];
  77828. /**
  77829. * Defines an estimate of the dimension of the skeleton at rest
  77830. */
  77831. dimensionsAtRest: Vector3;
  77832. /**
  77833. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77834. */
  77835. needInitialSkinMatrix: boolean;
  77836. /**
  77837. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77838. */
  77839. overrideMesh: Nullable<AbstractMesh>;
  77840. /**
  77841. * Gets the list of animations attached to this skeleton
  77842. */
  77843. animations: Array<Animation>;
  77844. private _scene;
  77845. private _isDirty;
  77846. private _transformMatrices;
  77847. private _transformMatrixTexture;
  77848. private _meshesWithPoseMatrix;
  77849. private _animatables;
  77850. private _identity;
  77851. private _synchronizedWithMesh;
  77852. private _ranges;
  77853. private _lastAbsoluteTransformsUpdateId;
  77854. private _canUseTextureForBones;
  77855. private _uniqueId;
  77856. /** @hidden */
  77857. _numBonesWithLinkedTransformNode: number;
  77858. /**
  77859. * Specifies if the skeleton should be serialized
  77860. */
  77861. doNotSerialize: boolean;
  77862. private _useTextureToStoreBoneMatrices;
  77863. /**
  77864. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77865. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  77866. */
  77867. useTextureToStoreBoneMatrices: boolean;
  77868. private _animationPropertiesOverride;
  77869. /**
  77870. * Gets or sets the animation properties override
  77871. */
  77872. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77873. /**
  77874. * List of inspectable custom properties (used by the Inspector)
  77875. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77876. */
  77877. inspectableCustomProperties: IInspectable[];
  77878. /**
  77879. * An observable triggered before computing the skeleton's matrices
  77880. */
  77881. onBeforeComputeObservable: Observable<Skeleton>;
  77882. /**
  77883. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77884. */
  77885. readonly isUsingTextureForMatrices: boolean;
  77886. /**
  77887. * Gets the unique ID of this skeleton
  77888. */
  77889. readonly uniqueId: number;
  77890. /**
  77891. * Creates a new skeleton
  77892. * @param name defines the skeleton name
  77893. * @param id defines the skeleton Id
  77894. * @param scene defines the hosting scene
  77895. */
  77896. constructor(
  77897. /** defines the skeleton name */
  77898. name: string,
  77899. /** defines the skeleton Id */
  77900. id: string, scene: Scene);
  77901. /**
  77902. * Gets the current object class name.
  77903. * @return the class name
  77904. */
  77905. getClassName(): string;
  77906. /**
  77907. * Returns an array containing the root bones
  77908. * @returns an array containing the root bones
  77909. */
  77910. getChildren(): Array<Bone>;
  77911. /**
  77912. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77913. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77914. * @returns a Float32Array containing matrices data
  77915. */
  77916. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77917. /**
  77918. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77919. * @returns a raw texture containing the data
  77920. */
  77921. getTransformMatrixTexture(): Nullable<RawTexture>;
  77922. /**
  77923. * Gets the current hosting scene
  77924. * @returns a scene object
  77925. */
  77926. getScene(): Scene;
  77927. /**
  77928. * Gets a string representing the current skeleton data
  77929. * @param fullDetails defines a boolean indicating if we want a verbose version
  77930. * @returns a string representing the current skeleton data
  77931. */
  77932. toString(fullDetails?: boolean): string;
  77933. /**
  77934. * Get bone's index searching by name
  77935. * @param name defines bone's name to search for
  77936. * @return the indice of the bone. Returns -1 if not found
  77937. */
  77938. getBoneIndexByName(name: string): number;
  77939. /**
  77940. * Creater a new animation range
  77941. * @param name defines the name of the range
  77942. * @param from defines the start key
  77943. * @param to defines the end key
  77944. */
  77945. createAnimationRange(name: string, from: number, to: number): void;
  77946. /**
  77947. * Delete a specific animation range
  77948. * @param name defines the name of the range
  77949. * @param deleteFrames defines if frames must be removed as well
  77950. */
  77951. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77952. /**
  77953. * Gets a specific animation range
  77954. * @param name defines the name of the range to look for
  77955. * @returns the requested animation range or null if not found
  77956. */
  77957. getAnimationRange(name: string): Nullable<AnimationRange>;
  77958. /**
  77959. * Gets the list of all animation ranges defined on this skeleton
  77960. * @returns an array
  77961. */
  77962. getAnimationRanges(): Nullable<AnimationRange>[];
  77963. /**
  77964. * Copy animation range from a source skeleton.
  77965. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77966. * @param source defines the source skeleton
  77967. * @param name defines the name of the range to copy
  77968. * @param rescaleAsRequired defines if rescaling must be applied if required
  77969. * @returns true if operation was successful
  77970. */
  77971. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77972. /**
  77973. * Forces the skeleton to go to rest pose
  77974. */
  77975. returnToRest(): void;
  77976. private _getHighestAnimationFrame;
  77977. /**
  77978. * Begin a specific animation range
  77979. * @param name defines the name of the range to start
  77980. * @param loop defines if looping must be turned on (false by default)
  77981. * @param speedRatio defines the speed ratio to apply (1 by default)
  77982. * @param onAnimationEnd defines a callback which will be called when animation will end
  77983. * @returns a new animatable
  77984. */
  77985. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77986. /** @hidden */
  77987. _markAsDirty(): void;
  77988. /** @hidden */
  77989. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77990. /** @hidden */
  77991. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77992. private _computeTransformMatrices;
  77993. /**
  77994. * Build all resources required to render a skeleton
  77995. */
  77996. prepare(): void;
  77997. /**
  77998. * Gets the list of animatables currently running for this skeleton
  77999. * @returns an array of animatables
  78000. */
  78001. getAnimatables(): IAnimatable[];
  78002. /**
  78003. * Clone the current skeleton
  78004. * @param name defines the name of the new skeleton
  78005. * @param id defines the id of the enw skeleton
  78006. * @returns the new skeleton
  78007. */
  78008. clone(name: string, id: string): Skeleton;
  78009. /**
  78010. * Enable animation blending for this skeleton
  78011. * @param blendingSpeed defines the blending speed to apply
  78012. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78013. */
  78014. enableBlending(blendingSpeed?: number): void;
  78015. /**
  78016. * Releases all resources associated with the current skeleton
  78017. */
  78018. dispose(): void;
  78019. /**
  78020. * Serialize the skeleton in a JSON object
  78021. * @returns a JSON object
  78022. */
  78023. serialize(): any;
  78024. /**
  78025. * Creates a new skeleton from serialized data
  78026. * @param parsedSkeleton defines the serialized data
  78027. * @param scene defines the hosting scene
  78028. * @returns a new skeleton
  78029. */
  78030. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78031. /**
  78032. * Compute all node absolute transforms
  78033. * @param forceUpdate defines if computation must be done even if cache is up to date
  78034. */
  78035. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78036. /**
  78037. * Gets the root pose matrix
  78038. * @returns a matrix
  78039. */
  78040. getPoseMatrix(): Nullable<Matrix>;
  78041. /**
  78042. * Sorts bones per internal index
  78043. */
  78044. sortBones(): void;
  78045. private _sortBones;
  78046. }
  78047. }
  78048. declare module BABYLON {
  78049. /**
  78050. * Defines a target to use with MorphTargetManager
  78051. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78052. */
  78053. export class MorphTarget implements IAnimatable {
  78054. /** defines the name of the target */
  78055. name: string;
  78056. /**
  78057. * Gets or sets the list of animations
  78058. */
  78059. animations: Animation[];
  78060. private _scene;
  78061. private _positions;
  78062. private _normals;
  78063. private _tangents;
  78064. private _influence;
  78065. /**
  78066. * Observable raised when the influence changes
  78067. */
  78068. onInfluenceChanged: Observable<boolean>;
  78069. /** @hidden */
  78070. _onDataLayoutChanged: Observable<void>;
  78071. /**
  78072. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  78073. */
  78074. influence: number;
  78075. /**
  78076. * Gets or sets the id of the morph Target
  78077. */
  78078. id: string;
  78079. private _animationPropertiesOverride;
  78080. /**
  78081. * Gets or sets the animation properties override
  78082. */
  78083. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78084. /**
  78085. * Creates a new MorphTarget
  78086. * @param name defines the name of the target
  78087. * @param influence defines the influence to use
  78088. * @param scene defines the scene the morphtarget belongs to
  78089. */
  78090. constructor(
  78091. /** defines the name of the target */
  78092. name: string, influence?: number, scene?: Nullable<Scene>);
  78093. /**
  78094. * Gets a boolean defining if the target contains position data
  78095. */
  78096. readonly hasPositions: boolean;
  78097. /**
  78098. * Gets a boolean defining if the target contains normal data
  78099. */
  78100. readonly hasNormals: boolean;
  78101. /**
  78102. * Gets a boolean defining if the target contains tangent data
  78103. */
  78104. readonly hasTangents: boolean;
  78105. /**
  78106. * Affects position data to this target
  78107. * @param data defines the position data to use
  78108. */
  78109. setPositions(data: Nullable<FloatArray>): void;
  78110. /**
  78111. * Gets the position data stored in this target
  78112. * @returns a FloatArray containing the position data (or null if not present)
  78113. */
  78114. getPositions(): Nullable<FloatArray>;
  78115. /**
  78116. * Affects normal data to this target
  78117. * @param data defines the normal data to use
  78118. */
  78119. setNormals(data: Nullable<FloatArray>): void;
  78120. /**
  78121. * Gets the normal data stored in this target
  78122. * @returns a FloatArray containing the normal data (or null if not present)
  78123. */
  78124. getNormals(): Nullable<FloatArray>;
  78125. /**
  78126. * Affects tangent data to this target
  78127. * @param data defines the tangent data to use
  78128. */
  78129. setTangents(data: Nullable<FloatArray>): void;
  78130. /**
  78131. * Gets the tangent data stored in this target
  78132. * @returns a FloatArray containing the tangent data (or null if not present)
  78133. */
  78134. getTangents(): Nullable<FloatArray>;
  78135. /**
  78136. * Serializes the current target into a Serialization object
  78137. * @returns the serialized object
  78138. */
  78139. serialize(): any;
  78140. /**
  78141. * Returns the string "MorphTarget"
  78142. * @returns "MorphTarget"
  78143. */
  78144. getClassName(): string;
  78145. /**
  78146. * Creates a new target from serialized data
  78147. * @param serializationObject defines the serialized data to use
  78148. * @returns a new MorphTarget
  78149. */
  78150. static Parse(serializationObject: any): MorphTarget;
  78151. /**
  78152. * Creates a MorphTarget from mesh data
  78153. * @param mesh defines the source mesh
  78154. * @param name defines the name to use for the new target
  78155. * @param influence defines the influence to attach to the target
  78156. * @returns a new MorphTarget
  78157. */
  78158. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  78159. }
  78160. }
  78161. declare module BABYLON {
  78162. /**
  78163. * This class is used to deform meshes using morphing between different targets
  78164. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78165. */
  78166. export class MorphTargetManager {
  78167. private _targets;
  78168. private _targetInfluenceChangedObservers;
  78169. private _targetDataLayoutChangedObservers;
  78170. private _activeTargets;
  78171. private _scene;
  78172. private _influences;
  78173. private _supportsNormals;
  78174. private _supportsTangents;
  78175. private _vertexCount;
  78176. private _uniqueId;
  78177. private _tempInfluences;
  78178. /**
  78179. * Creates a new MorphTargetManager
  78180. * @param scene defines the current scene
  78181. */
  78182. constructor(scene?: Nullable<Scene>);
  78183. /**
  78184. * Gets the unique ID of this manager
  78185. */
  78186. readonly uniqueId: number;
  78187. /**
  78188. * Gets the number of vertices handled by this manager
  78189. */
  78190. readonly vertexCount: number;
  78191. /**
  78192. * Gets a boolean indicating if this manager supports morphing of normals
  78193. */
  78194. readonly supportsNormals: boolean;
  78195. /**
  78196. * Gets a boolean indicating if this manager supports morphing of tangents
  78197. */
  78198. readonly supportsTangents: boolean;
  78199. /**
  78200. * Gets the number of targets stored in this manager
  78201. */
  78202. readonly numTargets: number;
  78203. /**
  78204. * Gets the number of influencers (ie. the number of targets with influences > 0)
  78205. */
  78206. readonly numInfluencers: number;
  78207. /**
  78208. * Gets the list of influences (one per target)
  78209. */
  78210. readonly influences: Float32Array;
  78211. /**
  78212. * Gets the active target at specified index. An active target is a target with an influence > 0
  78213. * @param index defines the index to check
  78214. * @returns the requested target
  78215. */
  78216. getActiveTarget(index: number): MorphTarget;
  78217. /**
  78218. * Gets the target at specified index
  78219. * @param index defines the index to check
  78220. * @returns the requested target
  78221. */
  78222. getTarget(index: number): MorphTarget;
  78223. /**
  78224. * Add a new target to this manager
  78225. * @param target defines the target to add
  78226. */
  78227. addTarget(target: MorphTarget): void;
  78228. /**
  78229. * Removes a target from the manager
  78230. * @param target defines the target to remove
  78231. */
  78232. removeTarget(target: MorphTarget): void;
  78233. /**
  78234. * Serializes the current manager into a Serialization object
  78235. * @returns the serialized object
  78236. */
  78237. serialize(): any;
  78238. private _syncActiveTargets;
  78239. /**
  78240. * Syncrhonize the targets with all the meshes using this morph target manager
  78241. */
  78242. synchronize(): void;
  78243. /**
  78244. * Creates a new MorphTargetManager from serialized data
  78245. * @param serializationObject defines the serialized data
  78246. * @param scene defines the hosting scene
  78247. * @returns the new MorphTargetManager
  78248. */
  78249. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  78250. }
  78251. }
  78252. declare module BABYLON {
  78253. /**
  78254. * Mesh representing the gorund
  78255. */
  78256. export class GroundMesh extends Mesh {
  78257. /** If octree should be generated */
  78258. generateOctree: boolean;
  78259. private _heightQuads;
  78260. /** @hidden */
  78261. _subdivisionsX: number;
  78262. /** @hidden */
  78263. _subdivisionsY: number;
  78264. /** @hidden */
  78265. _width: number;
  78266. /** @hidden */
  78267. _height: number;
  78268. /** @hidden */
  78269. _minX: number;
  78270. /** @hidden */
  78271. _maxX: number;
  78272. /** @hidden */
  78273. _minZ: number;
  78274. /** @hidden */
  78275. _maxZ: number;
  78276. constructor(name: string, scene: Scene);
  78277. /**
  78278. * "GroundMesh"
  78279. * @returns "GroundMesh"
  78280. */
  78281. getClassName(): string;
  78282. /**
  78283. * The minimum of x and y subdivisions
  78284. */
  78285. readonly subdivisions: number;
  78286. /**
  78287. * X subdivisions
  78288. */
  78289. readonly subdivisionsX: number;
  78290. /**
  78291. * Y subdivisions
  78292. */
  78293. readonly subdivisionsY: number;
  78294. /**
  78295. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  78296. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  78297. * @param chunksCount the number of subdivisions for x and y
  78298. * @param octreeBlocksSize (Default: 32)
  78299. */
  78300. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  78301. /**
  78302. * Returns a height (y) value in the Worl system :
  78303. * the ground altitude at the coordinates (x, z) expressed in the World system.
  78304. * @param x x coordinate
  78305. * @param z z coordinate
  78306. * @returns the ground y position if (x, z) are outside the ground surface.
  78307. */
  78308. getHeightAtCoordinates(x: number, z: number): number;
  78309. /**
  78310. * Returns a normalized vector (Vector3) orthogonal to the ground
  78311. * at the ground coordinates (x, z) expressed in the World system.
  78312. * @param x x coordinate
  78313. * @param z z coordinate
  78314. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  78315. */
  78316. getNormalAtCoordinates(x: number, z: number): Vector3;
  78317. /**
  78318. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  78319. * at the ground coordinates (x, z) expressed in the World system.
  78320. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  78321. * @param x x coordinate
  78322. * @param z z coordinate
  78323. * @param ref vector to store the result
  78324. * @returns the GroundMesh.
  78325. */
  78326. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  78327. /**
  78328. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  78329. * if the ground has been updated.
  78330. * This can be used in the render loop.
  78331. * @returns the GroundMesh.
  78332. */
  78333. updateCoordinateHeights(): GroundMesh;
  78334. private _getFacetAt;
  78335. private _initHeightQuads;
  78336. private _computeHeightQuads;
  78337. /**
  78338. * Serializes this ground mesh
  78339. * @param serializationObject object to write serialization to
  78340. */
  78341. serialize(serializationObject: any): void;
  78342. /**
  78343. * Parses a serialized ground mesh
  78344. * @param parsedMesh the serialized mesh
  78345. * @param scene the scene to create the ground mesh in
  78346. * @returns the created ground mesh
  78347. */
  78348. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  78349. }
  78350. }
  78351. declare module BABYLON {
  78352. /**
  78353. * Interface for Physics-Joint data
  78354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78355. */
  78356. export interface PhysicsJointData {
  78357. /**
  78358. * The main pivot of the joint
  78359. */
  78360. mainPivot?: Vector3;
  78361. /**
  78362. * The connected pivot of the joint
  78363. */
  78364. connectedPivot?: Vector3;
  78365. /**
  78366. * The main axis of the joint
  78367. */
  78368. mainAxis?: Vector3;
  78369. /**
  78370. * The connected axis of the joint
  78371. */
  78372. connectedAxis?: Vector3;
  78373. /**
  78374. * The collision of the joint
  78375. */
  78376. collision?: boolean;
  78377. /**
  78378. * Native Oimo/Cannon/Energy data
  78379. */
  78380. nativeParams?: any;
  78381. }
  78382. /**
  78383. * This is a holder class for the physics joint created by the physics plugin
  78384. * It holds a set of functions to control the underlying joint
  78385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78386. */
  78387. export class PhysicsJoint {
  78388. /**
  78389. * The type of the physics joint
  78390. */
  78391. type: number;
  78392. /**
  78393. * The data for the physics joint
  78394. */
  78395. jointData: PhysicsJointData;
  78396. private _physicsJoint;
  78397. protected _physicsPlugin: IPhysicsEnginePlugin;
  78398. /**
  78399. * Initializes the physics joint
  78400. * @param type The type of the physics joint
  78401. * @param jointData The data for the physics joint
  78402. */
  78403. constructor(
  78404. /**
  78405. * The type of the physics joint
  78406. */
  78407. type: number,
  78408. /**
  78409. * The data for the physics joint
  78410. */
  78411. jointData: PhysicsJointData);
  78412. /**
  78413. * Gets the physics joint
  78414. */
  78415. /**
  78416. * Sets the physics joint
  78417. */
  78418. physicsJoint: any;
  78419. /**
  78420. * Sets the physics plugin
  78421. */
  78422. physicsPlugin: IPhysicsEnginePlugin;
  78423. /**
  78424. * Execute a function that is physics-plugin specific.
  78425. * @param {Function} func the function that will be executed.
  78426. * It accepts two parameters: the physics world and the physics joint
  78427. */
  78428. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  78429. /**
  78430. * Distance-Joint type
  78431. */
  78432. static DistanceJoint: number;
  78433. /**
  78434. * Hinge-Joint type
  78435. */
  78436. static HingeJoint: number;
  78437. /**
  78438. * Ball-and-Socket joint type
  78439. */
  78440. static BallAndSocketJoint: number;
  78441. /**
  78442. * Wheel-Joint type
  78443. */
  78444. static WheelJoint: number;
  78445. /**
  78446. * Slider-Joint type
  78447. */
  78448. static SliderJoint: number;
  78449. /**
  78450. * Prismatic-Joint type
  78451. */
  78452. static PrismaticJoint: number;
  78453. /**
  78454. * Universal-Joint type
  78455. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  78456. */
  78457. static UniversalJoint: number;
  78458. /**
  78459. * Hinge-Joint 2 type
  78460. */
  78461. static Hinge2Joint: number;
  78462. /**
  78463. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  78464. */
  78465. static PointToPointJoint: number;
  78466. /**
  78467. * Spring-Joint type
  78468. */
  78469. static SpringJoint: number;
  78470. /**
  78471. * Lock-Joint type
  78472. */
  78473. static LockJoint: number;
  78474. }
  78475. /**
  78476. * A class representing a physics distance joint
  78477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78478. */
  78479. export class DistanceJoint extends PhysicsJoint {
  78480. /**
  78481. *
  78482. * @param jointData The data for the Distance-Joint
  78483. */
  78484. constructor(jointData: DistanceJointData);
  78485. /**
  78486. * Update the predefined distance.
  78487. * @param maxDistance The maximum preferred distance
  78488. * @param minDistance The minimum preferred distance
  78489. */
  78490. updateDistance(maxDistance: number, minDistance?: number): void;
  78491. }
  78492. /**
  78493. * Represents a Motor-Enabled Joint
  78494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78495. */
  78496. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  78497. /**
  78498. * Initializes the Motor-Enabled Joint
  78499. * @param type The type of the joint
  78500. * @param jointData The physica joint data for the joint
  78501. */
  78502. constructor(type: number, jointData: PhysicsJointData);
  78503. /**
  78504. * Set the motor values.
  78505. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78506. * @param force the force to apply
  78507. * @param maxForce max force for this motor.
  78508. */
  78509. setMotor(force?: number, maxForce?: number): void;
  78510. /**
  78511. * Set the motor's limits.
  78512. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78513. * @param upperLimit The upper limit of the motor
  78514. * @param lowerLimit The lower limit of the motor
  78515. */
  78516. setLimit(upperLimit: number, lowerLimit?: number): void;
  78517. }
  78518. /**
  78519. * This class represents a single physics Hinge-Joint
  78520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78521. */
  78522. export class HingeJoint extends MotorEnabledJoint {
  78523. /**
  78524. * Initializes the Hinge-Joint
  78525. * @param jointData The joint data for the Hinge-Joint
  78526. */
  78527. constructor(jointData: PhysicsJointData);
  78528. /**
  78529. * Set the motor values.
  78530. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78531. * @param {number} force the force to apply
  78532. * @param {number} maxForce max force for this motor.
  78533. */
  78534. setMotor(force?: number, maxForce?: number): void;
  78535. /**
  78536. * Set the motor's limits.
  78537. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78538. * @param upperLimit The upper limit of the motor
  78539. * @param lowerLimit The lower limit of the motor
  78540. */
  78541. setLimit(upperLimit: number, lowerLimit?: number): void;
  78542. }
  78543. /**
  78544. * This class represents a dual hinge physics joint (same as wheel joint)
  78545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78546. */
  78547. export class Hinge2Joint extends MotorEnabledJoint {
  78548. /**
  78549. * Initializes the Hinge2-Joint
  78550. * @param jointData The joint data for the Hinge2-Joint
  78551. */
  78552. constructor(jointData: PhysicsJointData);
  78553. /**
  78554. * Set the motor values.
  78555. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78556. * @param {number} targetSpeed the speed the motor is to reach
  78557. * @param {number} maxForce max force for this motor.
  78558. * @param {motorIndex} the motor's index, 0 or 1.
  78559. */
  78560. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  78561. /**
  78562. * Set the motor limits.
  78563. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78564. * @param {number} upperLimit the upper limit
  78565. * @param {number} lowerLimit lower limit
  78566. * @param {motorIndex} the motor's index, 0 or 1.
  78567. */
  78568. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78569. }
  78570. /**
  78571. * Interface for a motor enabled joint
  78572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78573. */
  78574. export interface IMotorEnabledJoint {
  78575. /**
  78576. * Physics joint
  78577. */
  78578. physicsJoint: any;
  78579. /**
  78580. * Sets the motor of the motor-enabled joint
  78581. * @param force The force of the motor
  78582. * @param maxForce The maximum force of the motor
  78583. * @param motorIndex The index of the motor
  78584. */
  78585. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  78586. /**
  78587. * Sets the limit of the motor
  78588. * @param upperLimit The upper limit of the motor
  78589. * @param lowerLimit The lower limit of the motor
  78590. * @param motorIndex The index of the motor
  78591. */
  78592. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78593. }
  78594. /**
  78595. * Joint data for a Distance-Joint
  78596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78597. */
  78598. export interface DistanceJointData extends PhysicsJointData {
  78599. /**
  78600. * Max distance the 2 joint objects can be apart
  78601. */
  78602. maxDistance: number;
  78603. }
  78604. /**
  78605. * Joint data from a spring joint
  78606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78607. */
  78608. export interface SpringJointData extends PhysicsJointData {
  78609. /**
  78610. * Length of the spring
  78611. */
  78612. length: number;
  78613. /**
  78614. * Stiffness of the spring
  78615. */
  78616. stiffness: number;
  78617. /**
  78618. * Damping of the spring
  78619. */
  78620. damping: number;
  78621. /** this callback will be called when applying the force to the impostors. */
  78622. forceApplicationCallback: () => void;
  78623. }
  78624. }
  78625. declare module BABYLON {
  78626. /**
  78627. * Holds the data for the raycast result
  78628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78629. */
  78630. export class PhysicsRaycastResult {
  78631. private _hasHit;
  78632. private _hitDistance;
  78633. private _hitNormalWorld;
  78634. private _hitPointWorld;
  78635. private _rayFromWorld;
  78636. private _rayToWorld;
  78637. /**
  78638. * Gets if there was a hit
  78639. */
  78640. readonly hasHit: boolean;
  78641. /**
  78642. * Gets the distance from the hit
  78643. */
  78644. readonly hitDistance: number;
  78645. /**
  78646. * Gets the hit normal/direction in the world
  78647. */
  78648. readonly hitNormalWorld: Vector3;
  78649. /**
  78650. * Gets the hit point in the world
  78651. */
  78652. readonly hitPointWorld: Vector3;
  78653. /**
  78654. * Gets the ray "start point" of the ray in the world
  78655. */
  78656. readonly rayFromWorld: Vector3;
  78657. /**
  78658. * Gets the ray "end point" of the ray in the world
  78659. */
  78660. readonly rayToWorld: Vector3;
  78661. /**
  78662. * Sets the hit data (normal & point in world space)
  78663. * @param hitNormalWorld defines the normal in world space
  78664. * @param hitPointWorld defines the point in world space
  78665. */
  78666. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  78667. /**
  78668. * Sets the distance from the start point to the hit point
  78669. * @param distance
  78670. */
  78671. setHitDistance(distance: number): void;
  78672. /**
  78673. * Calculates the distance manually
  78674. */
  78675. calculateHitDistance(): void;
  78676. /**
  78677. * Resets all the values to default
  78678. * @param from The from point on world space
  78679. * @param to The to point on world space
  78680. */
  78681. reset(from?: Vector3, to?: Vector3): void;
  78682. }
  78683. /**
  78684. * Interface for the size containing width and height
  78685. */
  78686. interface IXYZ {
  78687. /**
  78688. * X
  78689. */
  78690. x: number;
  78691. /**
  78692. * Y
  78693. */
  78694. y: number;
  78695. /**
  78696. * Z
  78697. */
  78698. z: number;
  78699. }
  78700. }
  78701. declare module BABYLON {
  78702. /**
  78703. * Interface used to describe a physics joint
  78704. */
  78705. export interface PhysicsImpostorJoint {
  78706. /** Defines the main impostor to which the joint is linked */
  78707. mainImpostor: PhysicsImpostor;
  78708. /** Defines the impostor that is connected to the main impostor using this joint */
  78709. connectedImpostor: PhysicsImpostor;
  78710. /** Defines the joint itself */
  78711. joint: PhysicsJoint;
  78712. }
  78713. /** @hidden */
  78714. export interface IPhysicsEnginePlugin {
  78715. world: any;
  78716. name: string;
  78717. setGravity(gravity: Vector3): void;
  78718. setTimeStep(timeStep: number): void;
  78719. getTimeStep(): number;
  78720. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  78721. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78722. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78723. generatePhysicsBody(impostor: PhysicsImpostor): void;
  78724. removePhysicsBody(impostor: PhysicsImpostor): void;
  78725. generateJoint(joint: PhysicsImpostorJoint): void;
  78726. removeJoint(joint: PhysicsImpostorJoint): void;
  78727. isSupported(): boolean;
  78728. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  78729. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  78730. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78731. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78732. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78733. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78734. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  78735. getBodyMass(impostor: PhysicsImpostor): number;
  78736. getBodyFriction(impostor: PhysicsImpostor): number;
  78737. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  78738. getBodyRestitution(impostor: PhysicsImpostor): number;
  78739. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  78740. getBodyPressure?(impostor: PhysicsImpostor): number;
  78741. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  78742. getBodyStiffness?(impostor: PhysicsImpostor): number;
  78743. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  78744. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  78745. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  78746. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  78747. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  78748. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78749. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78750. sleepBody(impostor: PhysicsImpostor): void;
  78751. wakeUpBody(impostor: PhysicsImpostor): void;
  78752. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78753. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  78754. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  78755. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78756. getRadius(impostor: PhysicsImpostor): number;
  78757. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  78758. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  78759. dispose(): void;
  78760. }
  78761. /**
  78762. * Interface used to define a physics engine
  78763. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  78764. */
  78765. export interface IPhysicsEngine {
  78766. /**
  78767. * Gets the gravity vector used by the simulation
  78768. */
  78769. gravity: Vector3;
  78770. /**
  78771. * Sets the gravity vector used by the simulation
  78772. * @param gravity defines the gravity vector to use
  78773. */
  78774. setGravity(gravity: Vector3): void;
  78775. /**
  78776. * Set the time step of the physics engine.
  78777. * Default is 1/60.
  78778. * To slow it down, enter 1/600 for example.
  78779. * To speed it up, 1/30
  78780. * @param newTimeStep the new timestep to apply to this world.
  78781. */
  78782. setTimeStep(newTimeStep: number): void;
  78783. /**
  78784. * Get the time step of the physics engine.
  78785. * @returns the current time step
  78786. */
  78787. getTimeStep(): number;
  78788. /**
  78789. * Release all resources
  78790. */
  78791. dispose(): void;
  78792. /**
  78793. * Gets the name of the current physics plugin
  78794. * @returns the name of the plugin
  78795. */
  78796. getPhysicsPluginName(): string;
  78797. /**
  78798. * Adding a new impostor for the impostor tracking.
  78799. * This will be done by the impostor itself.
  78800. * @param impostor the impostor to add
  78801. */
  78802. addImpostor(impostor: PhysicsImpostor): void;
  78803. /**
  78804. * Remove an impostor from the engine.
  78805. * This impostor and its mesh will not longer be updated by the physics engine.
  78806. * @param impostor the impostor to remove
  78807. */
  78808. removeImpostor(impostor: PhysicsImpostor): void;
  78809. /**
  78810. * Add a joint to the physics engine
  78811. * @param mainImpostor defines the main impostor to which the joint is added.
  78812. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  78813. * @param joint defines the joint that will connect both impostors.
  78814. */
  78815. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78816. /**
  78817. * Removes a joint from the simulation
  78818. * @param mainImpostor defines the impostor used with the joint
  78819. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  78820. * @param joint defines the joint to remove
  78821. */
  78822. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78823. /**
  78824. * Gets the current plugin used to run the simulation
  78825. * @returns current plugin
  78826. */
  78827. getPhysicsPlugin(): IPhysicsEnginePlugin;
  78828. /**
  78829. * Gets the list of physic impostors
  78830. * @returns an array of PhysicsImpostor
  78831. */
  78832. getImpostors(): Array<PhysicsImpostor>;
  78833. /**
  78834. * Gets the impostor for a physics enabled object
  78835. * @param object defines the object impersonated by the impostor
  78836. * @returns the PhysicsImpostor or null if not found
  78837. */
  78838. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78839. /**
  78840. * Gets the impostor for a physics body object
  78841. * @param body defines physics body used by the impostor
  78842. * @returns the PhysicsImpostor or null if not found
  78843. */
  78844. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  78845. /**
  78846. * Does a raycast in the physics world
  78847. * @param from when should the ray start?
  78848. * @param to when should the ray end?
  78849. * @returns PhysicsRaycastResult
  78850. */
  78851. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78852. /**
  78853. * Called by the scene. No need to call it.
  78854. * @param delta defines the timespam between frames
  78855. */
  78856. _step(delta: number): void;
  78857. }
  78858. }
  78859. declare module BABYLON {
  78860. /**
  78861. * The interface for the physics imposter parameters
  78862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78863. */
  78864. export interface PhysicsImpostorParameters {
  78865. /**
  78866. * The mass of the physics imposter
  78867. */
  78868. mass: number;
  78869. /**
  78870. * The friction of the physics imposter
  78871. */
  78872. friction?: number;
  78873. /**
  78874. * The coefficient of restitution of the physics imposter
  78875. */
  78876. restitution?: number;
  78877. /**
  78878. * The native options of the physics imposter
  78879. */
  78880. nativeOptions?: any;
  78881. /**
  78882. * Specifies if the parent should be ignored
  78883. */
  78884. ignoreParent?: boolean;
  78885. /**
  78886. * Specifies if bi-directional transformations should be disabled
  78887. */
  78888. disableBidirectionalTransformation?: boolean;
  78889. /**
  78890. * The pressure inside the physics imposter, soft object only
  78891. */
  78892. pressure?: number;
  78893. /**
  78894. * The stiffness the physics imposter, soft object only
  78895. */
  78896. stiffness?: number;
  78897. /**
  78898. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  78899. */
  78900. velocityIterations?: number;
  78901. /**
  78902. * The number of iterations used in maintaining consistent vertex positions, soft object only
  78903. */
  78904. positionIterations?: number;
  78905. /**
  78906. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  78907. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  78908. * Add to fix multiple points
  78909. */
  78910. fixedPoints?: number;
  78911. /**
  78912. * The collision margin around a soft object
  78913. */
  78914. margin?: number;
  78915. /**
  78916. * The collision margin around a soft object
  78917. */
  78918. damping?: number;
  78919. /**
  78920. * The path for a rope based on an extrusion
  78921. */
  78922. path?: any;
  78923. /**
  78924. * The shape of an extrusion used for a rope based on an extrusion
  78925. */
  78926. shape?: any;
  78927. }
  78928. /**
  78929. * Interface for a physics-enabled object
  78930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78931. */
  78932. export interface IPhysicsEnabledObject {
  78933. /**
  78934. * The position of the physics-enabled object
  78935. */
  78936. position: Vector3;
  78937. /**
  78938. * The rotation of the physics-enabled object
  78939. */
  78940. rotationQuaternion: Nullable<Quaternion>;
  78941. /**
  78942. * The scale of the physics-enabled object
  78943. */
  78944. scaling: Vector3;
  78945. /**
  78946. * The rotation of the physics-enabled object
  78947. */
  78948. rotation?: Vector3;
  78949. /**
  78950. * The parent of the physics-enabled object
  78951. */
  78952. parent?: any;
  78953. /**
  78954. * The bounding info of the physics-enabled object
  78955. * @returns The bounding info of the physics-enabled object
  78956. */
  78957. getBoundingInfo(): BoundingInfo;
  78958. /**
  78959. * Computes the world matrix
  78960. * @param force Specifies if the world matrix should be computed by force
  78961. * @returns A world matrix
  78962. */
  78963. computeWorldMatrix(force: boolean): Matrix;
  78964. /**
  78965. * Gets the world matrix
  78966. * @returns A world matrix
  78967. */
  78968. getWorldMatrix?(): Matrix;
  78969. /**
  78970. * Gets the child meshes
  78971. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  78972. * @returns An array of abstract meshes
  78973. */
  78974. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  78975. /**
  78976. * Gets the vertex data
  78977. * @param kind The type of vertex data
  78978. * @returns A nullable array of numbers, or a float32 array
  78979. */
  78980. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  78981. /**
  78982. * Gets the indices from the mesh
  78983. * @returns A nullable array of index arrays
  78984. */
  78985. getIndices?(): Nullable<IndicesArray>;
  78986. /**
  78987. * Gets the scene from the mesh
  78988. * @returns the indices array or null
  78989. */
  78990. getScene?(): Scene;
  78991. /**
  78992. * Gets the absolute position from the mesh
  78993. * @returns the absolute position
  78994. */
  78995. getAbsolutePosition(): Vector3;
  78996. /**
  78997. * Gets the absolute pivot point from the mesh
  78998. * @returns the absolute pivot point
  78999. */
  79000. getAbsolutePivotPoint(): Vector3;
  79001. /**
  79002. * Rotates the mesh
  79003. * @param axis The axis of rotation
  79004. * @param amount The amount of rotation
  79005. * @param space The space of the rotation
  79006. * @returns The rotation transform node
  79007. */
  79008. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79009. /**
  79010. * Translates the mesh
  79011. * @param axis The axis of translation
  79012. * @param distance The distance of translation
  79013. * @param space The space of the translation
  79014. * @returns The transform node
  79015. */
  79016. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79017. /**
  79018. * Sets the absolute position of the mesh
  79019. * @param absolutePosition The absolute position of the mesh
  79020. * @returns The transform node
  79021. */
  79022. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79023. /**
  79024. * Gets the class name of the mesh
  79025. * @returns The class name
  79026. */
  79027. getClassName(): string;
  79028. }
  79029. /**
  79030. * Represents a physics imposter
  79031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79032. */
  79033. export class PhysicsImpostor {
  79034. /**
  79035. * The physics-enabled object used as the physics imposter
  79036. */
  79037. object: IPhysicsEnabledObject;
  79038. /**
  79039. * The type of the physics imposter
  79040. */
  79041. type: number;
  79042. private _options;
  79043. private _scene?;
  79044. /**
  79045. * The default object size of the imposter
  79046. */
  79047. static DEFAULT_OBJECT_SIZE: Vector3;
  79048. /**
  79049. * The identity quaternion of the imposter
  79050. */
  79051. static IDENTITY_QUATERNION: Quaternion;
  79052. /** @hidden */
  79053. _pluginData: any;
  79054. private _physicsEngine;
  79055. private _physicsBody;
  79056. private _bodyUpdateRequired;
  79057. private _onBeforePhysicsStepCallbacks;
  79058. private _onAfterPhysicsStepCallbacks;
  79059. /** @hidden */
  79060. _onPhysicsCollideCallbacks: Array<{
  79061. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  79062. otherImpostors: Array<PhysicsImpostor>;
  79063. }>;
  79064. private _deltaPosition;
  79065. private _deltaRotation;
  79066. private _deltaRotationConjugated;
  79067. /** hidden */
  79068. _isFromLine: boolean;
  79069. private _parent;
  79070. private _isDisposed;
  79071. private static _tmpVecs;
  79072. private static _tmpQuat;
  79073. /**
  79074. * Specifies if the physics imposter is disposed
  79075. */
  79076. readonly isDisposed: boolean;
  79077. /**
  79078. * Gets the mass of the physics imposter
  79079. */
  79080. mass: number;
  79081. /**
  79082. * Gets the coefficient of friction
  79083. */
  79084. /**
  79085. * Sets the coefficient of friction
  79086. */
  79087. friction: number;
  79088. /**
  79089. * Gets the coefficient of restitution
  79090. */
  79091. /**
  79092. * Sets the coefficient of restitution
  79093. */
  79094. restitution: number;
  79095. /**
  79096. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  79097. */
  79098. /**
  79099. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  79100. */
  79101. pressure: number;
  79102. /**
  79103. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79104. */
  79105. /**
  79106. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79107. */
  79108. stiffness: number;
  79109. /**
  79110. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79111. */
  79112. /**
  79113. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79114. */
  79115. velocityIterations: number;
  79116. /**
  79117. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79118. */
  79119. /**
  79120. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79121. */
  79122. positionIterations: number;
  79123. /**
  79124. * The unique id of the physics imposter
  79125. * set by the physics engine when adding this impostor to the array
  79126. */
  79127. uniqueId: number;
  79128. /**
  79129. * @hidden
  79130. */
  79131. soft: boolean;
  79132. /**
  79133. * @hidden
  79134. */
  79135. segments: number;
  79136. private _joints;
  79137. /**
  79138. * Initializes the physics imposter
  79139. * @param object The physics-enabled object used as the physics imposter
  79140. * @param type The type of the physics imposter
  79141. * @param _options The options for the physics imposter
  79142. * @param _scene The Babylon scene
  79143. */
  79144. constructor(
  79145. /**
  79146. * The physics-enabled object used as the physics imposter
  79147. */
  79148. object: IPhysicsEnabledObject,
  79149. /**
  79150. * The type of the physics imposter
  79151. */
  79152. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  79153. /**
  79154. * This function will completly initialize this impostor.
  79155. * It will create a new body - but only if this mesh has no parent.
  79156. * If it has, this impostor will not be used other than to define the impostor
  79157. * of the child mesh.
  79158. * @hidden
  79159. */
  79160. _init(): void;
  79161. private _getPhysicsParent;
  79162. /**
  79163. * Should a new body be generated.
  79164. * @returns boolean specifying if body initialization is required
  79165. */
  79166. isBodyInitRequired(): boolean;
  79167. /**
  79168. * Sets the updated scaling
  79169. * @param updated Specifies if the scaling is updated
  79170. */
  79171. setScalingUpdated(): void;
  79172. /**
  79173. * Force a regeneration of this or the parent's impostor's body.
  79174. * Use under cautious - This will remove all joints already implemented.
  79175. */
  79176. forceUpdate(): void;
  79177. /**
  79178. * Gets the body that holds this impostor. Either its own, or its parent.
  79179. */
  79180. /**
  79181. * Set the physics body. Used mainly by the physics engine/plugin
  79182. */
  79183. physicsBody: any;
  79184. /**
  79185. * Get the parent of the physics imposter
  79186. * @returns Physics imposter or null
  79187. */
  79188. /**
  79189. * Sets the parent of the physics imposter
  79190. */
  79191. parent: Nullable<PhysicsImpostor>;
  79192. /**
  79193. * Resets the update flags
  79194. */
  79195. resetUpdateFlags(): void;
  79196. /**
  79197. * Gets the object extend size
  79198. * @returns the object extend size
  79199. */
  79200. getObjectExtendSize(): Vector3;
  79201. /**
  79202. * Gets the object center
  79203. * @returns The object center
  79204. */
  79205. getObjectCenter(): Vector3;
  79206. /**
  79207. * Get a specific parametes from the options parameter
  79208. * @param paramName The object parameter name
  79209. * @returns The object parameter
  79210. */
  79211. getParam(paramName: string): any;
  79212. /**
  79213. * Sets a specific parameter in the options given to the physics plugin
  79214. * @param paramName The parameter name
  79215. * @param value The value of the parameter
  79216. */
  79217. setParam(paramName: string, value: number): void;
  79218. /**
  79219. * Specifically change the body's mass option. Won't recreate the physics body object
  79220. * @param mass The mass of the physics imposter
  79221. */
  79222. setMass(mass: number): void;
  79223. /**
  79224. * Gets the linear velocity
  79225. * @returns linear velocity or null
  79226. */
  79227. getLinearVelocity(): Nullable<Vector3>;
  79228. /**
  79229. * Sets the linear velocity
  79230. * @param velocity linear velocity or null
  79231. */
  79232. setLinearVelocity(velocity: Nullable<Vector3>): void;
  79233. /**
  79234. * Gets the angular velocity
  79235. * @returns angular velocity or null
  79236. */
  79237. getAngularVelocity(): Nullable<Vector3>;
  79238. /**
  79239. * Sets the angular velocity
  79240. * @param velocity The velocity or null
  79241. */
  79242. setAngularVelocity(velocity: Nullable<Vector3>): void;
  79243. /**
  79244. * Execute a function with the physics plugin native code
  79245. * Provide a function the will have two variables - the world object and the physics body object
  79246. * @param func The function to execute with the physics plugin native code
  79247. */
  79248. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  79249. /**
  79250. * Register a function that will be executed before the physics world is stepping forward
  79251. * @param func The function to execute before the physics world is stepped forward
  79252. */
  79253. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79254. /**
  79255. * Unregister a function that will be executed before the physics world is stepping forward
  79256. * @param func The function to execute before the physics world is stepped forward
  79257. */
  79258. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79259. /**
  79260. * Register a function that will be executed after the physics step
  79261. * @param func The function to execute after physics step
  79262. */
  79263. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79264. /**
  79265. * Unregisters a function that will be executed after the physics step
  79266. * @param func The function to execute after physics step
  79267. */
  79268. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79269. /**
  79270. * register a function that will be executed when this impostor collides against a different body
  79271. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  79272. * @param func Callback that is executed on collision
  79273. */
  79274. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  79275. /**
  79276. * Unregisters the physics imposter on contact
  79277. * @param collideAgainst The physics object to collide against
  79278. * @param func Callback to execute on collision
  79279. */
  79280. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  79281. private _tmpQuat;
  79282. private _tmpQuat2;
  79283. /**
  79284. * Get the parent rotation
  79285. * @returns The parent rotation
  79286. */
  79287. getParentsRotation(): Quaternion;
  79288. /**
  79289. * this function is executed by the physics engine.
  79290. */
  79291. beforeStep: () => void;
  79292. /**
  79293. * this function is executed by the physics engine
  79294. */
  79295. afterStep: () => void;
  79296. /**
  79297. * Legacy collision detection event support
  79298. */
  79299. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  79300. /**
  79301. * event and body object due to cannon's event-based architecture.
  79302. */
  79303. onCollide: (e: {
  79304. body: any;
  79305. }) => void;
  79306. /**
  79307. * Apply a force
  79308. * @param force The force to apply
  79309. * @param contactPoint The contact point for the force
  79310. * @returns The physics imposter
  79311. */
  79312. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79313. /**
  79314. * Apply an impulse
  79315. * @param force The impulse force
  79316. * @param contactPoint The contact point for the impulse force
  79317. * @returns The physics imposter
  79318. */
  79319. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79320. /**
  79321. * A help function to create a joint
  79322. * @param otherImpostor A physics imposter used to create a joint
  79323. * @param jointType The type of joint
  79324. * @param jointData The data for the joint
  79325. * @returns The physics imposter
  79326. */
  79327. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  79328. /**
  79329. * Add a joint to this impostor with a different impostor
  79330. * @param otherImpostor A physics imposter used to add a joint
  79331. * @param joint The joint to add
  79332. * @returns The physics imposter
  79333. */
  79334. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  79335. /**
  79336. * Add an anchor to a cloth impostor
  79337. * @param otherImpostor rigid impostor to anchor to
  79338. * @param width ratio across width from 0 to 1
  79339. * @param height ratio up height from 0 to 1
  79340. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  79341. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  79342. * @returns impostor the soft imposter
  79343. */
  79344. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79345. /**
  79346. * Add a hook to a rope impostor
  79347. * @param otherImpostor rigid impostor to anchor to
  79348. * @param length ratio across rope from 0 to 1
  79349. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  79350. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  79351. * @returns impostor the rope imposter
  79352. */
  79353. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79354. /**
  79355. * Will keep this body still, in a sleep mode.
  79356. * @returns the physics imposter
  79357. */
  79358. sleep(): PhysicsImpostor;
  79359. /**
  79360. * Wake the body up.
  79361. * @returns The physics imposter
  79362. */
  79363. wakeUp(): PhysicsImpostor;
  79364. /**
  79365. * Clones the physics imposter
  79366. * @param newObject The physics imposter clones to this physics-enabled object
  79367. * @returns A nullable physics imposter
  79368. */
  79369. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79370. /**
  79371. * Disposes the physics imposter
  79372. */
  79373. dispose(): void;
  79374. /**
  79375. * Sets the delta position
  79376. * @param position The delta position amount
  79377. */
  79378. setDeltaPosition(position: Vector3): void;
  79379. /**
  79380. * Sets the delta rotation
  79381. * @param rotation The delta rotation amount
  79382. */
  79383. setDeltaRotation(rotation: Quaternion): void;
  79384. /**
  79385. * Gets the box size of the physics imposter and stores the result in the input parameter
  79386. * @param result Stores the box size
  79387. * @returns The physics imposter
  79388. */
  79389. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  79390. /**
  79391. * Gets the radius of the physics imposter
  79392. * @returns Radius of the physics imposter
  79393. */
  79394. getRadius(): number;
  79395. /**
  79396. * Sync a bone with this impostor
  79397. * @param bone The bone to sync to the impostor.
  79398. * @param boneMesh The mesh that the bone is influencing.
  79399. * @param jointPivot The pivot of the joint / bone in local space.
  79400. * @param distToJoint Optional distance from the impostor to the joint.
  79401. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79402. */
  79403. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  79404. /**
  79405. * Sync impostor to a bone
  79406. * @param bone The bone that the impostor will be synced to.
  79407. * @param boneMesh The mesh that the bone is influencing.
  79408. * @param jointPivot The pivot of the joint / bone in local space.
  79409. * @param distToJoint Optional distance from the impostor to the joint.
  79410. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79411. * @param boneAxis Optional vector3 axis the bone is aligned with
  79412. */
  79413. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  79414. /**
  79415. * No-Imposter type
  79416. */
  79417. static NoImpostor: number;
  79418. /**
  79419. * Sphere-Imposter type
  79420. */
  79421. static SphereImpostor: number;
  79422. /**
  79423. * Box-Imposter type
  79424. */
  79425. static BoxImpostor: number;
  79426. /**
  79427. * Plane-Imposter type
  79428. */
  79429. static PlaneImpostor: number;
  79430. /**
  79431. * Mesh-imposter type
  79432. */
  79433. static MeshImpostor: number;
  79434. /**
  79435. * Cylinder-Imposter type
  79436. */
  79437. static CylinderImpostor: number;
  79438. /**
  79439. * Particle-Imposter type
  79440. */
  79441. static ParticleImpostor: number;
  79442. /**
  79443. * Heightmap-Imposter type
  79444. */
  79445. static HeightmapImpostor: number;
  79446. /**
  79447. * ConvexHull-Impostor type (Ammo.js plugin only)
  79448. */
  79449. static ConvexHullImpostor: number;
  79450. /**
  79451. * Rope-Imposter type
  79452. */
  79453. static RopeImpostor: number;
  79454. /**
  79455. * Cloth-Imposter type
  79456. */
  79457. static ClothImpostor: number;
  79458. /**
  79459. * Softbody-Imposter type
  79460. */
  79461. static SoftbodyImpostor: number;
  79462. }
  79463. }
  79464. declare module BABYLON {
  79465. /**
  79466. * Class used to represent a specific level of detail of a mesh
  79467. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79468. */
  79469. export class MeshLODLevel {
  79470. /** Defines the distance where this level should star being displayed */
  79471. distance: number;
  79472. /** Defines the mesh to use to render this level */
  79473. mesh: Nullable<Mesh>;
  79474. /**
  79475. * Creates a new LOD level
  79476. * @param distance defines the distance where this level should star being displayed
  79477. * @param mesh defines the mesh to use to render this level
  79478. */
  79479. constructor(
  79480. /** Defines the distance where this level should star being displayed */
  79481. distance: number,
  79482. /** Defines the mesh to use to render this level */
  79483. mesh: Nullable<Mesh>);
  79484. }
  79485. /**
  79486. * @hidden
  79487. **/
  79488. export class _CreationDataStorage {
  79489. closePath?: boolean;
  79490. closeArray?: boolean;
  79491. idx: number[];
  79492. dashSize: number;
  79493. gapSize: number;
  79494. path3D: Path3D;
  79495. pathArray: Vector3[][];
  79496. arc: number;
  79497. radius: number;
  79498. cap: number;
  79499. tessellation: number;
  79500. }
  79501. /**
  79502. * @hidden
  79503. **/
  79504. class _InstanceDataStorage {
  79505. visibleInstances: any;
  79506. renderIdForInstances: number[];
  79507. batchCache: _InstancesBatch;
  79508. instancesBufferSize: number;
  79509. instancesBuffer: Nullable<Buffer>;
  79510. instancesData: Float32Array;
  79511. overridenInstanceCount: number;
  79512. }
  79513. /**
  79514. * @hidden
  79515. **/
  79516. export class _InstancesBatch {
  79517. mustReturn: boolean;
  79518. visibleInstances: Nullable<InstancedMesh[]>[];
  79519. renderSelf: boolean[];
  79520. }
  79521. /**
  79522. * Class used to represent renderable models
  79523. */
  79524. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  79525. /**
  79526. * Mesh side orientation : usually the external or front surface
  79527. */
  79528. static readonly FRONTSIDE: number;
  79529. /**
  79530. * Mesh side orientation : usually the internal or back surface
  79531. */
  79532. static readonly BACKSIDE: number;
  79533. /**
  79534. * Mesh side orientation : both internal and external or front and back surfaces
  79535. */
  79536. static readonly DOUBLESIDE: number;
  79537. /**
  79538. * Mesh side orientation : by default, `FRONTSIDE`
  79539. */
  79540. static readonly DEFAULTSIDE: number;
  79541. /**
  79542. * Mesh cap setting : no cap
  79543. */
  79544. static readonly NO_CAP: number;
  79545. /**
  79546. * Mesh cap setting : one cap at the beginning of the mesh
  79547. */
  79548. static readonly CAP_START: number;
  79549. /**
  79550. * Mesh cap setting : one cap at the end of the mesh
  79551. */
  79552. static readonly CAP_END: number;
  79553. /**
  79554. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  79555. */
  79556. static readonly CAP_ALL: number;
  79557. /**
  79558. * Gets the default side orientation.
  79559. * @param orientation the orientation to value to attempt to get
  79560. * @returns the default orientation
  79561. * @hidden
  79562. */
  79563. static _GetDefaultSideOrientation(orientation?: number): number;
  79564. private _onBeforeRenderObservable;
  79565. private _onBeforeBindObservable;
  79566. private _onAfterRenderObservable;
  79567. private _onBeforeDrawObservable;
  79568. /**
  79569. * An event triggered before rendering the mesh
  79570. */
  79571. readonly onBeforeRenderObservable: Observable<Mesh>;
  79572. /**
  79573. * An event triggered before binding the mesh
  79574. */
  79575. readonly onBeforeBindObservable: Observable<Mesh>;
  79576. /**
  79577. * An event triggered after rendering the mesh
  79578. */
  79579. readonly onAfterRenderObservable: Observable<Mesh>;
  79580. /**
  79581. * An event triggered before drawing the mesh
  79582. */
  79583. readonly onBeforeDrawObservable: Observable<Mesh>;
  79584. private _onBeforeDrawObserver;
  79585. /**
  79586. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  79587. */
  79588. onBeforeDraw: () => void;
  79589. /**
  79590. * Gets the delay loading state of the mesh (when delay loading is turned on)
  79591. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  79592. */
  79593. delayLoadState: number;
  79594. /**
  79595. * Gets the list of instances created from this mesh
  79596. * it is not supposed to be modified manually.
  79597. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  79598. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79599. */
  79600. instances: InstancedMesh[];
  79601. /**
  79602. * Gets the file containing delay loading data for this mesh
  79603. */
  79604. delayLoadingFile: string;
  79605. /** @hidden */
  79606. _binaryInfo: any;
  79607. private _LODLevels;
  79608. /**
  79609. * User defined function used to change how LOD level selection is done
  79610. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79611. */
  79612. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  79613. private _morphTargetManager;
  79614. /**
  79615. * Gets or sets the morph target manager
  79616. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79617. */
  79618. morphTargetManager: Nullable<MorphTargetManager>;
  79619. /** @hidden */
  79620. _creationDataStorage: Nullable<_CreationDataStorage>;
  79621. /** @hidden */
  79622. _geometry: Nullable<Geometry>;
  79623. /** @hidden */
  79624. _delayInfo: Array<string>;
  79625. /** @hidden */
  79626. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  79627. /** @hidden */
  79628. _instanceDataStorage: _InstanceDataStorage;
  79629. private _effectiveMaterial;
  79630. /** @hidden */
  79631. _shouldGenerateFlatShading: boolean;
  79632. private _preActivateId;
  79633. /** @hidden */
  79634. _originalBuilderSideOrientation: number;
  79635. /**
  79636. * Use this property to change the original side orientation defined at construction time
  79637. */
  79638. overrideMaterialSideOrientation: Nullable<number>;
  79639. private _areNormalsFrozen;
  79640. private _sourcePositions;
  79641. private _sourceNormals;
  79642. private _source;
  79643. private meshMap;
  79644. /**
  79645. * Gets the source mesh (the one used to clone this one from)
  79646. */
  79647. readonly source: Nullable<Mesh>;
  79648. /**
  79649. * Gets or sets a boolean indicating that this mesh does not use index buffer
  79650. */
  79651. isUnIndexed: boolean;
  79652. /**
  79653. * @constructor
  79654. * @param name The value used by scene.getMeshByName() to do a lookup.
  79655. * @param scene The scene to add this mesh to.
  79656. * @param parent The parent of this mesh, if it has one
  79657. * @param source An optional Mesh from which geometry is shared, cloned.
  79658. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79659. * When false, achieved by calling a clone(), also passing False.
  79660. * This will make creation of children, recursive.
  79661. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  79662. */
  79663. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  79664. /**
  79665. * Gets the class name
  79666. * @returns the string "Mesh".
  79667. */
  79668. getClassName(): string;
  79669. /** @hidden */
  79670. readonly _isMesh: boolean;
  79671. /**
  79672. * Returns a description of this mesh
  79673. * @param fullDetails define if full details about this mesh must be used
  79674. * @returns a descriptive string representing this mesh
  79675. */
  79676. toString(fullDetails?: boolean): string;
  79677. /** @hidden */
  79678. _unBindEffect(): void;
  79679. /**
  79680. * Gets a boolean indicating if this mesh has LOD
  79681. */
  79682. readonly hasLODLevels: boolean;
  79683. /**
  79684. * Gets the list of MeshLODLevel associated with the current mesh
  79685. * @returns an array of MeshLODLevel
  79686. */
  79687. getLODLevels(): MeshLODLevel[];
  79688. private _sortLODLevels;
  79689. /**
  79690. * Add a mesh as LOD level triggered at the given distance.
  79691. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79692. * @param distance The distance from the center of the object to show this level
  79693. * @param mesh The mesh to be added as LOD level (can be null)
  79694. * @return This mesh (for chaining)
  79695. */
  79696. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  79697. /**
  79698. * Returns the LOD level mesh at the passed distance or null if not found.
  79699. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79700. * @param distance The distance from the center of the object to show this level
  79701. * @returns a Mesh or `null`
  79702. */
  79703. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  79704. /**
  79705. * Remove a mesh from the LOD array
  79706. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79707. * @param mesh defines the mesh to be removed
  79708. * @return This mesh (for chaining)
  79709. */
  79710. removeLODLevel(mesh: Mesh): Mesh;
  79711. /**
  79712. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  79713. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79714. * @param camera defines the camera to use to compute distance
  79715. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  79716. * @return This mesh (for chaining)
  79717. */
  79718. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  79719. /**
  79720. * Gets the mesh internal Geometry object
  79721. */
  79722. readonly geometry: Nullable<Geometry>;
  79723. /**
  79724. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  79725. * @returns the total number of vertices
  79726. */
  79727. getTotalVertices(): number;
  79728. /**
  79729. * Returns the content of an associated vertex buffer
  79730. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79731. * - VertexBuffer.PositionKind
  79732. * - VertexBuffer.UVKind
  79733. * - VertexBuffer.UV2Kind
  79734. * - VertexBuffer.UV3Kind
  79735. * - VertexBuffer.UV4Kind
  79736. * - VertexBuffer.UV5Kind
  79737. * - VertexBuffer.UV6Kind
  79738. * - VertexBuffer.ColorKind
  79739. * - VertexBuffer.MatricesIndicesKind
  79740. * - VertexBuffer.MatricesIndicesExtraKind
  79741. * - VertexBuffer.MatricesWeightsKind
  79742. * - VertexBuffer.MatricesWeightsExtraKind
  79743. * @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
  79744. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  79745. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  79746. */
  79747. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79748. /**
  79749. * Returns the mesh VertexBuffer object from the requested `kind`
  79750. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79751. * - VertexBuffer.PositionKind
  79752. * - VertexBuffer.UVKind
  79753. * - VertexBuffer.UV2Kind
  79754. * - VertexBuffer.UV3Kind
  79755. * - VertexBuffer.UV4Kind
  79756. * - VertexBuffer.UV5Kind
  79757. * - VertexBuffer.UV6Kind
  79758. * - VertexBuffer.ColorKind
  79759. * - VertexBuffer.MatricesIndicesKind
  79760. * - VertexBuffer.MatricesIndicesExtraKind
  79761. * - VertexBuffer.MatricesWeightsKind
  79762. * - VertexBuffer.MatricesWeightsExtraKind
  79763. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  79764. */
  79765. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79766. /**
  79767. * Tests if a specific vertex buffer is associated with this mesh
  79768. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79769. * - VertexBuffer.PositionKind
  79770. * - VertexBuffer.UVKind
  79771. * - VertexBuffer.UV2Kind
  79772. * - VertexBuffer.UV3Kind
  79773. * - VertexBuffer.UV4Kind
  79774. * - VertexBuffer.UV5Kind
  79775. * - VertexBuffer.UV6Kind
  79776. * - VertexBuffer.ColorKind
  79777. * - VertexBuffer.MatricesIndicesKind
  79778. * - VertexBuffer.MatricesIndicesExtraKind
  79779. * - VertexBuffer.MatricesWeightsKind
  79780. * - VertexBuffer.MatricesWeightsExtraKind
  79781. * @returns a boolean
  79782. */
  79783. isVerticesDataPresent(kind: string): boolean;
  79784. /**
  79785. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  79786. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79787. * - VertexBuffer.PositionKind
  79788. * - VertexBuffer.UVKind
  79789. * - VertexBuffer.UV2Kind
  79790. * - VertexBuffer.UV3Kind
  79791. * - VertexBuffer.UV4Kind
  79792. * - VertexBuffer.UV5Kind
  79793. * - VertexBuffer.UV6Kind
  79794. * - VertexBuffer.ColorKind
  79795. * - VertexBuffer.MatricesIndicesKind
  79796. * - VertexBuffer.MatricesIndicesExtraKind
  79797. * - VertexBuffer.MatricesWeightsKind
  79798. * - VertexBuffer.MatricesWeightsExtraKind
  79799. * @returns a boolean
  79800. */
  79801. isVertexBufferUpdatable(kind: string): boolean;
  79802. /**
  79803. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  79804. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79805. * - VertexBuffer.PositionKind
  79806. * - VertexBuffer.UVKind
  79807. * - VertexBuffer.UV2Kind
  79808. * - VertexBuffer.UV3Kind
  79809. * - VertexBuffer.UV4Kind
  79810. * - VertexBuffer.UV5Kind
  79811. * - VertexBuffer.UV6Kind
  79812. * - VertexBuffer.ColorKind
  79813. * - VertexBuffer.MatricesIndicesKind
  79814. * - VertexBuffer.MatricesIndicesExtraKind
  79815. * - VertexBuffer.MatricesWeightsKind
  79816. * - VertexBuffer.MatricesWeightsExtraKind
  79817. * @returns an array of strings
  79818. */
  79819. getVerticesDataKinds(): string[];
  79820. /**
  79821. * Returns a positive integer : the total number of indices in this mesh geometry.
  79822. * @returns the numner of indices or zero if the mesh has no geometry.
  79823. */
  79824. getTotalIndices(): number;
  79825. /**
  79826. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79827. * @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.
  79828. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79829. * @returns the indices array or an empty array if the mesh has no geometry
  79830. */
  79831. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79832. readonly isBlocked: boolean;
  79833. /**
  79834. * Determine if the current mesh is ready to be rendered
  79835. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79836. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  79837. * @returns true if all associated assets are ready (material, textures, shaders)
  79838. */
  79839. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  79840. /**
  79841. * 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.
  79842. */
  79843. readonly areNormalsFrozen: boolean;
  79844. /**
  79845. * 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.
  79846. * @returns the current mesh
  79847. */
  79848. freezeNormals(): Mesh;
  79849. /**
  79850. * 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
  79851. * @returns the current mesh
  79852. */
  79853. unfreezeNormals(): Mesh;
  79854. /**
  79855. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  79856. */
  79857. overridenInstanceCount: number;
  79858. /** @hidden */
  79859. _preActivate(): Mesh;
  79860. /** @hidden */
  79861. _preActivateForIntermediateRendering(renderId: number): Mesh;
  79862. /** @hidden */
  79863. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  79864. /**
  79865. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79866. * This means the mesh underlying bounding box and sphere are recomputed.
  79867. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79868. * @returns the current mesh
  79869. */
  79870. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  79871. /** @hidden */
  79872. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  79873. /**
  79874. * This function will subdivide the mesh into multiple submeshes
  79875. * @param count defines the expected number of submeshes
  79876. */
  79877. subdivide(count: number): void;
  79878. /**
  79879. * Copy a FloatArray into a specific associated vertex buffer
  79880. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79881. * - VertexBuffer.PositionKind
  79882. * - VertexBuffer.UVKind
  79883. * - VertexBuffer.UV2Kind
  79884. * - VertexBuffer.UV3Kind
  79885. * - VertexBuffer.UV4Kind
  79886. * - VertexBuffer.UV5Kind
  79887. * - VertexBuffer.UV6Kind
  79888. * - VertexBuffer.ColorKind
  79889. * - VertexBuffer.MatricesIndicesKind
  79890. * - VertexBuffer.MatricesIndicesExtraKind
  79891. * - VertexBuffer.MatricesWeightsKind
  79892. * - VertexBuffer.MatricesWeightsExtraKind
  79893. * @param data defines the data source
  79894. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79895. * @param stride defines the data stride size (can be null)
  79896. * @returns the current mesh
  79897. */
  79898. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  79899. /**
  79900. * Flags an associated vertex buffer as updatable
  79901. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  79902. * - VertexBuffer.PositionKind
  79903. * - VertexBuffer.UVKind
  79904. * - VertexBuffer.UV2Kind
  79905. * - VertexBuffer.UV3Kind
  79906. * - VertexBuffer.UV4Kind
  79907. * - VertexBuffer.UV5Kind
  79908. * - VertexBuffer.UV6Kind
  79909. * - VertexBuffer.ColorKind
  79910. * - VertexBuffer.MatricesIndicesKind
  79911. * - VertexBuffer.MatricesIndicesExtraKind
  79912. * - VertexBuffer.MatricesWeightsKind
  79913. * - VertexBuffer.MatricesWeightsExtraKind
  79914. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79915. */
  79916. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  79917. /**
  79918. * Sets the mesh global Vertex Buffer
  79919. * @param buffer defines the buffer to use
  79920. * @returns the current mesh
  79921. */
  79922. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  79923. /**
  79924. * Update a specific associated vertex buffer
  79925. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79926. * - VertexBuffer.PositionKind
  79927. * - VertexBuffer.UVKind
  79928. * - VertexBuffer.UV2Kind
  79929. * - VertexBuffer.UV3Kind
  79930. * - VertexBuffer.UV4Kind
  79931. * - VertexBuffer.UV5Kind
  79932. * - VertexBuffer.UV6Kind
  79933. * - VertexBuffer.ColorKind
  79934. * - VertexBuffer.MatricesIndicesKind
  79935. * - VertexBuffer.MatricesIndicesExtraKind
  79936. * - VertexBuffer.MatricesWeightsKind
  79937. * - VertexBuffer.MatricesWeightsExtraKind
  79938. * @param data defines the data source
  79939. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79940. * @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)
  79941. * @returns the current mesh
  79942. */
  79943. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79944. /**
  79945. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  79946. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  79947. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  79948. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  79949. * @returns the current mesh
  79950. */
  79951. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  79952. /**
  79953. * Creates a un-shared specific occurence of the geometry for the mesh.
  79954. * @returns the current mesh
  79955. */
  79956. makeGeometryUnique(): Mesh;
  79957. /**
  79958. * Set the index buffer of this mesh
  79959. * @param indices defines the source data
  79960. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  79961. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  79962. * @returns the current mesh
  79963. */
  79964. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  79965. /**
  79966. * Update the current index buffer
  79967. * @param indices defines the source data
  79968. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  79969. * @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)
  79970. * @returns the current mesh
  79971. */
  79972. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  79973. /**
  79974. * Invert the geometry to move from a right handed system to a left handed one.
  79975. * @returns the current mesh
  79976. */
  79977. toLeftHanded(): Mesh;
  79978. /** @hidden */
  79979. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  79980. /** @hidden */
  79981. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  79982. /**
  79983. * Registers for this mesh a javascript function called just before the rendering process
  79984. * @param func defines the function to call before rendering this mesh
  79985. * @returns the current mesh
  79986. */
  79987. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79988. /**
  79989. * Disposes a previously registered javascript function called before the rendering
  79990. * @param func defines the function to remove
  79991. * @returns the current mesh
  79992. */
  79993. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79994. /**
  79995. * Registers for this mesh a javascript function called just after the rendering is complete
  79996. * @param func defines the function to call after rendering this mesh
  79997. * @returns the current mesh
  79998. */
  79999. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80000. /**
  80001. * Disposes a previously registered javascript function called after the rendering.
  80002. * @param func defines the function to remove
  80003. * @returns the current mesh
  80004. */
  80005. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80006. /** @hidden */
  80007. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  80008. /** @hidden */
  80009. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  80010. /** @hidden */
  80011. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  80012. /**
  80013. * 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
  80014. * @param subMesh defines the subMesh to render
  80015. * @param enableAlphaMode defines if alpha mode can be changed
  80016. * @returns the current mesh
  80017. */
  80018. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  80019. private _onBeforeDraw;
  80020. /**
  80021. * Renormalize the mesh and patch it up if there are no weights
  80022. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  80023. * However in the case of zero weights then we set just a single influence to 1.
  80024. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  80025. */
  80026. cleanMatrixWeights(): void;
  80027. private normalizeSkinFourWeights;
  80028. private normalizeSkinWeightsAndExtra;
  80029. /**
  80030. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  80031. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  80032. * the user know there was an issue with importing the mesh
  80033. * @returns a validation object with skinned, valid and report string
  80034. */
  80035. validateSkinning(): {
  80036. skinned: boolean;
  80037. valid: boolean;
  80038. report: string;
  80039. };
  80040. /** @hidden */
  80041. _checkDelayState(): Mesh;
  80042. private _queueLoad;
  80043. /**
  80044. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80045. * A mesh is in the frustum if its bounding box intersects the frustum
  80046. * @param frustumPlanes defines the frustum to test
  80047. * @returns true if the mesh is in the frustum planes
  80048. */
  80049. isInFrustum(frustumPlanes: Plane[]): boolean;
  80050. /**
  80051. * Sets the mesh material by the material or multiMaterial `id` property
  80052. * @param id is a string identifying the material or the multiMaterial
  80053. * @returns the current mesh
  80054. */
  80055. setMaterialByID(id: string): Mesh;
  80056. /**
  80057. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  80058. * @returns an array of IAnimatable
  80059. */
  80060. getAnimatables(): IAnimatable[];
  80061. /**
  80062. * Modifies the mesh geometry according to the passed transformation matrix.
  80063. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  80064. * The mesh normals are modified using the same transformation.
  80065. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80066. * @param transform defines the transform matrix to use
  80067. * @see http://doc.babylonjs.com/resources/baking_transformations
  80068. * @returns the current mesh
  80069. */
  80070. bakeTransformIntoVertices(transform: Matrix): Mesh;
  80071. /**
  80072. * Modifies the mesh geometry according to its own current World Matrix.
  80073. * The mesh World Matrix is then reset.
  80074. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  80075. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80076. * @see http://doc.babylonjs.com/resources/baking_transformations
  80077. * @returns the current mesh
  80078. */
  80079. bakeCurrentTransformIntoVertices(): Mesh;
  80080. /** @hidden */
  80081. readonly _positions: Nullable<Vector3[]>;
  80082. /** @hidden */
  80083. _resetPointsArrayCache(): Mesh;
  80084. /** @hidden */
  80085. _generatePointsArray(): boolean;
  80086. /**
  80087. * Returns a new Mesh object generated from the current mesh properties.
  80088. * This method must not get confused with createInstance()
  80089. * @param name is a string, the name given to the new mesh
  80090. * @param newParent can be any Node object (default `null`)
  80091. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  80092. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  80093. * @returns a new mesh
  80094. */
  80095. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  80096. /**
  80097. * Releases resources associated with this mesh.
  80098. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80099. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80100. */
  80101. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80102. /**
  80103. * Modifies the mesh geometry according to a displacement map.
  80104. * 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.
  80105. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80106. * @param url is a string, the URL from the image file is to be downloaded.
  80107. * @param minHeight is the lower limit of the displacement.
  80108. * @param maxHeight is the upper limit of the displacement.
  80109. * @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.
  80110. * @param uvOffset is an optional vector2 used to offset UV.
  80111. * @param uvScale is an optional vector2 used to scale UV.
  80112. * @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.
  80113. * @returns the Mesh.
  80114. */
  80115. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80116. /**
  80117. * Modifies the mesh geometry according to a displacementMap buffer.
  80118. * 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.
  80119. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80120. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  80121. * @param heightMapWidth is the width of the buffer image.
  80122. * @param heightMapHeight is the height of the buffer image.
  80123. * @param minHeight is the lower limit of the displacement.
  80124. * @param maxHeight is the upper limit of the displacement.
  80125. * @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.
  80126. * @param uvOffset is an optional vector2 used to offset UV.
  80127. * @param uvScale is an optional vector2 used to scale UV.
  80128. * @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.
  80129. * @returns the Mesh.
  80130. */
  80131. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80132. /**
  80133. * Modify the mesh to get a flat shading rendering.
  80134. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  80135. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  80136. * @returns current mesh
  80137. */
  80138. convertToFlatShadedMesh(): Mesh;
  80139. /**
  80140. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  80141. * In other words, more vertices, no more indices and a single bigger VBO.
  80142. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  80143. * @returns current mesh
  80144. */
  80145. convertToUnIndexedMesh(): Mesh;
  80146. /**
  80147. * Inverses facet orientations.
  80148. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80149. * @param flipNormals will also inverts the normals
  80150. * @returns current mesh
  80151. */
  80152. flipFaces(flipNormals?: boolean): Mesh;
  80153. /**
  80154. * Increase the number of facets and hence vertices in a mesh
  80155. * Vertex normals are interpolated from existing vertex normals
  80156. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80157. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  80158. */
  80159. increaseVertices(numberPerEdge: number): void;
  80160. /**
  80161. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  80162. * This will undo any application of covertToFlatShadedMesh
  80163. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80164. */
  80165. forceSharedVertices(): void;
  80166. /** @hidden */
  80167. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  80168. /** @hidden */
  80169. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  80170. /**
  80171. * Creates a new InstancedMesh object from the mesh model.
  80172. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80173. * @param name defines the name of the new instance
  80174. * @returns a new InstancedMesh
  80175. */
  80176. createInstance(name: string): InstancedMesh;
  80177. /**
  80178. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  80179. * After this call, all the mesh instances have the same submeshes than the current mesh.
  80180. * @returns the current mesh
  80181. */
  80182. synchronizeInstances(): Mesh;
  80183. /**
  80184. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  80185. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  80186. * This should be used together with the simplification to avoid disappearing triangles.
  80187. * @param successCallback an optional success callback to be called after the optimization finished.
  80188. * @returns the current mesh
  80189. */
  80190. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  80191. /**
  80192. * Serialize current mesh
  80193. * @param serializationObject defines the object which will receive the serialization data
  80194. */
  80195. serialize(serializationObject: any): void;
  80196. /** @hidden */
  80197. _syncGeometryWithMorphTargetManager(): void;
  80198. /** @hidden */
  80199. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  80200. /**
  80201. * Returns a new Mesh object parsed from the source provided.
  80202. * @param parsedMesh is the source
  80203. * @param scene defines the hosting scene
  80204. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  80205. * @returns a new Mesh
  80206. */
  80207. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  80208. /**
  80209. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  80210. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80211. * @param name defines the name of the mesh to create
  80212. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  80213. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  80214. * @param closePath creates a seam between the first and the last points of each path of the path array
  80215. * @param offset is taken in account only if the `pathArray` is containing a single path
  80216. * @param scene defines the hosting scene
  80217. * @param updatable defines if the mesh must be flagged as updatable
  80218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80219. * @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)
  80220. * @returns a new Mesh
  80221. */
  80222. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80223. /**
  80224. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  80225. * @param name defines the name of the mesh to create
  80226. * @param radius sets the radius size (float) of the polygon (default 0.5)
  80227. * @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
  80228. * @param scene defines the hosting scene
  80229. * @param updatable defines if the mesh must be flagged as updatable
  80230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80231. * @returns a new Mesh
  80232. */
  80233. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80234. /**
  80235. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  80236. * @param name defines the name of the mesh to create
  80237. * @param size sets the size (float) of each box side (default 1)
  80238. * @param scene defines the hosting scene
  80239. * @param updatable defines if the mesh must be flagged as updatable
  80240. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80241. * @returns a new Mesh
  80242. */
  80243. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80244. /**
  80245. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  80246. * @param name defines the name of the mesh to create
  80247. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80248. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80249. * @param scene defines the hosting scene
  80250. * @param updatable defines if the mesh must be flagged as updatable
  80251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80252. * @returns a new Mesh
  80253. */
  80254. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80255. /**
  80256. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  80257. * @param name defines the name of the mesh to create
  80258. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80259. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80260. * @param scene defines the hosting scene
  80261. * @returns a new Mesh
  80262. */
  80263. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  80264. /**
  80265. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  80266. * @param name defines the name of the mesh to create
  80267. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  80268. * @param diameterTop set the top cap diameter (floats, default 1)
  80269. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  80270. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  80271. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  80272. * @param scene defines the hosting scene
  80273. * @param updatable defines if the mesh must be flagged as updatable
  80274. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80275. * @returns a new Mesh
  80276. */
  80277. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  80278. /**
  80279. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  80280. * @param name defines the name of the mesh to create
  80281. * @param diameter sets the diameter size (float) of the torus (default 1)
  80282. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  80283. * @param tessellation sets the number of torus sides (postive integer, default 16)
  80284. * @param scene defines the hosting scene
  80285. * @param updatable defines if the mesh must be flagged as updatable
  80286. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80287. * @returns a new Mesh
  80288. */
  80289. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80290. /**
  80291. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  80292. * @param name defines the name of the mesh to create
  80293. * @param radius sets the global radius size (float) of the torus knot (default 2)
  80294. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  80295. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  80296. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  80297. * @param p the number of windings on X axis (positive integers, default 2)
  80298. * @param q the number of windings on Y axis (positive integers, default 3)
  80299. * @param scene defines the hosting scene
  80300. * @param updatable defines if the mesh must be flagged as updatable
  80301. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80302. * @returns a new Mesh
  80303. */
  80304. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80305. /**
  80306. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  80307. * @param name defines the name of the mesh to create
  80308. * @param points is an array successive Vector3
  80309. * @param scene defines the hosting scene
  80310. * @param updatable defines if the mesh must be flagged as updatable
  80311. * @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).
  80312. * @returns a new Mesh
  80313. */
  80314. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  80315. /**
  80316. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  80317. * @param name defines the name of the mesh to create
  80318. * @param points is an array successive Vector3
  80319. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  80320. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  80321. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  80322. * @param scene defines the hosting scene
  80323. * @param updatable defines if the mesh must be flagged as updatable
  80324. * @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)
  80325. * @returns a new Mesh
  80326. */
  80327. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  80328. /**
  80329. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  80330. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  80331. * 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.
  80332. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80333. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80334. * Remember you can only change the shape positions, not their number when updating a polygon.
  80335. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  80336. * @param name defines the name of the mesh to create
  80337. * @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
  80338. * @param scene defines the hosting scene
  80339. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80340. * @param updatable defines if the mesh must be flagged as updatable
  80341. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80342. * @param earcutInjection can be used to inject your own earcut reference
  80343. * @returns a new Mesh
  80344. */
  80345. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80346. /**
  80347. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  80348. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  80349. * @param name defines the name of the mesh to create
  80350. * @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
  80351. * @param depth defines the height of extrusion
  80352. * @param scene defines the hosting scene
  80353. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80354. * @param updatable defines if the mesh must be flagged as updatable
  80355. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80356. * @param earcutInjection can be used to inject your own earcut reference
  80357. * @returns a new Mesh
  80358. */
  80359. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80360. /**
  80361. * Creates an extruded shape mesh.
  80362. * 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
  80363. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80364. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80365. * @param name defines the name of the mesh to create
  80366. * @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
  80367. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80368. * @param scale is the value to scale the shape
  80369. * @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
  80370. * @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
  80371. * @param scene defines the hosting scene
  80372. * @param updatable defines if the mesh must be flagged as updatable
  80373. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80374. * @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)
  80375. * @returns a new Mesh
  80376. */
  80377. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80378. /**
  80379. * Creates an custom extruded shape mesh.
  80380. * The custom extrusion is a parametric shape.
  80381. * It has no predefined shape. Its final shape will depend on the input parameters.
  80382. * Please consider using the same method from the MeshBuilder class instead
  80383. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80384. * @param name defines the name of the mesh to create
  80385. * @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
  80386. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80387. * @param scaleFunction is a custom Javascript function called on each path point
  80388. * @param rotationFunction is a custom Javascript function called on each path point
  80389. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  80390. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  80391. * @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
  80392. * @param scene defines the hosting scene
  80393. * @param updatable defines if the mesh must be flagged as updatable
  80394. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80395. * @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)
  80396. * @returns a new Mesh
  80397. */
  80398. 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;
  80399. /**
  80400. * Creates lathe mesh.
  80401. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  80402. * Please consider using the same method from the MeshBuilder class instead
  80403. * @param name defines the name of the mesh to create
  80404. * @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
  80405. * @param radius is the radius value of the lathe
  80406. * @param tessellation is the side number of the lathe.
  80407. * @param scene defines the hosting scene
  80408. * @param updatable defines if the mesh must be flagged as updatable
  80409. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80410. * @returns a new Mesh
  80411. */
  80412. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80413. /**
  80414. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  80415. * @param name defines the name of the mesh to create
  80416. * @param size sets the size (float) of both sides of the plane at once (default 1)
  80417. * @param scene defines the hosting scene
  80418. * @param updatable defines if the mesh must be flagged as updatable
  80419. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80420. * @returns a new Mesh
  80421. */
  80422. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80423. /**
  80424. * Creates a ground mesh.
  80425. * Please consider using the same method from the MeshBuilder class instead
  80426. * @param name defines the name of the mesh to create
  80427. * @param width set the width of the ground
  80428. * @param height set the height of the ground
  80429. * @param subdivisions sets the number of subdivisions per side
  80430. * @param scene defines the hosting scene
  80431. * @param updatable defines if the mesh must be flagged as updatable
  80432. * @returns a new Mesh
  80433. */
  80434. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  80435. /**
  80436. * Creates a tiled ground mesh.
  80437. * Please consider using the same method from the MeshBuilder class instead
  80438. * @param name defines the name of the mesh to create
  80439. * @param xmin set the ground minimum X coordinate
  80440. * @param zmin set the ground minimum Y coordinate
  80441. * @param xmax set the ground maximum X coordinate
  80442. * @param zmax set the ground maximum Z coordinate
  80443. * @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
  80444. * @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
  80445. * @param scene defines the hosting scene
  80446. * @param updatable defines if the mesh must be flagged as updatable
  80447. * @returns a new Mesh
  80448. */
  80449. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  80450. w: number;
  80451. h: number;
  80452. }, precision: {
  80453. w: number;
  80454. h: number;
  80455. }, scene: Scene, updatable?: boolean): Mesh;
  80456. /**
  80457. * Creates a ground mesh from a height map.
  80458. * Please consider using the same method from the MeshBuilder class instead
  80459. * @see http://doc.babylonjs.com/babylon101/height_map
  80460. * @param name defines the name of the mesh to create
  80461. * @param url sets the URL of the height map image resource
  80462. * @param width set the ground width size
  80463. * @param height set the ground height size
  80464. * @param subdivisions sets the number of subdivision per side
  80465. * @param minHeight is the minimum altitude on the ground
  80466. * @param maxHeight is the maximum altitude on the ground
  80467. * @param scene defines the hosting scene
  80468. * @param updatable defines if the mesh must be flagged as updatable
  80469. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  80470. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  80471. * @returns a new Mesh
  80472. */
  80473. 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;
  80474. /**
  80475. * Creates a tube mesh.
  80476. * The tube is a parametric shape.
  80477. * It has no predefined shape. Its final shape will depend on the input parameters.
  80478. * Please consider using the same method from the MeshBuilder class instead
  80479. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80480. * @param name defines the name of the mesh to create
  80481. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  80482. * @param radius sets the tube radius size
  80483. * @param tessellation is the number of sides on the tubular surface
  80484. * @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
  80485. * @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
  80486. * @param scene defines the hosting scene
  80487. * @param updatable defines if the mesh must be flagged as updatable
  80488. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80489. * @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)
  80490. * @returns a new Mesh
  80491. */
  80492. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  80493. (i: number, distance: number): number;
  80494. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80495. /**
  80496. * Creates a polyhedron mesh.
  80497. * Please consider using the same method from the MeshBuilder class instead.
  80498. * * 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
  80499. * * The parameter `size` (positive float, default 1) sets the polygon size
  80500. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80501. * * 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`
  80502. * * 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
  80503. * * 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)`)
  80504. * * 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
  80505. * * 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
  80506. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80507. * * If you create a double-sided mesh, you can choose what parts of 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
  80508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80509. * @param name defines the name of the mesh to create
  80510. * @param options defines the options used to create the mesh
  80511. * @param scene defines the hosting scene
  80512. * @returns a new Mesh
  80513. */
  80514. static CreatePolyhedron(name: string, options: {
  80515. type?: number;
  80516. size?: number;
  80517. sizeX?: number;
  80518. sizeY?: number;
  80519. sizeZ?: number;
  80520. custom?: any;
  80521. faceUV?: Vector4[];
  80522. faceColors?: Color4[];
  80523. updatable?: boolean;
  80524. sideOrientation?: number;
  80525. }, scene: Scene): Mesh;
  80526. /**
  80527. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  80528. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  80529. * * 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`)
  80530. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  80531. * * 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
  80532. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80533. * * If you create a double-sided mesh, you can choose what parts of 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
  80534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80535. * @param name defines the name of the mesh
  80536. * @param options defines the options used to create the mesh
  80537. * @param scene defines the hosting scene
  80538. * @returns a new Mesh
  80539. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  80540. */
  80541. static CreateIcoSphere(name: string, options: {
  80542. radius?: number;
  80543. flat?: boolean;
  80544. subdivisions?: number;
  80545. sideOrientation?: number;
  80546. updatable?: boolean;
  80547. }, scene: Scene): Mesh;
  80548. /**
  80549. * Creates a decal mesh.
  80550. * Please consider using the same method from the MeshBuilder class instead.
  80551. * A decal is a mesh usually applied as a model onto the surface of another mesh
  80552. * @param name defines the name of the mesh
  80553. * @param sourceMesh defines the mesh receiving the decal
  80554. * @param position sets the position of the decal in world coordinates
  80555. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  80556. * @param size sets the decal scaling
  80557. * @param angle sets the angle to rotate the decal
  80558. * @returns a new Mesh
  80559. */
  80560. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  80561. /**
  80562. * Prepare internal position array for software CPU skinning
  80563. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  80564. */
  80565. setPositionsForCPUSkinning(): Float32Array;
  80566. /**
  80567. * Prepare internal normal array for software CPU skinning
  80568. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  80569. */
  80570. setNormalsForCPUSkinning(): Float32Array;
  80571. /**
  80572. * Updates the vertex buffer by applying transformation from the bones
  80573. * @param skeleton defines the skeleton to apply to current mesh
  80574. * @returns the current mesh
  80575. */
  80576. applySkeleton(skeleton: Skeleton): Mesh;
  80577. /**
  80578. * 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
  80579. * @param meshes defines the list of meshes to scan
  80580. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  80581. */
  80582. static MinMax(meshes: AbstractMesh[]): {
  80583. min: Vector3;
  80584. max: Vector3;
  80585. };
  80586. /**
  80587. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  80588. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  80589. * @returns a vector3
  80590. */
  80591. static Center(meshesOrMinMaxVector: {
  80592. min: Vector3;
  80593. max: Vector3;
  80594. } | AbstractMesh[]): Vector3;
  80595. /**
  80596. * Merge the array of meshes into a single mesh for performance reasons.
  80597. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  80598. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  80599. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  80600. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  80601. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  80602. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  80603. * @returns a new mesh
  80604. */
  80605. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  80606. /** @hidden */
  80607. addInstance(instance: InstancedMesh): void;
  80608. /** @hidden */
  80609. removeInstance(instance: InstancedMesh): void;
  80610. }
  80611. }
  80612. declare module BABYLON {
  80613. /**
  80614. * Base class for the main features of a material in Babylon.js
  80615. */
  80616. export class Material implements IAnimatable {
  80617. /**
  80618. * Returns the triangle fill mode
  80619. */
  80620. static readonly TriangleFillMode: number;
  80621. /**
  80622. * Returns the wireframe mode
  80623. */
  80624. static readonly WireFrameFillMode: number;
  80625. /**
  80626. * Returns the point fill mode
  80627. */
  80628. static readonly PointFillMode: number;
  80629. /**
  80630. * Returns the point list draw mode
  80631. */
  80632. static readonly PointListDrawMode: number;
  80633. /**
  80634. * Returns the line list draw mode
  80635. */
  80636. static readonly LineListDrawMode: number;
  80637. /**
  80638. * Returns the line loop draw mode
  80639. */
  80640. static readonly LineLoopDrawMode: number;
  80641. /**
  80642. * Returns the line strip draw mode
  80643. */
  80644. static readonly LineStripDrawMode: number;
  80645. /**
  80646. * Returns the triangle strip draw mode
  80647. */
  80648. static readonly TriangleStripDrawMode: number;
  80649. /**
  80650. * Returns the triangle fan draw mode
  80651. */
  80652. static readonly TriangleFanDrawMode: number;
  80653. /**
  80654. * Stores the clock-wise side orientation
  80655. */
  80656. static readonly ClockWiseSideOrientation: number;
  80657. /**
  80658. * Stores the counter clock-wise side orientation
  80659. */
  80660. static readonly CounterClockWiseSideOrientation: number;
  80661. /**
  80662. * The dirty texture flag value
  80663. */
  80664. static readonly TextureDirtyFlag: number;
  80665. /**
  80666. * The dirty light flag value
  80667. */
  80668. static readonly LightDirtyFlag: number;
  80669. /**
  80670. * The dirty fresnel flag value
  80671. */
  80672. static readonly FresnelDirtyFlag: number;
  80673. /**
  80674. * The dirty attribute flag value
  80675. */
  80676. static readonly AttributesDirtyFlag: number;
  80677. /**
  80678. * The dirty misc flag value
  80679. */
  80680. static readonly MiscDirtyFlag: number;
  80681. /**
  80682. * The all dirty flag value
  80683. */
  80684. static readonly AllDirtyFlag: number;
  80685. /**
  80686. * The ID of the material
  80687. */
  80688. id: string;
  80689. /**
  80690. * Gets or sets the unique id of the material
  80691. */
  80692. uniqueId: number;
  80693. /**
  80694. * The name of the material
  80695. */
  80696. name: string;
  80697. /**
  80698. * Gets or sets user defined metadata
  80699. */
  80700. metadata: any;
  80701. /**
  80702. * For internal use only. Please do not use.
  80703. */
  80704. reservedDataStore: any;
  80705. /**
  80706. * Specifies if the ready state should be checked on each call
  80707. */
  80708. checkReadyOnEveryCall: boolean;
  80709. /**
  80710. * Specifies if the ready state should be checked once
  80711. */
  80712. checkReadyOnlyOnce: boolean;
  80713. /**
  80714. * The state of the material
  80715. */
  80716. state: string;
  80717. /**
  80718. * The alpha value of the material
  80719. */
  80720. protected _alpha: number;
  80721. /**
  80722. * List of inspectable custom properties (used by the Inspector)
  80723. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80724. */
  80725. inspectableCustomProperties: IInspectable[];
  80726. /**
  80727. * Sets the alpha value of the material
  80728. */
  80729. /**
  80730. * Gets the alpha value of the material
  80731. */
  80732. alpha: number;
  80733. /**
  80734. * Specifies if back face culling is enabled
  80735. */
  80736. protected _backFaceCulling: boolean;
  80737. /**
  80738. * Sets the back-face culling state
  80739. */
  80740. /**
  80741. * Gets the back-face culling state
  80742. */
  80743. backFaceCulling: boolean;
  80744. /**
  80745. * Stores the value for side orientation
  80746. */
  80747. sideOrientation: number;
  80748. /**
  80749. * Callback triggered when the material is compiled
  80750. */
  80751. onCompiled: (effect: Effect) => void;
  80752. /**
  80753. * Callback triggered when an error occurs
  80754. */
  80755. onError: (effect: Effect, errors: string) => void;
  80756. /**
  80757. * Callback triggered to get the render target textures
  80758. */
  80759. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  80760. /**
  80761. * Gets a boolean indicating that current material needs to register RTT
  80762. */
  80763. readonly hasRenderTargetTextures: boolean;
  80764. /**
  80765. * Specifies if the material should be serialized
  80766. */
  80767. doNotSerialize: boolean;
  80768. /**
  80769. * @hidden
  80770. */
  80771. _storeEffectOnSubMeshes: boolean;
  80772. /**
  80773. * Stores the animations for the material
  80774. */
  80775. animations: Array<Animation>;
  80776. /**
  80777. * An event triggered when the material is disposed
  80778. */
  80779. onDisposeObservable: Observable<Material>;
  80780. /**
  80781. * An observer which watches for dispose events
  80782. */
  80783. private _onDisposeObserver;
  80784. private _onUnBindObservable;
  80785. /**
  80786. * Called during a dispose event
  80787. */
  80788. onDispose: () => void;
  80789. private _onBindObservable;
  80790. /**
  80791. * An event triggered when the material is bound
  80792. */
  80793. readonly onBindObservable: Observable<AbstractMesh>;
  80794. /**
  80795. * An observer which watches for bind events
  80796. */
  80797. private _onBindObserver;
  80798. /**
  80799. * Called during a bind event
  80800. */
  80801. onBind: (Mesh: AbstractMesh) => void;
  80802. /**
  80803. * An event triggered when the material is unbound
  80804. */
  80805. readonly onUnBindObservable: Observable<Material>;
  80806. /**
  80807. * Stores the value of the alpha mode
  80808. */
  80809. private _alphaMode;
  80810. /**
  80811. * Sets the value of the alpha mode.
  80812. *
  80813. * | Value | Type | Description |
  80814. * | --- | --- | --- |
  80815. * | 0 | ALPHA_DISABLE | |
  80816. * | 1 | ALPHA_ADD | |
  80817. * | 2 | ALPHA_COMBINE | |
  80818. * | 3 | ALPHA_SUBTRACT | |
  80819. * | 4 | ALPHA_MULTIPLY | |
  80820. * | 5 | ALPHA_MAXIMIZED | |
  80821. * | 6 | ALPHA_ONEONE | |
  80822. * | 7 | ALPHA_PREMULTIPLIED | |
  80823. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  80824. * | 9 | ALPHA_INTERPOLATE | |
  80825. * | 10 | ALPHA_SCREENMODE | |
  80826. *
  80827. */
  80828. /**
  80829. * Gets the value of the alpha mode
  80830. */
  80831. alphaMode: number;
  80832. /**
  80833. * Stores the state of the need depth pre-pass value
  80834. */
  80835. private _needDepthPrePass;
  80836. /**
  80837. * Sets the need depth pre-pass value
  80838. */
  80839. /**
  80840. * Gets the depth pre-pass value
  80841. */
  80842. needDepthPrePass: boolean;
  80843. /**
  80844. * Specifies if depth writing should be disabled
  80845. */
  80846. disableDepthWrite: boolean;
  80847. /**
  80848. * Specifies if depth writing should be forced
  80849. */
  80850. forceDepthWrite: boolean;
  80851. /**
  80852. * Specifies if there should be a separate pass for culling
  80853. */
  80854. separateCullingPass: boolean;
  80855. /**
  80856. * Stores the state specifing if fog should be enabled
  80857. */
  80858. private _fogEnabled;
  80859. /**
  80860. * Sets the state for enabling fog
  80861. */
  80862. /**
  80863. * Gets the value of the fog enabled state
  80864. */
  80865. fogEnabled: boolean;
  80866. /**
  80867. * Stores the size of points
  80868. */
  80869. pointSize: number;
  80870. /**
  80871. * Stores the z offset value
  80872. */
  80873. zOffset: number;
  80874. /**
  80875. * Gets a value specifying if wireframe mode is enabled
  80876. */
  80877. /**
  80878. * Sets the state of wireframe mode
  80879. */
  80880. wireframe: boolean;
  80881. /**
  80882. * Gets the value specifying if point clouds are enabled
  80883. */
  80884. /**
  80885. * Sets the state of point cloud mode
  80886. */
  80887. pointsCloud: boolean;
  80888. /**
  80889. * Gets the material fill mode
  80890. */
  80891. /**
  80892. * Sets the material fill mode
  80893. */
  80894. fillMode: number;
  80895. /**
  80896. * @hidden
  80897. * Stores the effects for the material
  80898. */
  80899. _effect: Nullable<Effect>;
  80900. /**
  80901. * @hidden
  80902. * Specifies if the material was previously ready
  80903. */
  80904. _wasPreviouslyReady: boolean;
  80905. /**
  80906. * Specifies if uniform buffers should be used
  80907. */
  80908. private _useUBO;
  80909. /**
  80910. * Stores a reference to the scene
  80911. */
  80912. private _scene;
  80913. /**
  80914. * Stores the fill mode state
  80915. */
  80916. private _fillMode;
  80917. /**
  80918. * Specifies if the depth write state should be cached
  80919. */
  80920. private _cachedDepthWriteState;
  80921. /**
  80922. * Stores the uniform buffer
  80923. */
  80924. protected _uniformBuffer: UniformBuffer;
  80925. /** @hidden */
  80926. _indexInSceneMaterialArray: number;
  80927. /** @hidden */
  80928. meshMap: Nullable<{
  80929. [id: string]: AbstractMesh | undefined;
  80930. }>;
  80931. /**
  80932. * Creates a material instance
  80933. * @param name defines the name of the material
  80934. * @param scene defines the scene to reference
  80935. * @param doNotAdd specifies if the material should be added to the scene
  80936. */
  80937. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  80938. /**
  80939. * Returns a string representation of the current material
  80940. * @param fullDetails defines a boolean indicating which levels of logging is desired
  80941. * @returns a string with material information
  80942. */
  80943. toString(fullDetails?: boolean): string;
  80944. /**
  80945. * Gets the class name of the material
  80946. * @returns a string with the class name of the material
  80947. */
  80948. getClassName(): string;
  80949. /**
  80950. * Specifies if updates for the material been locked
  80951. */
  80952. readonly isFrozen: boolean;
  80953. /**
  80954. * Locks updates for the material
  80955. */
  80956. freeze(): void;
  80957. /**
  80958. * Unlocks updates for the material
  80959. */
  80960. unfreeze(): void;
  80961. /**
  80962. * Specifies if the material is ready to be used
  80963. * @param mesh defines the mesh to check
  80964. * @param useInstances specifies if instances should be used
  80965. * @returns a boolean indicating if the material is ready to be used
  80966. */
  80967. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  80968. /**
  80969. * Specifies that the submesh is ready to be used
  80970. * @param mesh defines the mesh to check
  80971. * @param subMesh defines which submesh to check
  80972. * @param useInstances specifies that instances should be used
  80973. * @returns a boolean indicating that the submesh is ready or not
  80974. */
  80975. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  80976. /**
  80977. * Returns the material effect
  80978. * @returns the effect associated with the material
  80979. */
  80980. getEffect(): Nullable<Effect>;
  80981. /**
  80982. * Returns the current scene
  80983. * @returns a Scene
  80984. */
  80985. getScene(): Scene;
  80986. /**
  80987. * Specifies if the material will require alpha blending
  80988. * @returns a boolean specifying if alpha blending is needed
  80989. */
  80990. needAlphaBlending(): boolean;
  80991. /**
  80992. * Specifies if the mesh will require alpha blending
  80993. * @param mesh defines the mesh to check
  80994. * @returns a boolean specifying if alpha blending is needed for the mesh
  80995. */
  80996. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  80997. /**
  80998. * Specifies if this material should be rendered in alpha test mode
  80999. * @returns a boolean specifying if an alpha test is needed.
  81000. */
  81001. needAlphaTesting(): boolean;
  81002. /**
  81003. * Gets the texture used for the alpha test
  81004. * @returns the texture to use for alpha testing
  81005. */
  81006. getAlphaTestTexture(): Nullable<BaseTexture>;
  81007. /**
  81008. * Marks the material to indicate that it needs to be re-calculated
  81009. */
  81010. markDirty(): void;
  81011. /** @hidden */
  81012. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  81013. /**
  81014. * Binds the material to the mesh
  81015. * @param world defines the world transformation matrix
  81016. * @param mesh defines the mesh to bind the material to
  81017. */
  81018. bind(world: Matrix, mesh?: Mesh): void;
  81019. /**
  81020. * Binds the submesh to the material
  81021. * @param world defines the world transformation matrix
  81022. * @param mesh defines the mesh containing the submesh
  81023. * @param subMesh defines the submesh to bind the material to
  81024. */
  81025. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  81026. /**
  81027. * Binds the world matrix to the material
  81028. * @param world defines the world transformation matrix
  81029. */
  81030. bindOnlyWorldMatrix(world: Matrix): void;
  81031. /**
  81032. * Binds the scene's uniform buffer to the effect.
  81033. * @param effect defines the effect to bind to the scene uniform buffer
  81034. * @param sceneUbo defines the uniform buffer storing scene data
  81035. */
  81036. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  81037. /**
  81038. * Binds the view matrix to the effect
  81039. * @param effect defines the effect to bind the view matrix to
  81040. */
  81041. bindView(effect: Effect): void;
  81042. /**
  81043. * Binds the view projection matrix to the effect
  81044. * @param effect defines the effect to bind the view projection matrix to
  81045. */
  81046. bindViewProjection(effect: Effect): void;
  81047. /**
  81048. * Specifies if material alpha testing should be turned on for the mesh
  81049. * @param mesh defines the mesh to check
  81050. */
  81051. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  81052. /**
  81053. * Processes to execute after binding the material to a mesh
  81054. * @param mesh defines the rendered mesh
  81055. */
  81056. protected _afterBind(mesh?: Mesh): void;
  81057. /**
  81058. * Unbinds the material from the mesh
  81059. */
  81060. unbind(): void;
  81061. /**
  81062. * Gets the active textures from the material
  81063. * @returns an array of textures
  81064. */
  81065. getActiveTextures(): BaseTexture[];
  81066. /**
  81067. * Specifies if the material uses a texture
  81068. * @param texture defines the texture to check against the material
  81069. * @returns a boolean specifying if the material uses the texture
  81070. */
  81071. hasTexture(texture: BaseTexture): boolean;
  81072. /**
  81073. * Makes a duplicate of the material, and gives it a new name
  81074. * @param name defines the new name for the duplicated material
  81075. * @returns the cloned material
  81076. */
  81077. clone(name: string): Nullable<Material>;
  81078. /**
  81079. * Gets the meshes bound to the material
  81080. * @returns an array of meshes bound to the material
  81081. */
  81082. getBindedMeshes(): AbstractMesh[];
  81083. /**
  81084. * Force shader compilation
  81085. * @param mesh defines the mesh associated with this material
  81086. * @param onCompiled defines a function to execute once the material is compiled
  81087. * @param options defines the options to configure the compilation
  81088. */
  81089. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  81090. clipPlane: boolean;
  81091. }>): void;
  81092. /**
  81093. * Force shader compilation
  81094. * @param mesh defines the mesh that will use this material
  81095. * @param options defines additional options for compiling the shaders
  81096. * @returns a promise that resolves when the compilation completes
  81097. */
  81098. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  81099. clipPlane: boolean;
  81100. }>): Promise<void>;
  81101. private static readonly _ImageProcessingDirtyCallBack;
  81102. private static readonly _TextureDirtyCallBack;
  81103. private static readonly _FresnelDirtyCallBack;
  81104. private static readonly _MiscDirtyCallBack;
  81105. private static readonly _LightsDirtyCallBack;
  81106. private static readonly _AttributeDirtyCallBack;
  81107. private static _FresnelAndMiscDirtyCallBack;
  81108. private static _TextureAndMiscDirtyCallBack;
  81109. private static readonly _DirtyCallbackArray;
  81110. private static readonly _RunDirtyCallBacks;
  81111. /**
  81112. * Marks a define in the material to indicate that it needs to be re-computed
  81113. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  81114. */
  81115. markAsDirty(flag: number): void;
  81116. /**
  81117. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  81118. * @param func defines a function which checks material defines against the submeshes
  81119. */
  81120. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  81121. /**
  81122. * Indicates that image processing needs to be re-calculated for all submeshes
  81123. */
  81124. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  81125. /**
  81126. * Indicates that textures need to be re-calculated for all submeshes
  81127. */
  81128. protected _markAllSubMeshesAsTexturesDirty(): void;
  81129. /**
  81130. * Indicates that fresnel needs to be re-calculated for all submeshes
  81131. */
  81132. protected _markAllSubMeshesAsFresnelDirty(): void;
  81133. /**
  81134. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  81135. */
  81136. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  81137. /**
  81138. * Indicates that lights need to be re-calculated for all submeshes
  81139. */
  81140. protected _markAllSubMeshesAsLightsDirty(): void;
  81141. /**
  81142. * Indicates that attributes need to be re-calculated for all submeshes
  81143. */
  81144. protected _markAllSubMeshesAsAttributesDirty(): void;
  81145. /**
  81146. * Indicates that misc needs to be re-calculated for all submeshes
  81147. */
  81148. protected _markAllSubMeshesAsMiscDirty(): void;
  81149. /**
  81150. * Indicates that textures and misc need to be re-calculated for all submeshes
  81151. */
  81152. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  81153. /**
  81154. * Disposes the material
  81155. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81156. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  81157. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  81158. */
  81159. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  81160. /** @hidden */
  81161. private releaseVertexArrayObject;
  81162. /**
  81163. * Serializes this material
  81164. * @returns the serialized material object
  81165. */
  81166. serialize(): any;
  81167. /**
  81168. * Creates a material from parsed material data
  81169. * @param parsedMaterial defines parsed material data
  81170. * @param scene defines the hosting scene
  81171. * @param rootUrl defines the root URL to use to load textures
  81172. * @returns a new material
  81173. */
  81174. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  81175. }
  81176. }
  81177. declare module BABYLON {
  81178. /**
  81179. * Base class for submeshes
  81180. */
  81181. export class BaseSubMesh {
  81182. /** @hidden */
  81183. _materialDefines: Nullable<MaterialDefines>;
  81184. /** @hidden */
  81185. _materialEffect: Nullable<Effect>;
  81186. /**
  81187. * Gets associated effect
  81188. */
  81189. readonly effect: Nullable<Effect>;
  81190. /**
  81191. * Sets associated effect (effect used to render this submesh)
  81192. * @param effect defines the effect to associate with
  81193. * @param defines defines the set of defines used to compile this effect
  81194. */
  81195. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  81196. }
  81197. /**
  81198. * Defines a subdivision inside a mesh
  81199. */
  81200. export class SubMesh extends BaseSubMesh implements ICullable {
  81201. /** the material index to use */
  81202. materialIndex: number;
  81203. /** vertex index start */
  81204. verticesStart: number;
  81205. /** vertices count */
  81206. verticesCount: number;
  81207. /** index start */
  81208. indexStart: number;
  81209. /** indices count */
  81210. indexCount: number;
  81211. /** @hidden */
  81212. _linesIndexCount: number;
  81213. private _mesh;
  81214. private _renderingMesh;
  81215. private _boundingInfo;
  81216. private _linesIndexBuffer;
  81217. /** @hidden */
  81218. _lastColliderWorldVertices: Nullable<Vector3[]>;
  81219. /** @hidden */
  81220. _trianglePlanes: Plane[];
  81221. /** @hidden */
  81222. _lastColliderTransformMatrix: Matrix;
  81223. /** @hidden */
  81224. _renderId: number;
  81225. /** @hidden */
  81226. _alphaIndex: number;
  81227. /** @hidden */
  81228. _distanceToCamera: number;
  81229. /** @hidden */
  81230. _id: number;
  81231. private _currentMaterial;
  81232. /**
  81233. * Add a new submesh to a mesh
  81234. * @param materialIndex defines the material index to use
  81235. * @param verticesStart defines vertex index start
  81236. * @param verticesCount defines vertices count
  81237. * @param indexStart defines index start
  81238. * @param indexCount defines indices count
  81239. * @param mesh defines the parent mesh
  81240. * @param renderingMesh defines an optional rendering mesh
  81241. * @param createBoundingBox defines if bounding box should be created for this submesh
  81242. * @returns the new submesh
  81243. */
  81244. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  81245. /**
  81246. * Creates a new submesh
  81247. * @param materialIndex defines the material index to use
  81248. * @param verticesStart defines vertex index start
  81249. * @param verticesCount defines vertices count
  81250. * @param indexStart defines index start
  81251. * @param indexCount defines indices count
  81252. * @param mesh defines the parent mesh
  81253. * @param renderingMesh defines an optional rendering mesh
  81254. * @param createBoundingBox defines if bounding box should be created for this submesh
  81255. */
  81256. constructor(
  81257. /** the material index to use */
  81258. materialIndex: number,
  81259. /** vertex index start */
  81260. verticesStart: number,
  81261. /** vertices count */
  81262. verticesCount: number,
  81263. /** index start */
  81264. indexStart: number,
  81265. /** indices count */
  81266. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  81267. /**
  81268. * Returns true if this submesh covers the entire parent mesh
  81269. * @ignorenaming
  81270. */
  81271. readonly IsGlobal: boolean;
  81272. /**
  81273. * Returns the submesh BoudingInfo object
  81274. * @returns current bounding info (or mesh's one if the submesh is global)
  81275. */
  81276. getBoundingInfo(): BoundingInfo;
  81277. /**
  81278. * Sets the submesh BoundingInfo
  81279. * @param boundingInfo defines the new bounding info to use
  81280. * @returns the SubMesh
  81281. */
  81282. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  81283. /**
  81284. * Returns the mesh of the current submesh
  81285. * @return the parent mesh
  81286. */
  81287. getMesh(): AbstractMesh;
  81288. /**
  81289. * Returns the rendering mesh of the submesh
  81290. * @returns the rendering mesh (could be different from parent mesh)
  81291. */
  81292. getRenderingMesh(): Mesh;
  81293. /**
  81294. * Returns the submesh material
  81295. * @returns null or the current material
  81296. */
  81297. getMaterial(): Nullable<Material>;
  81298. /**
  81299. * Sets a new updated BoundingInfo object to the submesh
  81300. * @returns the SubMesh
  81301. */
  81302. refreshBoundingInfo(): SubMesh;
  81303. /** @hidden */
  81304. _checkCollision(collider: Collider): boolean;
  81305. /**
  81306. * Updates the submesh BoundingInfo
  81307. * @param world defines the world matrix to use to update the bounding info
  81308. * @returns the submesh
  81309. */
  81310. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  81311. /**
  81312. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  81313. * @param frustumPlanes defines the frustum planes
  81314. * @returns true if the submesh is intersecting with the frustum
  81315. */
  81316. isInFrustum(frustumPlanes: Plane[]): boolean;
  81317. /**
  81318. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  81319. * @param frustumPlanes defines the frustum planes
  81320. * @returns true if the submesh is inside the frustum
  81321. */
  81322. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81323. /**
  81324. * Renders the submesh
  81325. * @param enableAlphaMode defines if alpha needs to be used
  81326. * @returns the submesh
  81327. */
  81328. render(enableAlphaMode: boolean): SubMesh;
  81329. /**
  81330. * @hidden
  81331. */
  81332. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  81333. /**
  81334. * Checks if the submesh intersects with a ray
  81335. * @param ray defines the ray to test
  81336. * @returns true is the passed ray intersects the submesh bounding box
  81337. */
  81338. canIntersects(ray: Ray): boolean;
  81339. /**
  81340. * Intersects current submesh with a ray
  81341. * @param ray defines the ray to test
  81342. * @param positions defines mesh's positions array
  81343. * @param indices defines mesh's indices array
  81344. * @param fastCheck defines if only bounding info should be used
  81345. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81346. * @returns intersection info or null if no intersection
  81347. */
  81348. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  81349. /** @hidden */
  81350. private _intersectLines;
  81351. /** @hidden */
  81352. private _intersectTriangles;
  81353. /** @hidden */
  81354. _rebuild(): void;
  81355. /**
  81356. * Creates a new submesh from the passed mesh
  81357. * @param newMesh defines the new hosting mesh
  81358. * @param newRenderingMesh defines an optional rendering mesh
  81359. * @returns the new submesh
  81360. */
  81361. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  81362. /**
  81363. * Release associated resources
  81364. */
  81365. dispose(): void;
  81366. /**
  81367. * Gets the class name
  81368. * @returns the string "SubMesh".
  81369. */
  81370. getClassName(): string;
  81371. /**
  81372. * Creates a new submesh from indices data
  81373. * @param materialIndex the index of the main mesh material
  81374. * @param startIndex the index where to start the copy in the mesh indices array
  81375. * @param indexCount the number of indices to copy then from the startIndex
  81376. * @param mesh the main mesh to create the submesh from
  81377. * @param renderingMesh the optional rendering mesh
  81378. * @returns a new submesh
  81379. */
  81380. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  81381. }
  81382. }
  81383. declare module BABYLON {
  81384. /**
  81385. * Class used to store geometry data (vertex buffers + index buffer)
  81386. */
  81387. export class Geometry implements IGetSetVerticesData {
  81388. /**
  81389. * Gets or sets the ID of the geometry
  81390. */
  81391. id: string;
  81392. /**
  81393. * Gets or sets the unique ID of the geometry
  81394. */
  81395. uniqueId: number;
  81396. /**
  81397. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81398. */
  81399. delayLoadState: number;
  81400. /**
  81401. * Gets the file containing the data to load when running in delay load state
  81402. */
  81403. delayLoadingFile: Nullable<string>;
  81404. /**
  81405. * Callback called when the geometry is updated
  81406. */
  81407. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  81408. private _scene;
  81409. private _engine;
  81410. private _meshes;
  81411. private _totalVertices;
  81412. /** @hidden */
  81413. _indices: IndicesArray;
  81414. /** @hidden */
  81415. _vertexBuffers: {
  81416. [key: string]: VertexBuffer;
  81417. };
  81418. private _isDisposed;
  81419. private _extend;
  81420. private _boundingBias;
  81421. /** @hidden */
  81422. _delayInfo: Array<string>;
  81423. private _indexBuffer;
  81424. private _indexBufferIsUpdatable;
  81425. /** @hidden */
  81426. _boundingInfo: Nullable<BoundingInfo>;
  81427. /** @hidden */
  81428. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  81429. /** @hidden */
  81430. _softwareSkinningFrameId: number;
  81431. private _vertexArrayObjects;
  81432. private _updatable;
  81433. /** @hidden */
  81434. _positions: Nullable<Vector3[]>;
  81435. /**
  81436. * 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
  81437. */
  81438. /**
  81439. * 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
  81440. */
  81441. boundingBias: Vector2;
  81442. /**
  81443. * Static function used to attach a new empty geometry to a mesh
  81444. * @param mesh defines the mesh to attach the geometry to
  81445. * @returns the new Geometry
  81446. */
  81447. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  81448. /**
  81449. * Creates a new geometry
  81450. * @param id defines the unique ID
  81451. * @param scene defines the hosting scene
  81452. * @param vertexData defines the VertexData used to get geometry data
  81453. * @param updatable defines if geometry must be updatable (false by default)
  81454. * @param mesh defines the mesh that will be associated with the geometry
  81455. */
  81456. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  81457. /**
  81458. * Gets the current extend of the geometry
  81459. */
  81460. readonly extend: {
  81461. minimum: Vector3;
  81462. maximum: Vector3;
  81463. };
  81464. /**
  81465. * Gets the hosting scene
  81466. * @returns the hosting Scene
  81467. */
  81468. getScene(): Scene;
  81469. /**
  81470. * Gets the hosting engine
  81471. * @returns the hosting Engine
  81472. */
  81473. getEngine(): Engine;
  81474. /**
  81475. * Defines if the geometry is ready to use
  81476. * @returns true if the geometry is ready to be used
  81477. */
  81478. isReady(): boolean;
  81479. /**
  81480. * Gets a value indicating that the geometry should not be serialized
  81481. */
  81482. readonly doNotSerialize: boolean;
  81483. /** @hidden */
  81484. _rebuild(): void;
  81485. /**
  81486. * Affects all geometry data in one call
  81487. * @param vertexData defines the geometry data
  81488. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81489. */
  81490. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  81491. /**
  81492. * Set specific vertex data
  81493. * @param kind defines the data kind (Position, normal, etc...)
  81494. * @param data defines the vertex data to use
  81495. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81496. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81497. */
  81498. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  81499. /**
  81500. * Removes a specific vertex data
  81501. * @param kind defines the data kind (Position, normal, etc...)
  81502. */
  81503. removeVerticesData(kind: string): void;
  81504. /**
  81505. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81506. * @param buffer defines the vertex buffer to use
  81507. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81508. */
  81509. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  81510. /**
  81511. * Update a specific vertex buffer
  81512. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81513. * It will do nothing if the buffer is not updatable
  81514. * @param kind defines the data kind (Position, normal, etc...)
  81515. * @param data defines the data to use
  81516. * @param offset defines the offset in the target buffer where to store the data
  81517. * @param useBytes set to true if the offset is in bytes
  81518. */
  81519. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  81520. /**
  81521. * Update a specific vertex buffer
  81522. * This function will create a new buffer if the current one is not updatable
  81523. * @param kind defines the data kind (Position, normal, etc...)
  81524. * @param data defines the data to use
  81525. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81526. */
  81527. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  81528. private _updateBoundingInfo;
  81529. /** @hidden */
  81530. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  81531. /**
  81532. * Gets total number of vertices
  81533. * @returns the total number of vertices
  81534. */
  81535. getTotalVertices(): number;
  81536. /**
  81537. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81538. * @param kind defines the data kind (Position, normal, etc...)
  81539. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81540. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81541. * @returns a float array containing vertex data
  81542. */
  81543. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81544. /**
  81545. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81546. * @param kind defines the data kind (Position, normal, etc...)
  81547. * @returns true if the vertex buffer with the specified kind is updatable
  81548. */
  81549. isVertexBufferUpdatable(kind: string): boolean;
  81550. /**
  81551. * Gets a specific vertex buffer
  81552. * @param kind defines the data kind (Position, normal, etc...)
  81553. * @returns a VertexBuffer
  81554. */
  81555. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81556. /**
  81557. * Returns all vertex buffers
  81558. * @return an object holding all vertex buffers indexed by kind
  81559. */
  81560. getVertexBuffers(): Nullable<{
  81561. [key: string]: VertexBuffer;
  81562. }>;
  81563. /**
  81564. * Gets a boolean indicating if specific vertex buffer is present
  81565. * @param kind defines the data kind (Position, normal, etc...)
  81566. * @returns true if data is present
  81567. */
  81568. isVerticesDataPresent(kind: string): boolean;
  81569. /**
  81570. * Gets a list of all attached data kinds (Position, normal, etc...)
  81571. * @returns a list of string containing all kinds
  81572. */
  81573. getVerticesDataKinds(): string[];
  81574. /**
  81575. * Update index buffer
  81576. * @param indices defines the indices to store in the index buffer
  81577. * @param offset defines the offset in the target buffer where to store the data
  81578. * @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)
  81579. */
  81580. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  81581. /**
  81582. * Creates a new index buffer
  81583. * @param indices defines the indices to store in the index buffer
  81584. * @param totalVertices defines the total number of vertices (could be null)
  81585. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81586. */
  81587. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  81588. /**
  81589. * Return the total number of indices
  81590. * @returns the total number of indices
  81591. */
  81592. getTotalIndices(): number;
  81593. /**
  81594. * Gets the index buffer array
  81595. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81596. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81597. * @returns the index buffer array
  81598. */
  81599. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81600. /**
  81601. * Gets the index buffer
  81602. * @return the index buffer
  81603. */
  81604. getIndexBuffer(): Nullable<WebGLBuffer>;
  81605. /** @hidden */
  81606. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  81607. /**
  81608. * Release the associated resources for a specific mesh
  81609. * @param mesh defines the source mesh
  81610. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81611. */
  81612. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  81613. /**
  81614. * Apply current geometry to a given mesh
  81615. * @param mesh defines the mesh to apply geometry to
  81616. */
  81617. applyToMesh(mesh: Mesh): void;
  81618. private _updateExtend;
  81619. private _applyToMesh;
  81620. private notifyUpdate;
  81621. /**
  81622. * Load the geometry if it was flagged as delay loaded
  81623. * @param scene defines the hosting scene
  81624. * @param onLoaded defines a callback called when the geometry is loaded
  81625. */
  81626. load(scene: Scene, onLoaded?: () => void): void;
  81627. private _queueLoad;
  81628. /**
  81629. * Invert the geometry to move from a right handed system to a left handed one.
  81630. */
  81631. toLeftHanded(): void;
  81632. /** @hidden */
  81633. _resetPointsArrayCache(): void;
  81634. /** @hidden */
  81635. _generatePointsArray(): boolean;
  81636. /**
  81637. * Gets a value indicating if the geometry is disposed
  81638. * @returns true if the geometry was disposed
  81639. */
  81640. isDisposed(): boolean;
  81641. private _disposeVertexArrayObjects;
  81642. /**
  81643. * Free all associated resources
  81644. */
  81645. dispose(): void;
  81646. /**
  81647. * Clone the current geometry into a new geometry
  81648. * @param id defines the unique ID of the new geometry
  81649. * @returns a new geometry object
  81650. */
  81651. copy(id: string): Geometry;
  81652. /**
  81653. * Serialize the current geometry info (and not the vertices data) into a JSON object
  81654. * @return a JSON representation of the current geometry data (without the vertices data)
  81655. */
  81656. serialize(): any;
  81657. private toNumberArray;
  81658. /**
  81659. * Serialize all vertices data into a JSON oject
  81660. * @returns a JSON representation of the current geometry data
  81661. */
  81662. serializeVerticeData(): any;
  81663. /**
  81664. * Extracts a clone of a mesh geometry
  81665. * @param mesh defines the source mesh
  81666. * @param id defines the unique ID of the new geometry object
  81667. * @returns the new geometry object
  81668. */
  81669. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  81670. /**
  81671. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  81672. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  81673. * Be aware Math.random() could cause collisions, but:
  81674. * "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"
  81675. * @returns a string containing a new GUID
  81676. */
  81677. static RandomId(): string;
  81678. /** @hidden */
  81679. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  81680. private static _CleanMatricesWeights;
  81681. /**
  81682. * Create a new geometry from persisted data (Using .babylon file format)
  81683. * @param parsedVertexData defines the persisted data
  81684. * @param scene defines the hosting scene
  81685. * @param rootUrl defines the root url to use to load assets (like delayed data)
  81686. * @returns the new geometry object
  81687. */
  81688. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  81689. }
  81690. }
  81691. declare module BABYLON {
  81692. /**
  81693. * Define an interface for all classes that will get and set the data on vertices
  81694. */
  81695. export interface IGetSetVerticesData {
  81696. /**
  81697. * Gets a boolean indicating if specific vertex data is present
  81698. * @param kind defines the vertex data kind to use
  81699. * @returns true is data kind is present
  81700. */
  81701. isVerticesDataPresent(kind: string): boolean;
  81702. /**
  81703. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81704. * @param kind defines the data kind (Position, normal, etc...)
  81705. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81706. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81707. * @returns a float array containing vertex data
  81708. */
  81709. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81710. /**
  81711. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81712. * @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.
  81713. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81714. * @returns the indices array or an empty array if the mesh has no geometry
  81715. */
  81716. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81717. /**
  81718. * Set specific vertex data
  81719. * @param kind defines the data kind (Position, normal, etc...)
  81720. * @param data defines the vertex data to use
  81721. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81722. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81723. */
  81724. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  81725. /**
  81726. * Update a specific associated vertex buffer
  81727. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81728. * - VertexBuffer.PositionKind
  81729. * - VertexBuffer.UVKind
  81730. * - VertexBuffer.UV2Kind
  81731. * - VertexBuffer.UV3Kind
  81732. * - VertexBuffer.UV4Kind
  81733. * - VertexBuffer.UV5Kind
  81734. * - VertexBuffer.UV6Kind
  81735. * - VertexBuffer.ColorKind
  81736. * - VertexBuffer.MatricesIndicesKind
  81737. * - VertexBuffer.MatricesIndicesExtraKind
  81738. * - VertexBuffer.MatricesWeightsKind
  81739. * - VertexBuffer.MatricesWeightsExtraKind
  81740. * @param data defines the data source
  81741. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81742. * @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)
  81743. */
  81744. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  81745. /**
  81746. * Creates a new index buffer
  81747. * @param indices defines the indices to store in the index buffer
  81748. * @param totalVertices defines the total number of vertices (could be null)
  81749. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81750. */
  81751. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  81752. }
  81753. /**
  81754. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  81755. */
  81756. export class VertexData {
  81757. /**
  81758. * Mesh side orientation : usually the external or front surface
  81759. */
  81760. static readonly FRONTSIDE: number;
  81761. /**
  81762. * Mesh side orientation : usually the internal or back surface
  81763. */
  81764. static readonly BACKSIDE: number;
  81765. /**
  81766. * Mesh side orientation : both internal and external or front and back surfaces
  81767. */
  81768. static readonly DOUBLESIDE: number;
  81769. /**
  81770. * Mesh side orientation : by default, `FRONTSIDE`
  81771. */
  81772. static readonly DEFAULTSIDE: number;
  81773. /**
  81774. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  81775. */
  81776. positions: Nullable<FloatArray>;
  81777. /**
  81778. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  81779. */
  81780. normals: Nullable<FloatArray>;
  81781. /**
  81782. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  81783. */
  81784. tangents: Nullable<FloatArray>;
  81785. /**
  81786. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81787. */
  81788. uvs: Nullable<FloatArray>;
  81789. /**
  81790. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81791. */
  81792. uvs2: Nullable<FloatArray>;
  81793. /**
  81794. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81795. */
  81796. uvs3: Nullable<FloatArray>;
  81797. /**
  81798. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81799. */
  81800. uvs4: Nullable<FloatArray>;
  81801. /**
  81802. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81803. */
  81804. uvs5: Nullable<FloatArray>;
  81805. /**
  81806. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81807. */
  81808. uvs6: Nullable<FloatArray>;
  81809. /**
  81810. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  81811. */
  81812. colors: Nullable<FloatArray>;
  81813. /**
  81814. * 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).
  81815. */
  81816. matricesIndices: Nullable<FloatArray>;
  81817. /**
  81818. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  81819. */
  81820. matricesWeights: Nullable<FloatArray>;
  81821. /**
  81822. * An array extending the number of possible indices
  81823. */
  81824. matricesIndicesExtra: Nullable<FloatArray>;
  81825. /**
  81826. * An array extending the number of possible weights when the number of indices is extended
  81827. */
  81828. matricesWeightsExtra: Nullable<FloatArray>;
  81829. /**
  81830. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  81831. */
  81832. indices: Nullable<IndicesArray>;
  81833. /**
  81834. * Uses the passed data array to set the set the values for the specified kind of data
  81835. * @param data a linear array of floating numbers
  81836. * @param kind the type of data that is being set, eg positions, colors etc
  81837. */
  81838. set(data: FloatArray, kind: string): void;
  81839. /**
  81840. * Associates the vertexData to the passed Mesh.
  81841. * Sets it as updatable or not (default `false`)
  81842. * @param mesh the mesh the vertexData is applied to
  81843. * @param updatable when used and having the value true allows new data to update the vertexData
  81844. * @returns the VertexData
  81845. */
  81846. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  81847. /**
  81848. * Associates the vertexData to the passed Geometry.
  81849. * Sets it as updatable or not (default `false`)
  81850. * @param geometry the geometry the vertexData is applied to
  81851. * @param updatable when used and having the value true allows new data to update the vertexData
  81852. * @returns VertexData
  81853. */
  81854. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  81855. /**
  81856. * Updates the associated mesh
  81857. * @param mesh the mesh to be updated
  81858. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81859. * @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
  81860. * @returns VertexData
  81861. */
  81862. updateMesh(mesh: Mesh): VertexData;
  81863. /**
  81864. * Updates the associated geometry
  81865. * @param geometry the geometry to be updated
  81866. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81867. * @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
  81868. * @returns VertexData.
  81869. */
  81870. updateGeometry(geometry: Geometry): VertexData;
  81871. private _applyTo;
  81872. private _update;
  81873. /**
  81874. * Transforms each position and each normal of the vertexData according to the passed Matrix
  81875. * @param matrix the transforming matrix
  81876. * @returns the VertexData
  81877. */
  81878. transform(matrix: Matrix): VertexData;
  81879. /**
  81880. * Merges the passed VertexData into the current one
  81881. * @param other the VertexData to be merged into the current one
  81882. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  81883. * @returns the modified VertexData
  81884. */
  81885. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  81886. private _mergeElement;
  81887. private _validate;
  81888. /**
  81889. * Serializes the VertexData
  81890. * @returns a serialized object
  81891. */
  81892. serialize(): any;
  81893. /**
  81894. * Extracts the vertexData from a mesh
  81895. * @param mesh the mesh from which to extract the VertexData
  81896. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  81897. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81898. * @returns the object VertexData associated to the passed mesh
  81899. */
  81900. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81901. /**
  81902. * Extracts the vertexData from the geometry
  81903. * @param geometry the geometry from which to extract the VertexData
  81904. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  81905. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81906. * @returns the object VertexData associated to the passed mesh
  81907. */
  81908. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81909. private static _ExtractFrom;
  81910. /**
  81911. * Creates the VertexData for a Ribbon
  81912. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  81913. * * pathArray array of paths, each of which an array of successive Vector3
  81914. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  81915. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  81916. * * 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
  81917. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81918. * * 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)
  81919. * * 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)
  81920. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  81921. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  81922. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  81923. * @returns the VertexData of the ribbon
  81924. */
  81925. static CreateRibbon(options: {
  81926. pathArray: Vector3[][];
  81927. closeArray?: boolean;
  81928. closePath?: boolean;
  81929. offset?: number;
  81930. sideOrientation?: number;
  81931. frontUVs?: Vector4;
  81932. backUVs?: Vector4;
  81933. invertUV?: boolean;
  81934. uvs?: Vector2[];
  81935. colors?: Color4[];
  81936. }): VertexData;
  81937. /**
  81938. * Creates the VertexData for a box
  81939. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81940. * * size sets the width, height and depth of the box to the value of size, optional default 1
  81941. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  81942. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  81943. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  81944. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  81945. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  81946. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81947. * * 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)
  81948. * * 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)
  81949. * @returns the VertexData of the box
  81950. */
  81951. static CreateBox(options: {
  81952. size?: number;
  81953. width?: number;
  81954. height?: number;
  81955. depth?: number;
  81956. faceUV?: Vector4[];
  81957. faceColors?: Color4[];
  81958. sideOrientation?: number;
  81959. frontUVs?: Vector4;
  81960. backUVs?: Vector4;
  81961. }): VertexData;
  81962. /**
  81963. * Creates the VertexData for an ellipsoid, defaults to a sphere
  81964. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81965. * * segments sets the number of horizontal strips optional, default 32
  81966. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  81967. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  81968. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  81969. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  81970. * * 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
  81971. * * 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
  81972. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81973. * * 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)
  81974. * * 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)
  81975. * @returns the VertexData of the ellipsoid
  81976. */
  81977. static CreateSphere(options: {
  81978. segments?: number;
  81979. diameter?: number;
  81980. diameterX?: number;
  81981. diameterY?: number;
  81982. diameterZ?: number;
  81983. arc?: number;
  81984. slice?: number;
  81985. sideOrientation?: number;
  81986. frontUVs?: Vector4;
  81987. backUVs?: Vector4;
  81988. }): VertexData;
  81989. /**
  81990. * Creates the VertexData for a cylinder, cone or prism
  81991. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81992. * * height sets the height (y direction) of the cylinder, optional, default 2
  81993. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  81994. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  81995. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  81996. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81997. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  81998. * * 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
  81999. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82000. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82001. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  82002. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  82003. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82004. * * 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)
  82005. * * 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)
  82006. * @returns the VertexData of the cylinder, cone or prism
  82007. */
  82008. static CreateCylinder(options: {
  82009. height?: number;
  82010. diameterTop?: number;
  82011. diameterBottom?: number;
  82012. diameter?: number;
  82013. tessellation?: number;
  82014. subdivisions?: number;
  82015. arc?: number;
  82016. faceColors?: Color4[];
  82017. faceUV?: Vector4[];
  82018. hasRings?: boolean;
  82019. enclose?: boolean;
  82020. sideOrientation?: number;
  82021. frontUVs?: Vector4;
  82022. backUVs?: Vector4;
  82023. }): VertexData;
  82024. /**
  82025. * Creates the VertexData for a torus
  82026. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82027. * * diameter the diameter of the torus, optional default 1
  82028. * * thickness the diameter of the tube forming the torus, optional default 0.5
  82029. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82030. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82031. * * 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)
  82032. * * 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)
  82033. * @returns the VertexData of the torus
  82034. */
  82035. static CreateTorus(options: {
  82036. diameter?: number;
  82037. thickness?: number;
  82038. tessellation?: number;
  82039. sideOrientation?: number;
  82040. frontUVs?: Vector4;
  82041. backUVs?: Vector4;
  82042. }): VertexData;
  82043. /**
  82044. * Creates the VertexData of the LineSystem
  82045. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  82046. * - lines an array of lines, each line being an array of successive Vector3
  82047. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  82048. * @returns the VertexData of the LineSystem
  82049. */
  82050. static CreateLineSystem(options: {
  82051. lines: Vector3[][];
  82052. colors?: Nullable<Color4[][]>;
  82053. }): VertexData;
  82054. /**
  82055. * Create the VertexData for a DashedLines
  82056. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  82057. * - points an array successive Vector3
  82058. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  82059. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  82060. * - dashNb the intended total number of dashes, optional, default 200
  82061. * @returns the VertexData for the DashedLines
  82062. */
  82063. static CreateDashedLines(options: {
  82064. points: Vector3[];
  82065. dashSize?: number;
  82066. gapSize?: number;
  82067. dashNb?: number;
  82068. }): VertexData;
  82069. /**
  82070. * Creates the VertexData for a Ground
  82071. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82072. * - width the width (x direction) of the ground, optional, default 1
  82073. * - height the height (z direction) of the ground, optional, default 1
  82074. * - subdivisions the number of subdivisions per side, optional, default 1
  82075. * @returns the VertexData of the Ground
  82076. */
  82077. static CreateGround(options: {
  82078. width?: number;
  82079. height?: number;
  82080. subdivisions?: number;
  82081. subdivisionsX?: number;
  82082. subdivisionsY?: number;
  82083. }): VertexData;
  82084. /**
  82085. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  82086. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82087. * * xmin the ground minimum X coordinate, optional, default -1
  82088. * * zmin the ground minimum Z coordinate, optional, default -1
  82089. * * xmax the ground maximum X coordinate, optional, default 1
  82090. * * zmax the ground maximum Z coordinate, optional, default 1
  82091. * * 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}
  82092. * * 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}
  82093. * @returns the VertexData of the TiledGround
  82094. */
  82095. static CreateTiledGround(options: {
  82096. xmin: number;
  82097. zmin: number;
  82098. xmax: number;
  82099. zmax: number;
  82100. subdivisions?: {
  82101. w: number;
  82102. h: number;
  82103. };
  82104. precision?: {
  82105. w: number;
  82106. h: number;
  82107. };
  82108. }): VertexData;
  82109. /**
  82110. * Creates the VertexData of the Ground designed from a heightmap
  82111. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  82112. * * width the width (x direction) of the ground
  82113. * * height the height (z direction) of the ground
  82114. * * subdivisions the number of subdivisions per side
  82115. * * minHeight the minimum altitude on the ground, optional, default 0
  82116. * * maxHeight the maximum altitude on the ground, optional default 1
  82117. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  82118. * * buffer the array holding the image color data
  82119. * * bufferWidth the width of image
  82120. * * bufferHeight the height of image
  82121. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  82122. * @returns the VertexData of the Ground designed from a heightmap
  82123. */
  82124. static CreateGroundFromHeightMap(options: {
  82125. width: number;
  82126. height: number;
  82127. subdivisions: number;
  82128. minHeight: number;
  82129. maxHeight: number;
  82130. colorFilter: Color3;
  82131. buffer: Uint8Array;
  82132. bufferWidth: number;
  82133. bufferHeight: number;
  82134. alphaFilter: number;
  82135. }): VertexData;
  82136. /**
  82137. * Creates the VertexData for a Plane
  82138. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  82139. * * size sets the width and height of the plane to the value of size, optional default 1
  82140. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  82141. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  82142. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82143. * * 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)
  82144. * * 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)
  82145. * @returns the VertexData of the box
  82146. */
  82147. static CreatePlane(options: {
  82148. size?: number;
  82149. width?: number;
  82150. height?: number;
  82151. sideOrientation?: number;
  82152. frontUVs?: Vector4;
  82153. backUVs?: Vector4;
  82154. }): VertexData;
  82155. /**
  82156. * Creates the VertexData of the Disc or regular Polygon
  82157. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  82158. * * radius the radius of the disc, optional default 0.5
  82159. * * tessellation the number of polygon sides, optional, default 64
  82160. * * 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
  82161. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82162. * * 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)
  82163. * * 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)
  82164. * @returns the VertexData of the box
  82165. */
  82166. static CreateDisc(options: {
  82167. radius?: number;
  82168. tessellation?: number;
  82169. arc?: number;
  82170. sideOrientation?: number;
  82171. frontUVs?: Vector4;
  82172. backUVs?: Vector4;
  82173. }): VertexData;
  82174. /**
  82175. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  82176. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  82177. * @param polygon a mesh built from polygonTriangulation.build()
  82178. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82179. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82180. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82181. * @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)
  82182. * @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)
  82183. * @returns the VertexData of the Polygon
  82184. */
  82185. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  82186. /**
  82187. * Creates the VertexData of the IcoSphere
  82188. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  82189. * * radius the radius of the IcoSphere, optional default 1
  82190. * * radiusX allows stretching in the x direction, optional, default radius
  82191. * * radiusY allows stretching in the y direction, optional, default radius
  82192. * * radiusZ allows stretching in the z direction, optional, default radius
  82193. * * flat when true creates a flat shaded mesh, optional, default true
  82194. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82195. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82196. * * 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)
  82197. * * 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)
  82198. * @returns the VertexData of the IcoSphere
  82199. */
  82200. static CreateIcoSphere(options: {
  82201. radius?: number;
  82202. radiusX?: number;
  82203. radiusY?: number;
  82204. radiusZ?: number;
  82205. flat?: boolean;
  82206. subdivisions?: number;
  82207. sideOrientation?: number;
  82208. frontUVs?: Vector4;
  82209. backUVs?: Vector4;
  82210. }): VertexData;
  82211. /**
  82212. * Creates the VertexData for a Polyhedron
  82213. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  82214. * * type provided types are:
  82215. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  82216. * * 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)
  82217. * * size the size of the IcoSphere, optional default 1
  82218. * * sizeX allows stretching in the x direction, optional, default size
  82219. * * sizeY allows stretching in the y direction, optional, default size
  82220. * * sizeZ allows stretching in the z direction, optional, default size
  82221. * * 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
  82222. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82223. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82224. * * flat when true creates a flat shaded mesh, optional, default true
  82225. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82226. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82227. * * 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)
  82228. * * 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)
  82229. * @returns the VertexData of the Polyhedron
  82230. */
  82231. static CreatePolyhedron(options: {
  82232. type?: number;
  82233. size?: number;
  82234. sizeX?: number;
  82235. sizeY?: number;
  82236. sizeZ?: number;
  82237. custom?: any;
  82238. faceUV?: Vector4[];
  82239. faceColors?: Color4[];
  82240. flat?: boolean;
  82241. sideOrientation?: number;
  82242. frontUVs?: Vector4;
  82243. backUVs?: Vector4;
  82244. }): VertexData;
  82245. /**
  82246. * Creates the VertexData for a TorusKnot
  82247. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  82248. * * radius the radius of the torus knot, optional, default 2
  82249. * * tube the thickness of the tube, optional, default 0.5
  82250. * * radialSegments the number of sides on each tube segments, optional, default 32
  82251. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  82252. * * p the number of windings around the z axis, optional, default 2
  82253. * * q the number of windings around the x axis, optional, default 3
  82254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82255. * * 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)
  82256. * * 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)
  82257. * @returns the VertexData of the Torus Knot
  82258. */
  82259. static CreateTorusKnot(options: {
  82260. radius?: number;
  82261. tube?: number;
  82262. radialSegments?: number;
  82263. tubularSegments?: number;
  82264. p?: number;
  82265. q?: number;
  82266. sideOrientation?: number;
  82267. frontUVs?: Vector4;
  82268. backUVs?: Vector4;
  82269. }): VertexData;
  82270. /**
  82271. * Compute normals for given positions and indices
  82272. * @param positions an array of vertex positions, [...., x, y, z, ......]
  82273. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  82274. * @param normals an array of vertex normals, [...., x, y, z, ......]
  82275. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  82276. * * facetNormals : optional array of facet normals (vector3)
  82277. * * facetPositions : optional array of facet positions (vector3)
  82278. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  82279. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  82280. * * bInfo : optional bounding info, required for facetPartitioning computation
  82281. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  82282. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  82283. * * useRightHandedSystem: optional boolean to for right handed system computation
  82284. * * depthSort : optional boolean to enable the facet depth sort computation
  82285. * * distanceTo : optional Vector3 to compute the facet depth from this location
  82286. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  82287. */
  82288. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  82289. facetNormals?: any;
  82290. facetPositions?: any;
  82291. facetPartitioning?: any;
  82292. ratio?: number;
  82293. bInfo?: any;
  82294. bbSize?: Vector3;
  82295. subDiv?: any;
  82296. useRightHandedSystem?: boolean;
  82297. depthSort?: boolean;
  82298. distanceTo?: Vector3;
  82299. depthSortedFacets?: any;
  82300. }): void;
  82301. /** @hidden */
  82302. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  82303. /**
  82304. * Applies VertexData created from the imported parameters to the geometry
  82305. * @param parsedVertexData the parsed data from an imported file
  82306. * @param geometry the geometry to apply the VertexData to
  82307. */
  82308. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  82309. }
  82310. }
  82311. declare module BABYLON {
  82312. /**
  82313. * Class containing static functions to help procedurally build meshes
  82314. */
  82315. export class DiscBuilder {
  82316. /**
  82317. * Creates a plane polygonal mesh. By default, this is a disc
  82318. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  82319. * * 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
  82320. * * 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
  82321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  82323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82324. * @param name defines the name of the mesh
  82325. * @param options defines the options used to create the mesh
  82326. * @param scene defines the hosting scene
  82327. * @returns the plane polygonal mesh
  82328. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  82329. */
  82330. static CreateDisc(name: string, options: {
  82331. radius?: number;
  82332. tessellation?: number;
  82333. arc?: number;
  82334. updatable?: boolean;
  82335. sideOrientation?: number;
  82336. frontUVs?: Vector4;
  82337. backUVs?: Vector4;
  82338. }, scene?: Nullable<Scene>): Mesh;
  82339. }
  82340. }
  82341. declare module BABYLON {
  82342. /**
  82343. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  82344. *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.
  82345. * The SPS is also a particle system. It provides some methods to manage the particles.
  82346. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  82347. *
  82348. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  82349. */
  82350. export class SolidParticleSystem implements IDisposable {
  82351. /**
  82352. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  82353. * Example : var p = SPS.particles[i];
  82354. */
  82355. particles: SolidParticle[];
  82356. /**
  82357. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  82358. */
  82359. nbParticles: number;
  82360. /**
  82361. * If the particles must ever face the camera (default false). Useful for planar particles.
  82362. */
  82363. billboard: boolean;
  82364. /**
  82365. * Recompute normals when adding a shape
  82366. */
  82367. recomputeNormals: boolean;
  82368. /**
  82369. * This a counter ofr your own usage. It's not set by any SPS functions.
  82370. */
  82371. counter: number;
  82372. /**
  82373. * The SPS name. This name is also given to the underlying mesh.
  82374. */
  82375. name: string;
  82376. /**
  82377. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  82378. */
  82379. mesh: Mesh;
  82380. /**
  82381. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  82382. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  82383. */
  82384. vars: any;
  82385. /**
  82386. * This array is populated when the SPS is set as 'pickable'.
  82387. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  82388. * Each element of this array is an object `{idx: int, faceId: int}`.
  82389. * `idx` is the picked particle index in the `SPS.particles` array
  82390. * `faceId` is the picked face index counted within this particle.
  82391. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  82392. */
  82393. pickedParticles: {
  82394. idx: number;
  82395. faceId: number;
  82396. }[];
  82397. /**
  82398. * This array is populated when `enableDepthSort` is set to true.
  82399. * Each element of this array is an instance of the class DepthSortedParticle.
  82400. */
  82401. depthSortedParticles: DepthSortedParticle[];
  82402. /**
  82403. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  82404. * @hidden
  82405. */
  82406. _bSphereOnly: boolean;
  82407. /**
  82408. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  82409. * @hidden
  82410. */
  82411. _bSphereRadiusFactor: number;
  82412. private _scene;
  82413. private _positions;
  82414. private _indices;
  82415. private _normals;
  82416. private _colors;
  82417. private _uvs;
  82418. private _indices32;
  82419. private _positions32;
  82420. private _normals32;
  82421. private _fixedNormal32;
  82422. private _colors32;
  82423. private _uvs32;
  82424. private _index;
  82425. private _updatable;
  82426. private _pickable;
  82427. private _isVisibilityBoxLocked;
  82428. private _alwaysVisible;
  82429. private _depthSort;
  82430. private _shapeCounter;
  82431. private _copy;
  82432. private _color;
  82433. private _computeParticleColor;
  82434. private _computeParticleTexture;
  82435. private _computeParticleRotation;
  82436. private _computeParticleVertex;
  82437. private _computeBoundingBox;
  82438. private _depthSortParticles;
  82439. private _camera;
  82440. private _mustUnrotateFixedNormals;
  82441. private _particlesIntersect;
  82442. private _needs32Bits;
  82443. /**
  82444. * Creates a SPS (Solid Particle System) object.
  82445. * @param name (String) is the SPS name, this will be the underlying mesh name.
  82446. * @param scene (Scene) is the scene in which the SPS is added.
  82447. * @param options defines the options of the sps e.g.
  82448. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  82449. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  82450. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  82451. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  82452. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  82453. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  82454. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  82455. */
  82456. constructor(name: string, scene: Scene, options?: {
  82457. updatable?: boolean;
  82458. isPickable?: boolean;
  82459. enableDepthSort?: boolean;
  82460. particleIntersection?: boolean;
  82461. boundingSphereOnly?: boolean;
  82462. bSphereRadiusFactor?: number;
  82463. });
  82464. /**
  82465. * Builds the SPS underlying mesh. Returns a standard Mesh.
  82466. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  82467. * @returns the created mesh
  82468. */
  82469. buildMesh(): Mesh;
  82470. /**
  82471. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  82472. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  82473. * Thus the particles generated from `digest()` have their property `position` set yet.
  82474. * @param mesh ( Mesh ) is the mesh to be digested
  82475. * @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
  82476. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  82477. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  82478. * @returns the current SPS
  82479. */
  82480. digest(mesh: Mesh, options?: {
  82481. facetNb?: number;
  82482. number?: number;
  82483. delta?: number;
  82484. }): SolidParticleSystem;
  82485. private _unrotateFixedNormals;
  82486. private _resetCopy;
  82487. private _meshBuilder;
  82488. private _posToShape;
  82489. private _uvsToShapeUV;
  82490. private _addParticle;
  82491. /**
  82492. * Adds some particles to the SPS from the model shape. Returns the shape id.
  82493. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  82494. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  82495. * @param nb (positive integer) the number of particles to be created from this model
  82496. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  82497. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  82498. * @returns the number of shapes in the system
  82499. */
  82500. addShape(mesh: Mesh, nb: number, options?: {
  82501. positionFunction?: any;
  82502. vertexFunction?: any;
  82503. }): number;
  82504. private _rebuildParticle;
  82505. /**
  82506. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  82507. * @returns the SPS.
  82508. */
  82509. rebuildMesh(): SolidParticleSystem;
  82510. /**
  82511. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  82512. * This method calls `updateParticle()` for each particle of the SPS.
  82513. * For an animated SPS, it is usually called within the render loop.
  82514. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  82515. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  82516. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  82517. * @returns the SPS.
  82518. */
  82519. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  82520. /**
  82521. * Disposes the SPS.
  82522. */
  82523. dispose(): void;
  82524. /**
  82525. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  82526. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82527. * @returns the SPS.
  82528. */
  82529. refreshVisibleSize(): SolidParticleSystem;
  82530. /**
  82531. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  82532. * @param size the size (float) of the visibility box
  82533. * note : this doesn't lock the SPS mesh bounding box.
  82534. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82535. */
  82536. setVisibilityBox(size: number): void;
  82537. /**
  82538. * Gets whether the SPS as always visible or not
  82539. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82540. */
  82541. /**
  82542. * Sets the SPS as always visible or not
  82543. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82544. */
  82545. isAlwaysVisible: boolean;
  82546. /**
  82547. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82548. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82549. */
  82550. /**
  82551. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82552. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82553. */
  82554. isVisibilityBoxLocked: boolean;
  82555. /**
  82556. * Tells to `setParticles()` to compute the particle rotations or not.
  82557. * Default value : true. The SPS is faster when it's set to false.
  82558. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82559. */
  82560. /**
  82561. * Gets if `setParticles()` computes the particle rotations or not.
  82562. * Default value : true. The SPS is faster when it's set to false.
  82563. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82564. */
  82565. computeParticleRotation: boolean;
  82566. /**
  82567. * Tells to `setParticles()` to compute the particle colors or not.
  82568. * Default value : true. The SPS is faster when it's set to false.
  82569. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82570. */
  82571. /**
  82572. * Gets if `setParticles()` computes the particle colors or not.
  82573. * Default value : true. The SPS is faster when it's set to false.
  82574. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82575. */
  82576. computeParticleColor: boolean;
  82577. /**
  82578. * Gets if `setParticles()` computes the particle textures or not.
  82579. * Default value : true. The SPS is faster when it's set to false.
  82580. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  82581. */
  82582. computeParticleTexture: boolean;
  82583. /**
  82584. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  82585. * Default value : false. The SPS is faster when it's set to false.
  82586. * Note : the particle custom vertex positions aren't stored values.
  82587. */
  82588. /**
  82589. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  82590. * Default value : false. The SPS is faster when it's set to false.
  82591. * Note : the particle custom vertex positions aren't stored values.
  82592. */
  82593. computeParticleVertex: boolean;
  82594. /**
  82595. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  82596. */
  82597. /**
  82598. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  82599. */
  82600. computeBoundingBox: boolean;
  82601. /**
  82602. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  82603. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82604. * Default : `true`
  82605. */
  82606. /**
  82607. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  82608. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82609. * Default : `true`
  82610. */
  82611. depthSortParticles: boolean;
  82612. /**
  82613. * This function does nothing. It may be overwritten to set all the particle first values.
  82614. * The SPS doesn't call this function, you may have to call it by your own.
  82615. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82616. */
  82617. initParticles(): void;
  82618. /**
  82619. * This function does nothing. It may be overwritten to recycle a particle.
  82620. * The SPS doesn't call this function, you may have to call it by your own.
  82621. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82622. * @param particle The particle to recycle
  82623. * @returns the recycled particle
  82624. */
  82625. recycleParticle(particle: SolidParticle): SolidParticle;
  82626. /**
  82627. * Updates a particle : this function should be overwritten by the user.
  82628. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  82629. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82630. * @example : just set a particle position or velocity and recycle conditions
  82631. * @param particle The particle to update
  82632. * @returns the updated particle
  82633. */
  82634. updateParticle(particle: SolidParticle): SolidParticle;
  82635. /**
  82636. * Updates a vertex of a particle : it can be overwritten by the user.
  82637. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  82638. * @param particle the current particle
  82639. * @param vertex the current index of the current particle
  82640. * @param pt the index of the current vertex in the particle shape
  82641. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  82642. * @example : just set a vertex particle position
  82643. * @returns the updated vertex
  82644. */
  82645. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  82646. /**
  82647. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  82648. * This does nothing and may be overwritten by the user.
  82649. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82650. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82651. * @param update the boolean update value actually passed to setParticles()
  82652. */
  82653. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82654. /**
  82655. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  82656. * This will be passed three parameters.
  82657. * This does nothing and may be overwritten by the user.
  82658. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82659. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82660. * @param update the boolean update value actually passed to setParticles()
  82661. */
  82662. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82663. }
  82664. }
  82665. declare module BABYLON {
  82666. /**
  82667. * Represents one particle of a solid particle system.
  82668. */
  82669. export class SolidParticle {
  82670. /**
  82671. * particle global index
  82672. */
  82673. idx: number;
  82674. /**
  82675. * The color of the particle
  82676. */
  82677. color: Nullable<Color4>;
  82678. /**
  82679. * The world space position of the particle.
  82680. */
  82681. position: Vector3;
  82682. /**
  82683. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  82684. */
  82685. rotation: Vector3;
  82686. /**
  82687. * The world space rotation quaternion of the particle.
  82688. */
  82689. rotationQuaternion: Nullable<Quaternion>;
  82690. /**
  82691. * The scaling of the particle.
  82692. */
  82693. scaling: Vector3;
  82694. /**
  82695. * The uvs of the particle.
  82696. */
  82697. uvs: Vector4;
  82698. /**
  82699. * The current speed of the particle.
  82700. */
  82701. velocity: Vector3;
  82702. /**
  82703. * The pivot point in the particle local space.
  82704. */
  82705. pivot: Vector3;
  82706. /**
  82707. * Must the particle be translated from its pivot point in its local space ?
  82708. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  82709. * Default : false
  82710. */
  82711. translateFromPivot: boolean;
  82712. /**
  82713. * Is the particle active or not ?
  82714. */
  82715. alive: boolean;
  82716. /**
  82717. * Is the particle visible or not ?
  82718. */
  82719. isVisible: boolean;
  82720. /**
  82721. * Index of this particle in the global "positions" array (Internal use)
  82722. * @hidden
  82723. */
  82724. _pos: number;
  82725. /**
  82726. * @hidden Index of this particle in the global "indices" array (Internal use)
  82727. */
  82728. _ind: number;
  82729. /**
  82730. * @hidden ModelShape of this particle (Internal use)
  82731. */
  82732. _model: ModelShape;
  82733. /**
  82734. * ModelShape id of this particle
  82735. */
  82736. shapeId: number;
  82737. /**
  82738. * Index of the particle in its shape id (Internal use)
  82739. */
  82740. idxInShape: number;
  82741. /**
  82742. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  82743. */
  82744. _modelBoundingInfo: BoundingInfo;
  82745. /**
  82746. * @hidden Particle BoundingInfo object (Internal use)
  82747. */
  82748. _boundingInfo: BoundingInfo;
  82749. /**
  82750. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  82751. */
  82752. _sps: SolidParticleSystem;
  82753. /**
  82754. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  82755. */
  82756. _stillInvisible: boolean;
  82757. /**
  82758. * @hidden Last computed particle rotation matrix
  82759. */
  82760. _rotationMatrix: number[];
  82761. /**
  82762. * Parent particle Id, if any.
  82763. * Default null.
  82764. */
  82765. parentId: Nullable<number>;
  82766. /**
  82767. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  82768. * The possible values are :
  82769. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82770. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82771. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82772. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82773. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82774. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  82775. * */
  82776. cullingStrategy: number;
  82777. /**
  82778. * @hidden Internal global position in the SPS.
  82779. */
  82780. _globalPosition: Vector3;
  82781. /**
  82782. * Creates a Solid Particle object.
  82783. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  82784. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  82785. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  82786. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  82787. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  82788. * @param shapeId (integer) is the model shape identifier in the SPS.
  82789. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  82790. * @param sps defines the sps it is associated to
  82791. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  82792. */
  82793. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  82794. /**
  82795. * Legacy support, changed scale to scaling
  82796. */
  82797. /**
  82798. * Legacy support, changed scale to scaling
  82799. */
  82800. scale: Vector3;
  82801. /**
  82802. * Legacy support, changed quaternion to rotationQuaternion
  82803. */
  82804. /**
  82805. * Legacy support, changed quaternion to rotationQuaternion
  82806. */
  82807. quaternion: Nullable<Quaternion>;
  82808. /**
  82809. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  82810. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  82811. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  82812. * @returns true if it intersects
  82813. */
  82814. intersectsMesh(target: Mesh | SolidParticle): boolean;
  82815. /**
  82816. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  82817. * A particle is in the frustum if its bounding box intersects the frustum
  82818. * @param frustumPlanes defines the frustum to test
  82819. * @returns true if the particle is in the frustum planes
  82820. */
  82821. isInFrustum(frustumPlanes: Plane[]): boolean;
  82822. /**
  82823. * get the rotation matrix of the particle
  82824. * @hidden
  82825. */
  82826. getRotationMatrix(m: Matrix): void;
  82827. }
  82828. /**
  82829. * Represents the shape of the model used by one particle of a solid particle system.
  82830. * SPS internal tool, don't use it manually.
  82831. */
  82832. export class ModelShape {
  82833. /**
  82834. * The shape id
  82835. * @hidden
  82836. */
  82837. shapeID: number;
  82838. /**
  82839. * flat array of model positions (internal use)
  82840. * @hidden
  82841. */
  82842. _shape: Vector3[];
  82843. /**
  82844. * flat array of model UVs (internal use)
  82845. * @hidden
  82846. */
  82847. _shapeUV: number[];
  82848. /**
  82849. * length of the shape in the model indices array (internal use)
  82850. * @hidden
  82851. */
  82852. _indicesLength: number;
  82853. /**
  82854. * Custom position function (internal use)
  82855. * @hidden
  82856. */
  82857. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  82858. /**
  82859. * Custom vertex function (internal use)
  82860. * @hidden
  82861. */
  82862. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  82863. /**
  82864. * 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.
  82865. * SPS internal tool, don't use it manually.
  82866. * @hidden
  82867. */
  82868. 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>);
  82869. }
  82870. /**
  82871. * Represents a Depth Sorted Particle in the solid particle system.
  82872. */
  82873. export class DepthSortedParticle {
  82874. /**
  82875. * Index of the particle in the "indices" array
  82876. */
  82877. ind: number;
  82878. /**
  82879. * Length of the particle shape in the "indices" array
  82880. */
  82881. indicesLength: number;
  82882. /**
  82883. * Squared distance from the particle to the camera
  82884. */
  82885. sqDistance: number;
  82886. }
  82887. }
  82888. declare module BABYLON {
  82889. /**
  82890. * Class used to store all common mesh properties
  82891. */
  82892. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  82893. /** No occlusion */
  82894. static OCCLUSION_TYPE_NONE: number;
  82895. /** Occlusion set to optimisitic */
  82896. static OCCLUSION_TYPE_OPTIMISTIC: number;
  82897. /** Occlusion set to strict */
  82898. static OCCLUSION_TYPE_STRICT: number;
  82899. /** Use an accurante occlusion algorithm */
  82900. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  82901. /** Use a conservative occlusion algorithm */
  82902. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  82903. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82904. * Test order :
  82905. * Is the bounding sphere outside the frustum ?
  82906. * If not, are the bounding box vertices outside the frustum ?
  82907. * It not, then the cullable object is in the frustum.
  82908. */
  82909. static readonly CULLINGSTRATEGY_STANDARD: number;
  82910. /** Culling strategy : Bounding Sphere Only.
  82911. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82912. * It's also less accurate than the standard because some not visible objects can still be selected.
  82913. * Test : is the bounding sphere outside the frustum ?
  82914. * If not, then the cullable object is in the frustum.
  82915. */
  82916. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82917. /** Culling strategy : Optimistic Inclusion.
  82918. * This in an inclusion test first, then the standard exclusion test.
  82919. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82920. * 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.
  82921. * Anyway, it's as accurate as the standard strategy.
  82922. * Test :
  82923. * Is the cullable object bounding sphere center in the frustum ?
  82924. * If not, apply the default culling strategy.
  82925. */
  82926. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82927. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82928. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82929. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82930. * 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.
  82931. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82932. * Test :
  82933. * Is the cullable object bounding sphere center in the frustum ?
  82934. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82935. */
  82936. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82937. /**
  82938. * No billboard
  82939. */
  82940. static readonly BILLBOARDMODE_NONE: number;
  82941. /** Billboard on X axis */
  82942. static readonly BILLBOARDMODE_X: number;
  82943. /** Billboard on Y axis */
  82944. static readonly BILLBOARDMODE_Y: number;
  82945. /** Billboard on Z axis */
  82946. static readonly BILLBOARDMODE_Z: number;
  82947. /** Billboard on all axes */
  82948. static readonly BILLBOARDMODE_ALL: number;
  82949. private _facetData;
  82950. /**
  82951. * The culling strategy to use to check whether the mesh must be rendered or not.
  82952. * This value can be changed at any time and will be used on the next render mesh selection.
  82953. * The possible values are :
  82954. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82955. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82956. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82957. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82958. * Please read each static variable documentation to get details about the culling process.
  82959. * */
  82960. cullingStrategy: number;
  82961. /**
  82962. * Gets the number of facets in the mesh
  82963. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82964. */
  82965. readonly facetNb: number;
  82966. /**
  82967. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82969. */
  82970. partitioningSubdivisions: number;
  82971. /**
  82972. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82973. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82975. */
  82976. partitioningBBoxRatio: number;
  82977. /**
  82978. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  82979. * Works only for updatable meshes.
  82980. * Doesn't work with multi-materials
  82981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82982. */
  82983. mustDepthSortFacets: boolean;
  82984. /**
  82985. * The location (Vector3) where the facet depth sort must be computed from.
  82986. * By default, the active camera position.
  82987. * Used only when facet depth sort is enabled
  82988. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82989. */
  82990. facetDepthSortFrom: Vector3;
  82991. /**
  82992. * gets a boolean indicating if facetData is enabled
  82993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82994. */
  82995. readonly isFacetDataEnabled: boolean;
  82996. /** @hidden */
  82997. _updateNonUniformScalingState(value: boolean): boolean;
  82998. /**
  82999. * An event triggered when this mesh collides with another one
  83000. */
  83001. onCollideObservable: Observable<AbstractMesh>;
  83002. private _onCollideObserver;
  83003. /** Set a function to call when this mesh collides with another one */
  83004. onCollide: () => void;
  83005. /**
  83006. * An event triggered when the collision's position changes
  83007. */
  83008. onCollisionPositionChangeObservable: Observable<Vector3>;
  83009. private _onCollisionPositionChangeObserver;
  83010. /** Set a function to call when the collision's position changes */
  83011. onCollisionPositionChange: () => void;
  83012. /**
  83013. * An event triggered when material is changed
  83014. */
  83015. onMaterialChangedObservable: Observable<AbstractMesh>;
  83016. /**
  83017. * Gets or sets the orientation for POV movement & rotation
  83018. */
  83019. definedFacingForward: boolean;
  83020. /** @hidden */
  83021. _occlusionQuery: Nullable<WebGLQuery>;
  83022. private _visibility;
  83023. /**
  83024. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83025. */
  83026. /**
  83027. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83028. */
  83029. visibility: number;
  83030. /** Gets or sets the alpha index used to sort transparent meshes
  83031. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83032. */
  83033. alphaIndex: number;
  83034. /**
  83035. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83036. */
  83037. isVisible: boolean;
  83038. /**
  83039. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83040. */
  83041. isPickable: boolean;
  83042. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  83043. showSubMeshesBoundingBox: boolean;
  83044. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  83045. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  83046. */
  83047. isBlocker: boolean;
  83048. /**
  83049. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  83050. */
  83051. enablePointerMoveEvents: boolean;
  83052. /**
  83053. * Specifies the rendering group id for this mesh (0 by default)
  83054. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83055. */
  83056. renderingGroupId: number;
  83057. private _material;
  83058. /** Gets or sets current material */
  83059. material: Nullable<Material>;
  83060. private _receiveShadows;
  83061. /**
  83062. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  83063. * @see http://doc.babylonjs.com/babylon101/shadows
  83064. */
  83065. receiveShadows: boolean;
  83066. /** Defines color to use when rendering outline */
  83067. outlineColor: Color3;
  83068. /** Define width to use when rendering outline */
  83069. outlineWidth: number;
  83070. /** Defines color to use when rendering overlay */
  83071. overlayColor: Color3;
  83072. /** Defines alpha to use when rendering overlay */
  83073. overlayAlpha: number;
  83074. private _hasVertexAlpha;
  83075. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  83076. hasVertexAlpha: boolean;
  83077. private _useVertexColors;
  83078. /** 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) */
  83079. useVertexColors: boolean;
  83080. private _computeBonesUsingShaders;
  83081. /**
  83082. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  83083. */
  83084. computeBonesUsingShaders: boolean;
  83085. private _numBoneInfluencers;
  83086. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  83087. numBoneInfluencers: number;
  83088. private _applyFog;
  83089. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  83090. applyFog: boolean;
  83091. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  83092. useOctreeForRenderingSelection: boolean;
  83093. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  83094. useOctreeForPicking: boolean;
  83095. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  83096. useOctreeForCollisions: boolean;
  83097. private _layerMask;
  83098. /**
  83099. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  83100. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  83101. */
  83102. layerMask: number;
  83103. /**
  83104. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  83105. */
  83106. alwaysSelectAsActiveMesh: boolean;
  83107. /**
  83108. * Gets or sets the current action manager
  83109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83110. */
  83111. actionManager: Nullable<AbstractActionManager>;
  83112. private _checkCollisions;
  83113. private _collisionMask;
  83114. private _collisionGroup;
  83115. /**
  83116. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  83117. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83118. */
  83119. ellipsoid: Vector3;
  83120. /**
  83121. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  83122. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83123. */
  83124. ellipsoidOffset: Vector3;
  83125. private _collider;
  83126. private _oldPositionForCollisions;
  83127. private _diffPositionForCollisions;
  83128. /**
  83129. * Gets or sets a collision mask used to mask collisions (default is -1).
  83130. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83131. */
  83132. collisionMask: number;
  83133. /**
  83134. * Gets or sets the current collision group mask (-1 by default).
  83135. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83136. */
  83137. collisionGroup: number;
  83138. /**
  83139. * Defines edge width used when edgesRenderer is enabled
  83140. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83141. */
  83142. edgesWidth: number;
  83143. /**
  83144. * Defines edge color used when edgesRenderer is enabled
  83145. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83146. */
  83147. edgesColor: Color4;
  83148. /** @hidden */
  83149. _edgesRenderer: Nullable<IEdgesRenderer>;
  83150. /** @hidden */
  83151. _masterMesh: Nullable<AbstractMesh>;
  83152. /** @hidden */
  83153. _boundingInfo: Nullable<BoundingInfo>;
  83154. /** @hidden */
  83155. _renderId: number;
  83156. /**
  83157. * Gets or sets the list of subMeshes
  83158. * @see http://doc.babylonjs.com/how_to/multi_materials
  83159. */
  83160. subMeshes: SubMesh[];
  83161. /** @hidden */
  83162. _intersectionsInProgress: AbstractMesh[];
  83163. /** @hidden */
  83164. _unIndexed: boolean;
  83165. /** @hidden */
  83166. _lightSources: Light[];
  83167. /** @hidden */
  83168. readonly _positions: Nullable<Vector3[]>;
  83169. /** @hidden */
  83170. _waitingActions: any;
  83171. /** @hidden */
  83172. _waitingFreezeWorldMatrix: Nullable<boolean>;
  83173. private _skeleton;
  83174. /** @hidden */
  83175. _bonesTransformMatrices: Nullable<Float32Array>;
  83176. /**
  83177. * Gets or sets a skeleton to apply skining transformations
  83178. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  83179. */
  83180. skeleton: Nullable<Skeleton>;
  83181. /**
  83182. * An event triggered when the mesh is rebuilt.
  83183. */
  83184. onRebuildObservable: Observable<AbstractMesh>;
  83185. /**
  83186. * Creates a new AbstractMesh
  83187. * @param name defines the name of the mesh
  83188. * @param scene defines the hosting scene
  83189. */
  83190. constructor(name: string, scene?: Nullable<Scene>);
  83191. /**
  83192. * Returns the string "AbstractMesh"
  83193. * @returns "AbstractMesh"
  83194. */
  83195. getClassName(): string;
  83196. /**
  83197. * Gets a string representation of the current mesh
  83198. * @param fullDetails defines a boolean indicating if full details must be included
  83199. * @returns a string representation of the current mesh
  83200. */
  83201. toString(fullDetails?: boolean): string;
  83202. /** @hidden */
  83203. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83204. /** @hidden */
  83205. _rebuild(): void;
  83206. /** @hidden */
  83207. _resyncLightSources(): void;
  83208. /** @hidden */
  83209. _resyncLighSource(light: Light): void;
  83210. /** @hidden */
  83211. _unBindEffect(): void;
  83212. /** @hidden */
  83213. _removeLightSource(light: Light): void;
  83214. private _markSubMeshesAsDirty;
  83215. /** @hidden */
  83216. _markSubMeshesAsLightDirty(): void;
  83217. /** @hidden */
  83218. _markSubMeshesAsAttributesDirty(): void;
  83219. /** @hidden */
  83220. _markSubMeshesAsMiscDirty(): void;
  83221. /**
  83222. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  83223. */
  83224. scaling: Vector3;
  83225. /**
  83226. * Returns true if the mesh is blocked. Implemented by child classes
  83227. */
  83228. readonly isBlocked: boolean;
  83229. /**
  83230. * Returns the mesh itself by default. Implemented by child classes
  83231. * @param camera defines the camera to use to pick the right LOD level
  83232. * @returns the currentAbstractMesh
  83233. */
  83234. getLOD(camera: Camera): Nullable<AbstractMesh>;
  83235. /**
  83236. * Returns 0 by default. Implemented by child classes
  83237. * @returns an integer
  83238. */
  83239. getTotalVertices(): number;
  83240. /**
  83241. * Returns a positive integer : the total number of indices in this mesh geometry.
  83242. * @returns the numner of indices or zero if the mesh has no geometry.
  83243. */
  83244. getTotalIndices(): number;
  83245. /**
  83246. * Returns null by default. Implemented by child classes
  83247. * @returns null
  83248. */
  83249. getIndices(): Nullable<IndicesArray>;
  83250. /**
  83251. * Returns the array of the requested vertex data kind. Implemented by child classes
  83252. * @param kind defines the vertex data kind to use
  83253. * @returns null
  83254. */
  83255. getVerticesData(kind: string): Nullable<FloatArray>;
  83256. /**
  83257. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83258. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83259. * Note that a new underlying VertexBuffer object is created each call.
  83260. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83261. * @param kind defines vertex data kind:
  83262. * * VertexBuffer.PositionKind
  83263. * * VertexBuffer.UVKind
  83264. * * VertexBuffer.UV2Kind
  83265. * * VertexBuffer.UV3Kind
  83266. * * VertexBuffer.UV4Kind
  83267. * * VertexBuffer.UV5Kind
  83268. * * VertexBuffer.UV6Kind
  83269. * * VertexBuffer.ColorKind
  83270. * * VertexBuffer.MatricesIndicesKind
  83271. * * VertexBuffer.MatricesIndicesExtraKind
  83272. * * VertexBuffer.MatricesWeightsKind
  83273. * * VertexBuffer.MatricesWeightsExtraKind
  83274. * @param data defines the data source
  83275. * @param updatable defines if the data must be flagged as updatable (or static)
  83276. * @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
  83277. * @returns the current mesh
  83278. */
  83279. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83280. /**
  83281. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83282. * If the mesh has no geometry, it is simply returned as it is.
  83283. * @param kind defines vertex data kind:
  83284. * * VertexBuffer.PositionKind
  83285. * * VertexBuffer.UVKind
  83286. * * VertexBuffer.UV2Kind
  83287. * * VertexBuffer.UV3Kind
  83288. * * VertexBuffer.UV4Kind
  83289. * * VertexBuffer.UV5Kind
  83290. * * VertexBuffer.UV6Kind
  83291. * * VertexBuffer.ColorKind
  83292. * * VertexBuffer.MatricesIndicesKind
  83293. * * VertexBuffer.MatricesIndicesExtraKind
  83294. * * VertexBuffer.MatricesWeightsKind
  83295. * * VertexBuffer.MatricesWeightsExtraKind
  83296. * @param data defines the data source
  83297. * @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
  83298. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  83299. * @returns the current mesh
  83300. */
  83301. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  83302. /**
  83303. * Sets the mesh indices,
  83304. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83305. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  83306. * @param totalVertices Defines the total number of vertices
  83307. * @returns the current mesh
  83308. */
  83309. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  83310. /**
  83311. * Gets a boolean indicating if specific vertex data is present
  83312. * @param kind defines the vertex data kind to use
  83313. * @returns true is data kind is present
  83314. */
  83315. isVerticesDataPresent(kind: string): boolean;
  83316. /**
  83317. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  83318. * @returns a BoundingInfo
  83319. */
  83320. getBoundingInfo(): BoundingInfo;
  83321. /**
  83322. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83323. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83324. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83325. * @returns the current mesh
  83326. */
  83327. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  83328. /**
  83329. * Overwrite the current bounding info
  83330. * @param boundingInfo defines the new bounding info
  83331. * @returns the current mesh
  83332. */
  83333. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  83334. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  83335. readonly useBones: boolean;
  83336. /** @hidden */
  83337. _preActivate(): void;
  83338. /** @hidden */
  83339. _preActivateForIntermediateRendering(renderId: number): void;
  83340. /** @hidden */
  83341. _activate(renderId: number): void;
  83342. /**
  83343. * Gets the current world matrix
  83344. * @returns a Matrix
  83345. */
  83346. getWorldMatrix(): Matrix;
  83347. /** @hidden */
  83348. _getWorldMatrixDeterminant(): number;
  83349. /**
  83350. * Perform relative position change from the point of view of behind the front of the mesh.
  83351. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83352. * Supports definition of mesh facing forward or backward
  83353. * @param amountRight defines the distance on the right axis
  83354. * @param amountUp defines the distance on the up axis
  83355. * @param amountForward defines the distance on the forward axis
  83356. * @returns the current mesh
  83357. */
  83358. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  83359. /**
  83360. * Calculate relative position change from the point of view of behind the front of the mesh.
  83361. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83362. * Supports definition of mesh facing forward or backward
  83363. * @param amountRight defines the distance on the right axis
  83364. * @param amountUp defines the distance on the up axis
  83365. * @param amountForward defines the distance on the forward axis
  83366. * @returns the new displacement vector
  83367. */
  83368. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  83369. /**
  83370. * Perform relative rotation change from the point of view of behind the front of the mesh.
  83371. * Supports definition of mesh facing forward or backward
  83372. * @param flipBack defines the flip
  83373. * @param twirlClockwise defines the twirl
  83374. * @param tiltRight defines the tilt
  83375. * @returns the current mesh
  83376. */
  83377. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  83378. /**
  83379. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  83380. * Supports definition of mesh facing forward or backward.
  83381. * @param flipBack defines the flip
  83382. * @param twirlClockwise defines the twirl
  83383. * @param tiltRight defines the tilt
  83384. * @returns the new rotation vector
  83385. */
  83386. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  83387. /**
  83388. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  83389. * @param includeDescendants Include bounding info from descendants as well (true by default)
  83390. * @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
  83391. * @returns the new bounding vectors
  83392. */
  83393. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  83394. min: Vector3;
  83395. max: Vector3;
  83396. };
  83397. /**
  83398. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83399. * This means the mesh underlying bounding box and sphere are recomputed.
  83400. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83401. * @returns the current mesh
  83402. */
  83403. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  83404. /** @hidden */
  83405. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  83406. /** @hidden */
  83407. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  83408. /** @hidden */
  83409. _updateBoundingInfo(): AbstractMesh;
  83410. /** @hidden */
  83411. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  83412. /** @hidden */
  83413. protected _afterComputeWorldMatrix(): void;
  83414. /** @hidden */
  83415. readonly _effectiveMesh: AbstractMesh;
  83416. /**
  83417. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83418. * A mesh is in the frustum if its bounding box intersects the frustum
  83419. * @param frustumPlanes defines the frustum to test
  83420. * @returns true if the mesh is in the frustum planes
  83421. */
  83422. isInFrustum(frustumPlanes: Plane[]): boolean;
  83423. /**
  83424. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83425. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83426. * @param frustumPlanes defines the frustum to test
  83427. * @returns true if the mesh is completely in the frustum planes
  83428. */
  83429. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83430. /**
  83431. * True if the mesh intersects another mesh or a SolidParticle object
  83432. * @param mesh defines a target mesh or SolidParticle to test
  83433. * @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)
  83434. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83435. * @returns true if there is an intersection
  83436. */
  83437. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  83438. /**
  83439. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83440. * @param point defines the point to test
  83441. * @returns true if there is an intersection
  83442. */
  83443. intersectsPoint(point: Vector3): boolean;
  83444. /**
  83445. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83446. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83447. */
  83448. checkCollisions: boolean;
  83449. /**
  83450. * Gets Collider object used to compute collisions (not physics)
  83451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83452. */
  83453. readonly collider: Collider;
  83454. /**
  83455. * Move the mesh using collision engine
  83456. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83457. * @param displacement defines the requested displacement vector
  83458. * @returns the current mesh
  83459. */
  83460. moveWithCollisions(displacement: Vector3): AbstractMesh;
  83461. private _onCollisionPositionChange;
  83462. /** @hidden */
  83463. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  83464. /** @hidden */
  83465. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  83466. /** @hidden */
  83467. _checkCollision(collider: Collider): AbstractMesh;
  83468. /** @hidden */
  83469. _generatePointsArray(): boolean;
  83470. /**
  83471. * Checks if the passed Ray intersects with the mesh
  83472. * @param ray defines the ray to use
  83473. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83474. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83475. * @returns the picking info
  83476. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83477. */
  83478. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  83479. /**
  83480. * Clones the current mesh
  83481. * @param name defines the mesh name
  83482. * @param newParent defines the new mesh parent
  83483. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83484. * @returns the new mesh
  83485. */
  83486. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83487. /**
  83488. * Disposes all the submeshes of the current meshnp
  83489. * @returns the current mesh
  83490. */
  83491. releaseSubMeshes(): AbstractMesh;
  83492. /**
  83493. * Releases resources associated with this abstract mesh.
  83494. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83495. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83496. */
  83497. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83498. /**
  83499. * Adds the passed mesh as a child to the current mesh
  83500. * @param mesh defines the child mesh
  83501. * @returns the current mesh
  83502. */
  83503. addChild(mesh: AbstractMesh): AbstractMesh;
  83504. /**
  83505. * Removes the passed mesh from the current mesh children list
  83506. * @param mesh defines the child mesh
  83507. * @returns the current mesh
  83508. */
  83509. removeChild(mesh: AbstractMesh): AbstractMesh;
  83510. /** @hidden */
  83511. private _initFacetData;
  83512. /**
  83513. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83514. * This method can be called within the render loop.
  83515. * 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
  83516. * @returns the current mesh
  83517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83518. */
  83519. updateFacetData(): AbstractMesh;
  83520. /**
  83521. * Returns the facetLocalNormals array.
  83522. * The normals are expressed in the mesh local spac
  83523. * @returns an array of Vector3
  83524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83525. */
  83526. getFacetLocalNormals(): Vector3[];
  83527. /**
  83528. * Returns the facetLocalPositions array.
  83529. * The facet positions are expressed in the mesh local space
  83530. * @returns an array of Vector3
  83531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83532. */
  83533. getFacetLocalPositions(): Vector3[];
  83534. /**
  83535. * Returns the facetLocalPartioning array
  83536. * @returns an array of array of numbers
  83537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83538. */
  83539. getFacetLocalPartitioning(): number[][];
  83540. /**
  83541. * Returns the i-th facet position in the world system.
  83542. * This method allocates a new Vector3 per call
  83543. * @param i defines the facet index
  83544. * @returns a new Vector3
  83545. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83546. */
  83547. getFacetPosition(i: number): Vector3;
  83548. /**
  83549. * Sets the reference Vector3 with the i-th facet position in the world system
  83550. * @param i defines the facet index
  83551. * @param ref defines the target vector
  83552. * @returns the current mesh
  83553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83554. */
  83555. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  83556. /**
  83557. * Returns the i-th facet normal in the world system.
  83558. * This method allocates a new Vector3 per call
  83559. * @param i defines the facet index
  83560. * @returns a new Vector3
  83561. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83562. */
  83563. getFacetNormal(i: number): Vector3;
  83564. /**
  83565. * Sets the reference Vector3 with the i-th facet normal in the world system
  83566. * @param i defines the facet index
  83567. * @param ref defines the target vector
  83568. * @returns the current mesh
  83569. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83570. */
  83571. getFacetNormalToRef(i: number, ref: Vector3): this;
  83572. /**
  83573. * 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)
  83574. * @param x defines x coordinate
  83575. * @param y defines y coordinate
  83576. * @param z defines z coordinate
  83577. * @returns the array of facet indexes
  83578. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83579. */
  83580. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  83581. /**
  83582. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83583. * @param projected sets as the (x,y,z) world projection on the facet
  83584. * @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
  83585. * @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
  83586. * @param x defines x coordinate
  83587. * @param y defines y coordinate
  83588. * @param z defines z coordinate
  83589. * @returns the face index if found (or null instead)
  83590. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83591. */
  83592. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83593. /**
  83594. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83595. * @param projected sets as the (x,y,z) local projection on the facet
  83596. * @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
  83597. * @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
  83598. * @param x defines x coordinate
  83599. * @param y defines y coordinate
  83600. * @param z defines z coordinate
  83601. * @returns the face index if found (or null instead)
  83602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83603. */
  83604. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83605. /**
  83606. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83607. * @returns the parameters
  83608. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83609. */
  83610. getFacetDataParameters(): any;
  83611. /**
  83612. * Disables the feature FacetData and frees the related memory
  83613. * @returns the current mesh
  83614. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83615. */
  83616. disableFacetData(): AbstractMesh;
  83617. /**
  83618. * Updates the AbstractMesh indices array
  83619. * @param indices defines the data source
  83620. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83621. * @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)
  83622. * @returns the current mesh
  83623. */
  83624. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  83625. /**
  83626. * Creates new normals data for the mesh
  83627. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83628. * @returns the current mesh
  83629. */
  83630. createNormals(updatable: boolean): AbstractMesh;
  83631. /**
  83632. * Align the mesh with a normal
  83633. * @param normal defines the normal to use
  83634. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83635. * @returns the current mesh
  83636. */
  83637. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  83638. /** @hidden */
  83639. _checkOcclusionQuery(): boolean;
  83640. }
  83641. }
  83642. declare module BABYLON {
  83643. /**
  83644. * Interface used to define ActionEvent
  83645. */
  83646. export interface IActionEvent {
  83647. /** The mesh or sprite that triggered the action */
  83648. source: any;
  83649. /** The X mouse cursor position at the time of the event */
  83650. pointerX: number;
  83651. /** The Y mouse cursor position at the time of the event */
  83652. pointerY: number;
  83653. /** The mesh that is currently pointed at (can be null) */
  83654. meshUnderPointer: Nullable<AbstractMesh>;
  83655. /** the original (browser) event that triggered the ActionEvent */
  83656. sourceEvent?: any;
  83657. /** additional data for the event */
  83658. additionalData?: any;
  83659. }
  83660. /**
  83661. * ActionEvent is the event being sent when an action is triggered.
  83662. */
  83663. export class ActionEvent implements IActionEvent {
  83664. /** The mesh or sprite that triggered the action */
  83665. source: any;
  83666. /** The X mouse cursor position at the time of the event */
  83667. pointerX: number;
  83668. /** The Y mouse cursor position at the time of the event */
  83669. pointerY: number;
  83670. /** The mesh that is currently pointed at (can be null) */
  83671. meshUnderPointer: Nullable<AbstractMesh>;
  83672. /** the original (browser) event that triggered the ActionEvent */
  83673. sourceEvent?: any;
  83674. /** additional data for the event */
  83675. additionalData?: any;
  83676. /**
  83677. * Creates a new ActionEvent
  83678. * @param source The mesh or sprite that triggered the action
  83679. * @param pointerX The X mouse cursor position at the time of the event
  83680. * @param pointerY The Y mouse cursor position at the time of the event
  83681. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  83682. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  83683. * @param additionalData additional data for the event
  83684. */
  83685. constructor(
  83686. /** The mesh or sprite that triggered the action */
  83687. source: any,
  83688. /** The X mouse cursor position at the time of the event */
  83689. pointerX: number,
  83690. /** The Y mouse cursor position at the time of the event */
  83691. pointerY: number,
  83692. /** The mesh that is currently pointed at (can be null) */
  83693. meshUnderPointer: Nullable<AbstractMesh>,
  83694. /** the original (browser) event that triggered the ActionEvent */
  83695. sourceEvent?: any,
  83696. /** additional data for the event */
  83697. additionalData?: any);
  83698. /**
  83699. * Helper function to auto-create an ActionEvent from a source mesh.
  83700. * @param source The source mesh that triggered the event
  83701. * @param evt The original (browser) event
  83702. * @param additionalData additional data for the event
  83703. * @returns the new ActionEvent
  83704. */
  83705. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  83706. /**
  83707. * Helper function to auto-create an ActionEvent from a source sprite
  83708. * @param source The source sprite that triggered the event
  83709. * @param scene Scene associated with the sprite
  83710. * @param evt The original (browser) event
  83711. * @param additionalData additional data for the event
  83712. * @returns the new ActionEvent
  83713. */
  83714. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  83715. /**
  83716. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  83717. * @param scene the scene where the event occurred
  83718. * @param evt The original (browser) event
  83719. * @returns the new ActionEvent
  83720. */
  83721. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  83722. /**
  83723. * Helper function to auto-create an ActionEvent from a primitive
  83724. * @param prim defines the target primitive
  83725. * @param pointerPos defines the pointer position
  83726. * @param evt The original (browser) event
  83727. * @param additionalData additional data for the event
  83728. * @returns the new ActionEvent
  83729. */
  83730. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  83731. }
  83732. }
  83733. declare module BABYLON {
  83734. /**
  83735. * Abstract class used to decouple action Manager from scene and meshes.
  83736. * Do not instantiate.
  83737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83738. */
  83739. export abstract class AbstractActionManager implements IDisposable {
  83740. /** Gets the list of active triggers */
  83741. static Triggers: {
  83742. [key: string]: number;
  83743. };
  83744. /** Gets the cursor to use when hovering items */
  83745. hoverCursor: string;
  83746. /** Gets the list of actions */
  83747. actions: IAction[];
  83748. /**
  83749. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  83750. */
  83751. isRecursive: boolean;
  83752. /**
  83753. * Releases all associated resources
  83754. */
  83755. abstract dispose(): void;
  83756. /**
  83757. * Does this action manager has pointer triggers
  83758. */
  83759. abstract readonly hasPointerTriggers: boolean;
  83760. /**
  83761. * Does this action manager has pick triggers
  83762. */
  83763. abstract readonly hasPickTriggers: boolean;
  83764. /**
  83765. * Process a specific trigger
  83766. * @param trigger defines the trigger to process
  83767. * @param evt defines the event details to be processed
  83768. */
  83769. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  83770. /**
  83771. * Does this action manager handles actions of any of the given triggers
  83772. * @param triggers defines the triggers to be tested
  83773. * @return a boolean indicating whether one (or more) of the triggers is handled
  83774. */
  83775. abstract hasSpecificTriggers(triggers: number[]): boolean;
  83776. /**
  83777. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  83778. * speed.
  83779. * @param triggerA defines the trigger to be tested
  83780. * @param triggerB defines the trigger to be tested
  83781. * @return a boolean indicating whether one (or more) of the triggers is handled
  83782. */
  83783. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  83784. /**
  83785. * Does this action manager handles actions of a given trigger
  83786. * @param trigger defines the trigger to be tested
  83787. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  83788. * @return whether the trigger is handled
  83789. */
  83790. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  83791. /**
  83792. * Serialize this manager to a JSON object
  83793. * @param name defines the property name to store this manager
  83794. * @returns a JSON representation of this manager
  83795. */
  83796. abstract serialize(name: string): any;
  83797. /**
  83798. * Registers an action to this action manager
  83799. * @param action defines the action to be registered
  83800. * @return the action amended (prepared) after registration
  83801. */
  83802. abstract registerAction(action: IAction): Nullable<IAction>;
  83803. /**
  83804. * Unregisters an action to this action manager
  83805. * @param action defines the action to be unregistered
  83806. * @return a boolean indicating whether the action has been unregistered
  83807. */
  83808. abstract unregisterAction(action: IAction): Boolean;
  83809. /**
  83810. * Does exist one action manager with at least one trigger
  83811. **/
  83812. static readonly HasTriggers: boolean;
  83813. /**
  83814. * Does exist one action manager with at least one pick trigger
  83815. **/
  83816. static readonly HasPickTriggers: boolean;
  83817. /**
  83818. * Does exist one action manager that handles actions of a given trigger
  83819. * @param trigger defines the trigger to be tested
  83820. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  83821. **/
  83822. static HasSpecificTrigger(trigger: number): boolean;
  83823. }
  83824. }
  83825. declare module BABYLON {
  83826. /**
  83827. * Defines how a node can be built from a string name.
  83828. */
  83829. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  83830. /**
  83831. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  83832. */
  83833. export class Node implements IBehaviorAware<Node> {
  83834. /** @hidden */
  83835. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  83836. private static _NodeConstructors;
  83837. /**
  83838. * Add a new node constructor
  83839. * @param type defines the type name of the node to construct
  83840. * @param constructorFunc defines the constructor function
  83841. */
  83842. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  83843. /**
  83844. * Returns a node constructor based on type name
  83845. * @param type defines the type name
  83846. * @param name defines the new node name
  83847. * @param scene defines the hosting scene
  83848. * @param options defines optional options to transmit to constructors
  83849. * @returns the new constructor or null
  83850. */
  83851. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  83852. /**
  83853. * Gets or sets the name of the node
  83854. */
  83855. name: string;
  83856. /**
  83857. * Gets or sets the id of the node
  83858. */
  83859. id: string;
  83860. /**
  83861. * Gets or sets the unique id of the node
  83862. */
  83863. uniqueId: number;
  83864. /**
  83865. * Gets or sets a string used to store user defined state for the node
  83866. */
  83867. state: string;
  83868. /**
  83869. * Gets or sets an object used to store user defined information for the node
  83870. */
  83871. metadata: any;
  83872. /**
  83873. * For internal use only. Please do not use.
  83874. */
  83875. reservedDataStore: any;
  83876. /**
  83877. * List of inspectable custom properties (used by the Inspector)
  83878. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83879. */
  83880. inspectableCustomProperties: IInspectable[];
  83881. /**
  83882. * Gets or sets a boolean used to define if the node must be serialized
  83883. */
  83884. doNotSerialize: boolean;
  83885. /** @hidden */
  83886. _isDisposed: boolean;
  83887. /**
  83888. * Gets a list of Animations associated with the node
  83889. */
  83890. animations: Animation[];
  83891. protected _ranges: {
  83892. [name: string]: Nullable<AnimationRange>;
  83893. };
  83894. /**
  83895. * Callback raised when the node is ready to be used
  83896. */
  83897. onReady: (node: Node) => void;
  83898. private _isEnabled;
  83899. private _isParentEnabled;
  83900. private _isReady;
  83901. /** @hidden */
  83902. _currentRenderId: number;
  83903. private _parentUpdateId;
  83904. protected _childUpdateId: number;
  83905. /** @hidden */
  83906. _waitingParentId: Nullable<string>;
  83907. /** @hidden */
  83908. _scene: Scene;
  83909. /** @hidden */
  83910. _cache: any;
  83911. private _parentNode;
  83912. private _children;
  83913. /** @hidden */
  83914. _worldMatrix: Matrix;
  83915. /** @hidden */
  83916. _worldMatrixDeterminant: number;
  83917. /** @hidden */
  83918. private _sceneRootNodesIndex;
  83919. /**
  83920. * Gets a boolean indicating if the node has been disposed
  83921. * @returns true if the node was disposed
  83922. */
  83923. isDisposed(): boolean;
  83924. /**
  83925. * Gets or sets the parent of the node (without keeping the current position in the scene)
  83926. * @see https://doc.babylonjs.com/how_to/parenting
  83927. */
  83928. parent: Nullable<Node>;
  83929. private addToSceneRootNodes;
  83930. private removeFromSceneRootNodes;
  83931. private _animationPropertiesOverride;
  83932. /**
  83933. * Gets or sets the animation properties override
  83934. */
  83935. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  83936. /**
  83937. * Gets a string idenfifying the name of the class
  83938. * @returns "Node" string
  83939. */
  83940. getClassName(): string;
  83941. /** @hidden */
  83942. readonly _isNode: boolean;
  83943. /**
  83944. * An event triggered when the mesh is disposed
  83945. */
  83946. onDisposeObservable: Observable<Node>;
  83947. private _onDisposeObserver;
  83948. /**
  83949. * Sets a callback that will be raised when the node will be disposed
  83950. */
  83951. onDispose: () => void;
  83952. /**
  83953. * Creates a new Node
  83954. * @param name the name and id to be given to this node
  83955. * @param scene the scene this node will be added to
  83956. * @param addToRootNodes the node will be added to scene.rootNodes
  83957. */
  83958. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  83959. /**
  83960. * Gets the scene of the node
  83961. * @returns a scene
  83962. */
  83963. getScene(): Scene;
  83964. /**
  83965. * Gets the engine of the node
  83966. * @returns a Engine
  83967. */
  83968. getEngine(): Engine;
  83969. private _behaviors;
  83970. /**
  83971. * Attach a behavior to the node
  83972. * @see http://doc.babylonjs.com/features/behaviour
  83973. * @param behavior defines the behavior to attach
  83974. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  83975. * @returns the current Node
  83976. */
  83977. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  83978. /**
  83979. * Remove an attached behavior
  83980. * @see http://doc.babylonjs.com/features/behaviour
  83981. * @param behavior defines the behavior to attach
  83982. * @returns the current Node
  83983. */
  83984. removeBehavior(behavior: Behavior<Node>): Node;
  83985. /**
  83986. * Gets the list of attached behaviors
  83987. * @see http://doc.babylonjs.com/features/behaviour
  83988. */
  83989. readonly behaviors: Behavior<Node>[];
  83990. /**
  83991. * Gets an attached behavior by name
  83992. * @param name defines the name of the behavior to look for
  83993. * @see http://doc.babylonjs.com/features/behaviour
  83994. * @returns null if behavior was not found else the requested behavior
  83995. */
  83996. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  83997. /**
  83998. * Returns the latest update of the World matrix
  83999. * @returns a Matrix
  84000. */
  84001. getWorldMatrix(): Matrix;
  84002. /** @hidden */
  84003. _getWorldMatrixDeterminant(): number;
  84004. /**
  84005. * Returns directly the latest state of the mesh World matrix.
  84006. * A Matrix is returned.
  84007. */
  84008. readonly worldMatrixFromCache: Matrix;
  84009. /** @hidden */
  84010. _initCache(): void;
  84011. /** @hidden */
  84012. updateCache(force?: boolean): void;
  84013. /** @hidden */
  84014. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84015. /** @hidden */
  84016. _updateCache(ignoreParentClass?: boolean): void;
  84017. /** @hidden */
  84018. _isSynchronized(): boolean;
  84019. /** @hidden */
  84020. _markSyncedWithParent(): void;
  84021. /** @hidden */
  84022. isSynchronizedWithParent(): boolean;
  84023. /** @hidden */
  84024. isSynchronized(): boolean;
  84025. /**
  84026. * Is this node ready to be used/rendered
  84027. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84028. * @return true if the node is ready
  84029. */
  84030. isReady(completeCheck?: boolean): boolean;
  84031. /**
  84032. * Is this node enabled?
  84033. * 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
  84034. * @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
  84035. * @return whether this node (and its parent) is enabled
  84036. */
  84037. isEnabled(checkAncestors?: boolean): boolean;
  84038. /** @hidden */
  84039. protected _syncParentEnabledState(): void;
  84040. /**
  84041. * Set the enabled state of this node
  84042. * @param value defines the new enabled state
  84043. */
  84044. setEnabled(value: boolean): void;
  84045. /**
  84046. * Is this node a descendant of the given node?
  84047. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  84048. * @param ancestor defines the parent node to inspect
  84049. * @returns a boolean indicating if this node is a descendant of the given node
  84050. */
  84051. isDescendantOf(ancestor: Node): boolean;
  84052. /** @hidden */
  84053. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  84054. /**
  84055. * Will return all nodes that have this node as ascendant
  84056. * @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
  84057. * @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
  84058. * @return all children nodes of all types
  84059. */
  84060. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  84061. /**
  84062. * Get all child-meshes of this node
  84063. * @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)
  84064. * @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
  84065. * @returns an array of AbstractMesh
  84066. */
  84067. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  84068. /**
  84069. * Get all direct children of this node
  84070. * @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
  84071. * @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)
  84072. * @returns an array of Node
  84073. */
  84074. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  84075. /** @hidden */
  84076. _setReady(state: boolean): void;
  84077. /**
  84078. * Get an animation by name
  84079. * @param name defines the name of the animation to look for
  84080. * @returns null if not found else the requested animation
  84081. */
  84082. getAnimationByName(name: string): Nullable<Animation>;
  84083. /**
  84084. * Creates an animation range for this node
  84085. * @param name defines the name of the range
  84086. * @param from defines the starting key
  84087. * @param to defines the end key
  84088. */
  84089. createAnimationRange(name: string, from: number, to: number): void;
  84090. /**
  84091. * Delete a specific animation range
  84092. * @param name defines the name of the range to delete
  84093. * @param deleteFrames defines if animation frames from the range must be deleted as well
  84094. */
  84095. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84096. /**
  84097. * Get an animation range by name
  84098. * @param name defines the name of the animation range to look for
  84099. * @returns null if not found else the requested animation range
  84100. */
  84101. getAnimationRange(name: string): Nullable<AnimationRange>;
  84102. /**
  84103. * Gets the list of all animation ranges defined on this node
  84104. * @returns an array
  84105. */
  84106. getAnimationRanges(): Nullable<AnimationRange>[];
  84107. /**
  84108. * Will start the animation sequence
  84109. * @param name defines the range frames for animation sequence
  84110. * @param loop defines if the animation should loop (false by default)
  84111. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  84112. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  84113. * @returns the object created for this animation. If range does not exist, it will return null
  84114. */
  84115. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84116. /**
  84117. * Serialize animation ranges into a JSON compatible object
  84118. * @returns serialization object
  84119. */
  84120. serializeAnimationRanges(): any;
  84121. /**
  84122. * Computes the world matrix of the node
  84123. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84124. * @returns the world matrix
  84125. */
  84126. computeWorldMatrix(force?: boolean): Matrix;
  84127. /**
  84128. * Releases resources associated with this node.
  84129. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84130. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84131. */
  84132. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84133. /**
  84134. * Parse animation range data from a serialization object and store them into a given node
  84135. * @param node defines where to store the animation ranges
  84136. * @param parsedNode defines the serialization object to read data from
  84137. * @param scene defines the hosting scene
  84138. */
  84139. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  84140. }
  84141. }
  84142. declare module BABYLON {
  84143. /**
  84144. * Class used to store any kind of animation
  84145. */
  84146. export class Animation {
  84147. /**Name of the animation */
  84148. name: string;
  84149. /**Property to animate */
  84150. targetProperty: string;
  84151. /**The frames per second of the animation */
  84152. framePerSecond: number;
  84153. /**The data type of the animation */
  84154. dataType: number;
  84155. /**The loop mode of the animation */
  84156. loopMode?: number | undefined;
  84157. /**Specifies if blending should be enabled */
  84158. enableBlending?: boolean | undefined;
  84159. /**
  84160. * Use matrix interpolation instead of using direct key value when animating matrices
  84161. */
  84162. static AllowMatricesInterpolation: boolean;
  84163. /**
  84164. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  84165. */
  84166. static AllowMatrixDecomposeForInterpolation: boolean;
  84167. /**
  84168. * Stores the key frames of the animation
  84169. */
  84170. private _keys;
  84171. /**
  84172. * Stores the easing function of the animation
  84173. */
  84174. private _easingFunction;
  84175. /**
  84176. * @hidden Internal use only
  84177. */
  84178. _runtimeAnimations: RuntimeAnimation[];
  84179. /**
  84180. * The set of event that will be linked to this animation
  84181. */
  84182. private _events;
  84183. /**
  84184. * Stores an array of target property paths
  84185. */
  84186. targetPropertyPath: string[];
  84187. /**
  84188. * Stores the blending speed of the animation
  84189. */
  84190. blendingSpeed: number;
  84191. /**
  84192. * Stores the animation ranges for the animation
  84193. */
  84194. private _ranges;
  84195. /**
  84196. * @hidden Internal use
  84197. */
  84198. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  84199. /**
  84200. * Sets up an animation
  84201. * @param property The property to animate
  84202. * @param animationType The animation type to apply
  84203. * @param framePerSecond The frames per second of the animation
  84204. * @param easingFunction The easing function used in the animation
  84205. * @returns The created animation
  84206. */
  84207. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  84208. /**
  84209. * Create and start an animation on a node
  84210. * @param name defines the name of the global animation that will be run on all nodes
  84211. * @param node defines the root node where the animation will take place
  84212. * @param targetProperty defines property to animate
  84213. * @param framePerSecond defines the number of frame per second yo use
  84214. * @param totalFrame defines the number of frames in total
  84215. * @param from defines the initial value
  84216. * @param to defines the final value
  84217. * @param loopMode defines which loop mode you want to use (off by default)
  84218. * @param easingFunction defines the easing function to use (linear by default)
  84219. * @param onAnimationEnd defines the callback to call when animation end
  84220. * @returns the animatable created for this animation
  84221. */
  84222. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84223. /**
  84224. * Create and start an animation on a node and its descendants
  84225. * @param name defines the name of the global animation that will be run on all nodes
  84226. * @param node defines the root node where the animation will take place
  84227. * @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
  84228. * @param targetProperty defines property to animate
  84229. * @param framePerSecond defines the number of frame per second to use
  84230. * @param totalFrame defines the number of frames in total
  84231. * @param from defines the initial value
  84232. * @param to defines the final value
  84233. * @param loopMode defines which loop mode you want to use (off by default)
  84234. * @param easingFunction defines the easing function to use (linear by default)
  84235. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84236. * @returns the list of animatables created for all nodes
  84237. * @example https://www.babylonjs-playground.com/#MH0VLI
  84238. */
  84239. 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[]>;
  84240. /**
  84241. * Creates a new animation, merges it with the existing animations and starts it
  84242. * @param name Name of the animation
  84243. * @param node Node which contains the scene that begins the animations
  84244. * @param targetProperty Specifies which property to animate
  84245. * @param framePerSecond The frames per second of the animation
  84246. * @param totalFrame The total number of frames
  84247. * @param from The frame at the beginning of the animation
  84248. * @param to The frame at the end of the animation
  84249. * @param loopMode Specifies the loop mode of the animation
  84250. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  84251. * @param onAnimationEnd Callback to run once the animation is complete
  84252. * @returns Nullable animation
  84253. */
  84254. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84255. /**
  84256. * Transition property of an host to the target Value
  84257. * @param property The property to transition
  84258. * @param targetValue The target Value of the property
  84259. * @param host The object where the property to animate belongs
  84260. * @param scene Scene used to run the animation
  84261. * @param frameRate Framerate (in frame/s) to use
  84262. * @param transition The transition type we want to use
  84263. * @param duration The duration of the animation, in milliseconds
  84264. * @param onAnimationEnd Callback trigger at the end of the animation
  84265. * @returns Nullable animation
  84266. */
  84267. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  84268. /**
  84269. * Return the array of runtime animations currently using this animation
  84270. */
  84271. readonly runtimeAnimations: RuntimeAnimation[];
  84272. /**
  84273. * Specifies if any of the runtime animations are currently running
  84274. */
  84275. readonly hasRunningRuntimeAnimations: boolean;
  84276. /**
  84277. * Initializes the animation
  84278. * @param name Name of the animation
  84279. * @param targetProperty Property to animate
  84280. * @param framePerSecond The frames per second of the animation
  84281. * @param dataType The data type of the animation
  84282. * @param loopMode The loop mode of the animation
  84283. * @param enableBlending Specifies if blending should be enabled
  84284. */
  84285. constructor(
  84286. /**Name of the animation */
  84287. name: string,
  84288. /**Property to animate */
  84289. targetProperty: string,
  84290. /**The frames per second of the animation */
  84291. framePerSecond: number,
  84292. /**The data type of the animation */
  84293. dataType: number,
  84294. /**The loop mode of the animation */
  84295. loopMode?: number | undefined,
  84296. /**Specifies if blending should be enabled */
  84297. enableBlending?: boolean | undefined);
  84298. /**
  84299. * Converts the animation to a string
  84300. * @param fullDetails support for multiple levels of logging within scene loading
  84301. * @returns String form of the animation
  84302. */
  84303. toString(fullDetails?: boolean): string;
  84304. /**
  84305. * Add an event to this animation
  84306. * @param event Event to add
  84307. */
  84308. addEvent(event: AnimationEvent): void;
  84309. /**
  84310. * Remove all events found at the given frame
  84311. * @param frame The frame to remove events from
  84312. */
  84313. removeEvents(frame: number): void;
  84314. /**
  84315. * Retrieves all the events from the animation
  84316. * @returns Events from the animation
  84317. */
  84318. getEvents(): AnimationEvent[];
  84319. /**
  84320. * Creates an animation range
  84321. * @param name Name of the animation range
  84322. * @param from Starting frame of the animation range
  84323. * @param to Ending frame of the animation
  84324. */
  84325. createRange(name: string, from: number, to: number): void;
  84326. /**
  84327. * Deletes an animation range by name
  84328. * @param name Name of the animation range to delete
  84329. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  84330. */
  84331. deleteRange(name: string, deleteFrames?: boolean): void;
  84332. /**
  84333. * Gets the animation range by name, or null if not defined
  84334. * @param name Name of the animation range
  84335. * @returns Nullable animation range
  84336. */
  84337. getRange(name: string): Nullable<AnimationRange>;
  84338. /**
  84339. * Gets the key frames from the animation
  84340. * @returns The key frames of the animation
  84341. */
  84342. getKeys(): Array<IAnimationKey>;
  84343. /**
  84344. * Gets the highest frame rate of the animation
  84345. * @returns Highest frame rate of the animation
  84346. */
  84347. getHighestFrame(): number;
  84348. /**
  84349. * Gets the easing function of the animation
  84350. * @returns Easing function of the animation
  84351. */
  84352. getEasingFunction(): IEasingFunction;
  84353. /**
  84354. * Sets the easing function of the animation
  84355. * @param easingFunction A custom mathematical formula for animation
  84356. */
  84357. setEasingFunction(easingFunction: EasingFunction): void;
  84358. /**
  84359. * Interpolates a scalar linearly
  84360. * @param startValue Start value of the animation curve
  84361. * @param endValue End value of the animation curve
  84362. * @param gradient Scalar amount to interpolate
  84363. * @returns Interpolated scalar value
  84364. */
  84365. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  84366. /**
  84367. * Interpolates a scalar cubically
  84368. * @param startValue Start value of the animation curve
  84369. * @param outTangent End tangent of the animation
  84370. * @param endValue End value of the animation curve
  84371. * @param inTangent Start tangent of the animation curve
  84372. * @param gradient Scalar amount to interpolate
  84373. * @returns Interpolated scalar value
  84374. */
  84375. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  84376. /**
  84377. * Interpolates a quaternion using a spherical linear interpolation
  84378. * @param startValue Start value of the animation curve
  84379. * @param endValue End value of the animation curve
  84380. * @param gradient Scalar amount to interpolate
  84381. * @returns Interpolated quaternion value
  84382. */
  84383. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  84384. /**
  84385. * Interpolates a quaternion cubically
  84386. * @param startValue Start value of the animation curve
  84387. * @param outTangent End tangent of the animation curve
  84388. * @param endValue End value of the animation curve
  84389. * @param inTangent Start tangent of the animation curve
  84390. * @param gradient Scalar amount to interpolate
  84391. * @returns Interpolated quaternion value
  84392. */
  84393. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  84394. /**
  84395. * Interpolates a Vector3 linearl
  84396. * @param startValue Start value of the animation curve
  84397. * @param endValue End value of the animation curve
  84398. * @param gradient Scalar amount to interpolate
  84399. * @returns Interpolated scalar value
  84400. */
  84401. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  84402. /**
  84403. * Interpolates a Vector3 cubically
  84404. * @param startValue Start value of the animation curve
  84405. * @param outTangent End tangent of the animation
  84406. * @param endValue End value of the animation curve
  84407. * @param inTangent Start tangent of the animation curve
  84408. * @param gradient Scalar amount to interpolate
  84409. * @returns InterpolatedVector3 value
  84410. */
  84411. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  84412. /**
  84413. * Interpolates a Vector2 linearly
  84414. * @param startValue Start value of the animation curve
  84415. * @param endValue End value of the animation curve
  84416. * @param gradient Scalar amount to interpolate
  84417. * @returns Interpolated Vector2 value
  84418. */
  84419. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  84420. /**
  84421. * Interpolates a Vector2 cubically
  84422. * @param startValue Start value of the animation curve
  84423. * @param outTangent End tangent of the animation
  84424. * @param endValue End value of the animation curve
  84425. * @param inTangent Start tangent of the animation curve
  84426. * @param gradient Scalar amount to interpolate
  84427. * @returns Interpolated Vector2 value
  84428. */
  84429. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  84430. /**
  84431. * Interpolates a size linearly
  84432. * @param startValue Start value of the animation curve
  84433. * @param endValue End value of the animation curve
  84434. * @param gradient Scalar amount to interpolate
  84435. * @returns Interpolated Size value
  84436. */
  84437. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  84438. /**
  84439. * Interpolates a Color3 linearly
  84440. * @param startValue Start value of the animation curve
  84441. * @param endValue End value of the animation curve
  84442. * @param gradient Scalar amount to interpolate
  84443. * @returns Interpolated Color3 value
  84444. */
  84445. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  84446. /**
  84447. * @hidden Internal use only
  84448. */
  84449. _getKeyValue(value: any): any;
  84450. /**
  84451. * @hidden Internal use only
  84452. */
  84453. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  84454. /**
  84455. * Defines the function to use to interpolate matrices
  84456. * @param startValue defines the start matrix
  84457. * @param endValue defines the end matrix
  84458. * @param gradient defines the gradient between both matrices
  84459. * @param result defines an optional target matrix where to store the interpolation
  84460. * @returns the interpolated matrix
  84461. */
  84462. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  84463. /**
  84464. * Makes a copy of the animation
  84465. * @returns Cloned animation
  84466. */
  84467. clone(): Animation;
  84468. /**
  84469. * Sets the key frames of the animation
  84470. * @param values The animation key frames to set
  84471. */
  84472. setKeys(values: Array<IAnimationKey>): void;
  84473. /**
  84474. * Serializes the animation to an object
  84475. * @returns Serialized object
  84476. */
  84477. serialize(): any;
  84478. /**
  84479. * Float animation type
  84480. */
  84481. private static _ANIMATIONTYPE_FLOAT;
  84482. /**
  84483. * Vector3 animation type
  84484. */
  84485. private static _ANIMATIONTYPE_VECTOR3;
  84486. /**
  84487. * Quaternion animation type
  84488. */
  84489. private static _ANIMATIONTYPE_QUATERNION;
  84490. /**
  84491. * Matrix animation type
  84492. */
  84493. private static _ANIMATIONTYPE_MATRIX;
  84494. /**
  84495. * Color3 animation type
  84496. */
  84497. private static _ANIMATIONTYPE_COLOR3;
  84498. /**
  84499. * Vector2 animation type
  84500. */
  84501. private static _ANIMATIONTYPE_VECTOR2;
  84502. /**
  84503. * Size animation type
  84504. */
  84505. private static _ANIMATIONTYPE_SIZE;
  84506. /**
  84507. * Relative Loop Mode
  84508. */
  84509. private static _ANIMATIONLOOPMODE_RELATIVE;
  84510. /**
  84511. * Cycle Loop Mode
  84512. */
  84513. private static _ANIMATIONLOOPMODE_CYCLE;
  84514. /**
  84515. * Constant Loop Mode
  84516. */
  84517. private static _ANIMATIONLOOPMODE_CONSTANT;
  84518. /**
  84519. * Get the float animation type
  84520. */
  84521. static readonly ANIMATIONTYPE_FLOAT: number;
  84522. /**
  84523. * Get the Vector3 animation type
  84524. */
  84525. static readonly ANIMATIONTYPE_VECTOR3: number;
  84526. /**
  84527. * Get the Vector2 animation type
  84528. */
  84529. static readonly ANIMATIONTYPE_VECTOR2: number;
  84530. /**
  84531. * Get the Size animation type
  84532. */
  84533. static readonly ANIMATIONTYPE_SIZE: number;
  84534. /**
  84535. * Get the Quaternion animation type
  84536. */
  84537. static readonly ANIMATIONTYPE_QUATERNION: number;
  84538. /**
  84539. * Get the Matrix animation type
  84540. */
  84541. static readonly ANIMATIONTYPE_MATRIX: number;
  84542. /**
  84543. * Get the Color3 animation type
  84544. */
  84545. static readonly ANIMATIONTYPE_COLOR3: number;
  84546. /**
  84547. * Get the Relative Loop Mode
  84548. */
  84549. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  84550. /**
  84551. * Get the Cycle Loop Mode
  84552. */
  84553. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  84554. /**
  84555. * Get the Constant Loop Mode
  84556. */
  84557. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  84558. /** @hidden */
  84559. static _UniversalLerp(left: any, right: any, amount: number): any;
  84560. /**
  84561. * Parses an animation object and creates an animation
  84562. * @param parsedAnimation Parsed animation object
  84563. * @returns Animation object
  84564. */
  84565. static Parse(parsedAnimation: any): Animation;
  84566. /**
  84567. * Appends the serialized animations from the source animations
  84568. * @param source Source containing the animations
  84569. * @param destination Target to store the animations
  84570. */
  84571. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  84572. }
  84573. }
  84574. declare module BABYLON {
  84575. /**
  84576. * Base class of all the textures in babylon.
  84577. * It groups all the common properties the materials, post process, lights... might need
  84578. * in order to make a correct use of the texture.
  84579. */
  84580. export class BaseTexture implements IAnimatable {
  84581. /**
  84582. * Default anisotropic filtering level for the application.
  84583. * It is set to 4 as a good tradeoff between perf and quality.
  84584. */
  84585. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  84586. /**
  84587. * Gets or sets the unique id of the texture
  84588. */
  84589. uniqueId: number;
  84590. /**
  84591. * Define the name of the texture.
  84592. */
  84593. name: string;
  84594. /**
  84595. * Gets or sets an object used to store user defined information.
  84596. */
  84597. metadata: any;
  84598. /**
  84599. * For internal use only. Please do not use.
  84600. */
  84601. reservedDataStore: any;
  84602. private _hasAlpha;
  84603. /**
  84604. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  84605. */
  84606. hasAlpha: boolean;
  84607. /**
  84608. * Defines if the alpha value should be determined via the rgb values.
  84609. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  84610. */
  84611. getAlphaFromRGB: boolean;
  84612. /**
  84613. * Intensity or strength of the texture.
  84614. * It is commonly used by materials to fine tune the intensity of the texture
  84615. */
  84616. level: number;
  84617. /**
  84618. * Define the UV chanel to use starting from 0 and defaulting to 0.
  84619. * This is part of the texture as textures usually maps to one uv set.
  84620. */
  84621. coordinatesIndex: number;
  84622. private _coordinatesMode;
  84623. /**
  84624. * How a texture is mapped.
  84625. *
  84626. * | Value | Type | Description |
  84627. * | ----- | ----------------------------------- | ----------- |
  84628. * | 0 | EXPLICIT_MODE | |
  84629. * | 1 | SPHERICAL_MODE | |
  84630. * | 2 | PLANAR_MODE | |
  84631. * | 3 | CUBIC_MODE | |
  84632. * | 4 | PROJECTION_MODE | |
  84633. * | 5 | SKYBOX_MODE | |
  84634. * | 6 | INVCUBIC_MODE | |
  84635. * | 7 | EQUIRECTANGULAR_MODE | |
  84636. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  84637. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  84638. */
  84639. coordinatesMode: number;
  84640. /**
  84641. * | Value | Type | Description |
  84642. * | ----- | ------------------ | ----------- |
  84643. * | 0 | CLAMP_ADDRESSMODE | |
  84644. * | 1 | WRAP_ADDRESSMODE | |
  84645. * | 2 | MIRROR_ADDRESSMODE | |
  84646. */
  84647. wrapU: number;
  84648. /**
  84649. * | Value | Type | Description |
  84650. * | ----- | ------------------ | ----------- |
  84651. * | 0 | CLAMP_ADDRESSMODE | |
  84652. * | 1 | WRAP_ADDRESSMODE | |
  84653. * | 2 | MIRROR_ADDRESSMODE | |
  84654. */
  84655. wrapV: number;
  84656. /**
  84657. * | Value | Type | Description |
  84658. * | ----- | ------------------ | ----------- |
  84659. * | 0 | CLAMP_ADDRESSMODE | |
  84660. * | 1 | WRAP_ADDRESSMODE | |
  84661. * | 2 | MIRROR_ADDRESSMODE | |
  84662. */
  84663. wrapR: number;
  84664. /**
  84665. * With compliant hardware and browser (supporting anisotropic filtering)
  84666. * this defines the level of anisotropic filtering in the texture.
  84667. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  84668. */
  84669. anisotropicFilteringLevel: number;
  84670. /**
  84671. * Define if the texture is a cube texture or if false a 2d texture.
  84672. */
  84673. isCube: boolean;
  84674. /**
  84675. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  84676. */
  84677. is3D: boolean;
  84678. /**
  84679. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  84680. * HDR texture are usually stored in linear space.
  84681. * This only impacts the PBR and Background materials
  84682. */
  84683. gammaSpace: boolean;
  84684. /**
  84685. * Gets whether or not the texture contains RGBD data.
  84686. */
  84687. readonly isRGBD: boolean;
  84688. /**
  84689. * Is Z inverted in the texture (useful in a cube texture).
  84690. */
  84691. invertZ: boolean;
  84692. /**
  84693. * Are mip maps generated for this texture or not.
  84694. */
  84695. readonly noMipmap: boolean;
  84696. /**
  84697. * @hidden
  84698. */
  84699. lodLevelInAlpha: boolean;
  84700. /**
  84701. * With prefiltered texture, defined the offset used during the prefiltering steps.
  84702. */
  84703. lodGenerationOffset: number;
  84704. /**
  84705. * With prefiltered texture, defined the scale used during the prefiltering steps.
  84706. */
  84707. lodGenerationScale: number;
  84708. /**
  84709. * Define if the texture is a render target.
  84710. */
  84711. isRenderTarget: boolean;
  84712. /**
  84713. * Define the unique id of the texture in the scene.
  84714. */
  84715. readonly uid: string;
  84716. /**
  84717. * Return a string representation of the texture.
  84718. * @returns the texture as a string
  84719. */
  84720. toString(): string;
  84721. /**
  84722. * Get the class name of the texture.
  84723. * @returns "BaseTexture"
  84724. */
  84725. getClassName(): string;
  84726. /**
  84727. * Define the list of animation attached to the texture.
  84728. */
  84729. animations: Animation[];
  84730. /**
  84731. * An event triggered when the texture is disposed.
  84732. */
  84733. onDisposeObservable: Observable<BaseTexture>;
  84734. private _onDisposeObserver;
  84735. /**
  84736. * Callback triggered when the texture has been disposed.
  84737. * Kept for back compatibility, you can use the onDisposeObservable instead.
  84738. */
  84739. onDispose: () => void;
  84740. /**
  84741. * Define the current state of the loading sequence when in delayed load mode.
  84742. */
  84743. delayLoadState: number;
  84744. private _scene;
  84745. /** @hidden */
  84746. _texture: Nullable<InternalTexture>;
  84747. private _uid;
  84748. /**
  84749. * Define if the texture is preventinga material to render or not.
  84750. * If not and the texture is not ready, the engine will use a default black texture instead.
  84751. */
  84752. readonly isBlocking: boolean;
  84753. /**
  84754. * Instantiates a new BaseTexture.
  84755. * Base class of all the textures in babylon.
  84756. * It groups all the common properties the materials, post process, lights... might need
  84757. * in order to make a correct use of the texture.
  84758. * @param scene Define the scene the texture blongs to
  84759. */
  84760. constructor(scene: Nullable<Scene>);
  84761. /**
  84762. * Get the scene the texture belongs to.
  84763. * @returns the scene or null if undefined
  84764. */
  84765. getScene(): Nullable<Scene>;
  84766. /**
  84767. * Get the texture transform matrix used to offset tile the texture for istance.
  84768. * @returns the transformation matrix
  84769. */
  84770. getTextureMatrix(): Matrix;
  84771. /**
  84772. * Get the texture reflection matrix used to rotate/transform the reflection.
  84773. * @returns the reflection matrix
  84774. */
  84775. getReflectionTextureMatrix(): Matrix;
  84776. /**
  84777. * Get the underlying lower level texture from Babylon.
  84778. * @returns the insternal texture
  84779. */
  84780. getInternalTexture(): Nullable<InternalTexture>;
  84781. /**
  84782. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  84783. * @returns true if ready or not blocking
  84784. */
  84785. isReadyOrNotBlocking(): boolean;
  84786. /**
  84787. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  84788. * @returns true if fully ready
  84789. */
  84790. isReady(): boolean;
  84791. private _cachedSize;
  84792. /**
  84793. * Get the size of the texture.
  84794. * @returns the texture size.
  84795. */
  84796. getSize(): ISize;
  84797. /**
  84798. * Get the base size of the texture.
  84799. * It can be different from the size if the texture has been resized for POT for instance
  84800. * @returns the base size
  84801. */
  84802. getBaseSize(): ISize;
  84803. /**
  84804. * Update the sampling mode of the texture.
  84805. * Default is Trilinear mode.
  84806. *
  84807. * | Value | Type | Description |
  84808. * | ----- | ------------------ | ----------- |
  84809. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  84810. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  84811. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  84812. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  84813. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  84814. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  84815. * | 7 | NEAREST_LINEAR | |
  84816. * | 8 | NEAREST_NEAREST | |
  84817. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  84818. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  84819. * | 11 | LINEAR_LINEAR | |
  84820. * | 12 | LINEAR_NEAREST | |
  84821. *
  84822. * > _mag_: magnification filter (close to the viewer)
  84823. * > _min_: minification filter (far from the viewer)
  84824. * > _mip_: filter used between mip map levels
  84825. *@param samplingMode Define the new sampling mode of the texture
  84826. */
  84827. updateSamplingMode(samplingMode: number): void;
  84828. /**
  84829. * Scales the texture if is `canRescale()`
  84830. * @param ratio the resize factor we want to use to rescale
  84831. */
  84832. scale(ratio: number): void;
  84833. /**
  84834. * Get if the texture can rescale.
  84835. */
  84836. readonly canRescale: boolean;
  84837. /** @hidden */
  84838. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  84839. /** @hidden */
  84840. _rebuild(): void;
  84841. /**
  84842. * Triggers the load sequence in delayed load mode.
  84843. */
  84844. delayLoad(): void;
  84845. /**
  84846. * Clones the texture.
  84847. * @returns the cloned texture
  84848. */
  84849. clone(): Nullable<BaseTexture>;
  84850. /**
  84851. * Get the texture underlying type (INT, FLOAT...)
  84852. */
  84853. readonly textureType: number;
  84854. /**
  84855. * Get the texture underlying format (RGB, RGBA...)
  84856. */
  84857. readonly textureFormat: number;
  84858. /**
  84859. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  84860. * This will returns an RGBA array buffer containing either in values (0-255) or
  84861. * float values (0-1) depending of the underlying buffer type.
  84862. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  84863. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  84864. * @param buffer defines a user defined buffer to fill with data (can be null)
  84865. * @returns The Array buffer containing the pixels data.
  84866. */
  84867. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  84868. /**
  84869. * Release and destroy the underlying lower level texture aka internalTexture.
  84870. */
  84871. releaseInternalTexture(): void;
  84872. /**
  84873. * Get the polynomial representation of the texture data.
  84874. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  84875. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  84876. */
  84877. sphericalPolynomial: Nullable<SphericalPolynomial>;
  84878. /** @hidden */
  84879. readonly _lodTextureHigh: Nullable<BaseTexture>;
  84880. /** @hidden */
  84881. readonly _lodTextureMid: Nullable<BaseTexture>;
  84882. /** @hidden */
  84883. readonly _lodTextureLow: Nullable<BaseTexture>;
  84884. /**
  84885. * Dispose the texture and release its associated resources.
  84886. */
  84887. dispose(): void;
  84888. /**
  84889. * Serialize the texture into a JSON representation that can be parsed later on.
  84890. * @returns the JSON representation of the texture
  84891. */
  84892. serialize(): any;
  84893. /**
  84894. * Helper function to be called back once a list of texture contains only ready textures.
  84895. * @param textures Define the list of textures to wait for
  84896. * @param callback Define the callback triggered once the entire list will be ready
  84897. */
  84898. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  84899. }
  84900. }
  84901. declare module BABYLON {
  84902. /**
  84903. * Uniform buffer objects.
  84904. *
  84905. * Handles blocks of uniform on the GPU.
  84906. *
  84907. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84908. *
  84909. * For more information, please refer to :
  84910. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84911. */
  84912. export class UniformBuffer {
  84913. private _engine;
  84914. private _buffer;
  84915. private _data;
  84916. private _bufferData;
  84917. private _dynamic?;
  84918. private _uniformLocations;
  84919. private _uniformSizes;
  84920. private _uniformLocationPointer;
  84921. private _needSync;
  84922. private _noUBO;
  84923. private _currentEffect;
  84924. private static _MAX_UNIFORM_SIZE;
  84925. private static _tempBuffer;
  84926. /**
  84927. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84928. * This is dynamic to allow compat with webgl 1 and 2.
  84929. * You will need to pass the name of the uniform as well as the value.
  84930. */
  84931. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84932. /**
  84933. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84934. * This is dynamic to allow compat with webgl 1 and 2.
  84935. * You will need to pass the name of the uniform as well as the value.
  84936. */
  84937. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84938. /**
  84939. * Lambda to Update a single float in a uniform buffer.
  84940. * This is dynamic to allow compat with webgl 1 and 2.
  84941. * You will need to pass the name of the uniform as well as the value.
  84942. */
  84943. updateFloat: (name: string, x: number) => void;
  84944. /**
  84945. * Lambda to Update a vec2 of float in a uniform buffer.
  84946. * This is dynamic to allow compat with webgl 1 and 2.
  84947. * You will need to pass the name of the uniform as well as the value.
  84948. */
  84949. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84950. /**
  84951. * Lambda to Update a vec3 of float in a uniform buffer.
  84952. * This is dynamic to allow compat with webgl 1 and 2.
  84953. * You will need to pass the name of the uniform as well as the value.
  84954. */
  84955. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84956. /**
  84957. * Lambda to Update a vec4 of float in a uniform buffer.
  84958. * This is dynamic to allow compat with webgl 1 and 2.
  84959. * You will need to pass the name of the uniform as well as the value.
  84960. */
  84961. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84962. /**
  84963. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84964. * This is dynamic to allow compat with webgl 1 and 2.
  84965. * You will need to pass the name of the uniform as well as the value.
  84966. */
  84967. updateMatrix: (name: string, mat: Matrix) => void;
  84968. /**
  84969. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84970. * This is dynamic to allow compat with webgl 1 and 2.
  84971. * You will need to pass the name of the uniform as well as the value.
  84972. */
  84973. updateVector3: (name: string, vector: Vector3) => void;
  84974. /**
  84975. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84976. * This is dynamic to allow compat with webgl 1 and 2.
  84977. * You will need to pass the name of the uniform as well as the value.
  84978. */
  84979. updateVector4: (name: string, vector: Vector4) => void;
  84980. /**
  84981. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84982. * This is dynamic to allow compat with webgl 1 and 2.
  84983. * You will need to pass the name of the uniform as well as the value.
  84984. */
  84985. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84986. /**
  84987. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84988. * This is dynamic to allow compat with webgl 1 and 2.
  84989. * You will need to pass the name of the uniform as well as the value.
  84990. */
  84991. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84992. /**
  84993. * Instantiates a new Uniform buffer objects.
  84994. *
  84995. * Handles blocks of uniform on the GPU.
  84996. *
  84997. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84998. *
  84999. * For more information, please refer to :
  85000. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85001. * @param engine Define the engine the buffer is associated with
  85002. * @param data Define the data contained in the buffer
  85003. * @param dynamic Define if the buffer is updatable
  85004. */
  85005. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85006. /**
  85007. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85008. * or just falling back on setUniformXXX calls.
  85009. */
  85010. readonly useUbo: boolean;
  85011. /**
  85012. * Indicates if the WebGL underlying uniform buffer is in sync
  85013. * with the javascript cache data.
  85014. */
  85015. readonly isSync: boolean;
  85016. /**
  85017. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85018. * Also, a dynamic UniformBuffer will disable cache verification and always
  85019. * update the underlying WebGL uniform buffer to the GPU.
  85020. * @returns if Dynamic, otherwise false
  85021. */
  85022. isDynamic(): boolean;
  85023. /**
  85024. * The data cache on JS side.
  85025. * @returns the underlying data as a float array
  85026. */
  85027. getData(): Float32Array;
  85028. /**
  85029. * The underlying WebGL Uniform buffer.
  85030. * @returns the webgl buffer
  85031. */
  85032. getBuffer(): Nullable<WebGLBuffer>;
  85033. /**
  85034. * std140 layout specifies how to align data within an UBO structure.
  85035. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85036. * for specs.
  85037. */
  85038. private _fillAlignment;
  85039. /**
  85040. * Adds an uniform in the buffer.
  85041. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85042. * for the layout to be correct !
  85043. * @param name Name of the uniform, as used in the uniform block in the shader.
  85044. * @param size Data size, or data directly.
  85045. */
  85046. addUniform(name: string, size: number | number[]): void;
  85047. /**
  85048. * Adds a Matrix 4x4 to the uniform buffer.
  85049. * @param name Name of the uniform, as used in the uniform block in the shader.
  85050. * @param mat A 4x4 matrix.
  85051. */
  85052. addMatrix(name: string, mat: Matrix): void;
  85053. /**
  85054. * Adds a vec2 to the uniform buffer.
  85055. * @param name Name of the uniform, as used in the uniform block in the shader.
  85056. * @param x Define the x component value of the vec2
  85057. * @param y Define the y component value of the vec2
  85058. */
  85059. addFloat2(name: string, x: number, y: number): void;
  85060. /**
  85061. * Adds a vec3 to the uniform buffer.
  85062. * @param name Name of the uniform, as used in the uniform block in the shader.
  85063. * @param x Define the x component value of the vec3
  85064. * @param y Define the y component value of the vec3
  85065. * @param z Define the z component value of the vec3
  85066. */
  85067. addFloat3(name: string, x: number, y: number, z: number): void;
  85068. /**
  85069. * Adds a vec3 to the uniform buffer.
  85070. * @param name Name of the uniform, as used in the uniform block in the shader.
  85071. * @param color Define the vec3 from a Color
  85072. */
  85073. addColor3(name: string, color: Color3): void;
  85074. /**
  85075. * Adds a vec4 to the uniform buffer.
  85076. * @param name Name of the uniform, as used in the uniform block in the shader.
  85077. * @param color Define the rgb components from a Color
  85078. * @param alpha Define the a component of the vec4
  85079. */
  85080. addColor4(name: string, color: Color3, alpha: number): void;
  85081. /**
  85082. * Adds a vec3 to the uniform buffer.
  85083. * @param name Name of the uniform, as used in the uniform block in the shader.
  85084. * @param vector Define the vec3 components from a Vector
  85085. */
  85086. addVector3(name: string, vector: Vector3): void;
  85087. /**
  85088. * Adds a Matrix 3x3 to the uniform buffer.
  85089. * @param name Name of the uniform, as used in the uniform block in the shader.
  85090. */
  85091. addMatrix3x3(name: string): void;
  85092. /**
  85093. * Adds a Matrix 2x2 to the uniform buffer.
  85094. * @param name Name of the uniform, as used in the uniform block in the shader.
  85095. */
  85096. addMatrix2x2(name: string): void;
  85097. /**
  85098. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85099. */
  85100. create(): void;
  85101. /** @hidden */
  85102. _rebuild(): void;
  85103. /**
  85104. * Updates the WebGL Uniform Buffer on the GPU.
  85105. * If the `dynamic` flag is set to true, no cache comparison is done.
  85106. * Otherwise, the buffer will be updated only if the cache differs.
  85107. */
  85108. update(): void;
  85109. /**
  85110. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85111. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85112. * @param data Define the flattened data
  85113. * @param size Define the size of the data.
  85114. */
  85115. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85116. private _updateMatrix3x3ForUniform;
  85117. private _updateMatrix3x3ForEffect;
  85118. private _updateMatrix2x2ForEffect;
  85119. private _updateMatrix2x2ForUniform;
  85120. private _updateFloatForEffect;
  85121. private _updateFloatForUniform;
  85122. private _updateFloat2ForEffect;
  85123. private _updateFloat2ForUniform;
  85124. private _updateFloat3ForEffect;
  85125. private _updateFloat3ForUniform;
  85126. private _updateFloat4ForEffect;
  85127. private _updateFloat4ForUniform;
  85128. private _updateMatrixForEffect;
  85129. private _updateMatrixForUniform;
  85130. private _updateVector3ForEffect;
  85131. private _updateVector3ForUniform;
  85132. private _updateVector4ForEffect;
  85133. private _updateVector4ForUniform;
  85134. private _updateColor3ForEffect;
  85135. private _updateColor3ForUniform;
  85136. private _updateColor4ForEffect;
  85137. private _updateColor4ForUniform;
  85138. /**
  85139. * Sets a sampler uniform on the effect.
  85140. * @param name Define the name of the sampler.
  85141. * @param texture Define the texture to set in the sampler
  85142. */
  85143. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85144. /**
  85145. * Directly updates the value of the uniform in the cache AND on the GPU.
  85146. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85147. * @param data Define the flattened data
  85148. */
  85149. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85150. /**
  85151. * Binds this uniform buffer to an effect.
  85152. * @param effect Define the effect to bind the buffer to
  85153. * @param name Name of the uniform block in the shader.
  85154. */
  85155. bindToEffect(effect: Effect, name: string): void;
  85156. /**
  85157. * Disposes the uniform buffer.
  85158. */
  85159. dispose(): void;
  85160. }
  85161. }
  85162. declare module BABYLON {
  85163. /**
  85164. * This represents the required contract to create a new type of texture loader.
  85165. */
  85166. export interface IInternalTextureLoader {
  85167. /**
  85168. * Defines wether the loader supports cascade loading the different faces.
  85169. */
  85170. supportCascades: boolean;
  85171. /**
  85172. * This returns if the loader support the current file information.
  85173. * @param extension defines the file extension of the file being loaded
  85174. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85175. * @param fallback defines the fallback internal texture if any
  85176. * @param isBase64 defines whether the texture is encoded as a base64
  85177. * @param isBuffer defines whether the texture data are stored as a buffer
  85178. * @returns true if the loader can load the specified file
  85179. */
  85180. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  85181. /**
  85182. * Transform the url before loading if required.
  85183. * @param rootUrl the url of the texture
  85184. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85185. * @returns the transformed texture
  85186. */
  85187. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  85188. /**
  85189. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  85190. * @param rootUrl the url of the texture
  85191. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85192. * @returns the fallback texture
  85193. */
  85194. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  85195. /**
  85196. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  85197. * @param data contains the texture data
  85198. * @param texture defines the BabylonJS internal texture
  85199. * @param createPolynomials will be true if polynomials have been requested
  85200. * @param onLoad defines the callback to trigger once the texture is ready
  85201. * @param onError defines the callback to trigger in case of error
  85202. */
  85203. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  85204. /**
  85205. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  85206. * @param data contains the texture data
  85207. * @param texture defines the BabylonJS internal texture
  85208. * @param callback defines the method to call once ready to upload
  85209. */
  85210. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  85211. }
  85212. }
  85213. declare module BABYLON {
  85214. /**
  85215. * Creation options of the multi render target texture.
  85216. */
  85217. export interface IMultiRenderTargetOptions {
  85218. /**
  85219. * Define if the texture needs to create mip maps after render.
  85220. */
  85221. generateMipMaps?: boolean;
  85222. /**
  85223. * Define the types of all the draw buffers we want to create
  85224. */
  85225. types?: number[];
  85226. /**
  85227. * Define the sampling modes of all the draw buffers we want to create
  85228. */
  85229. samplingModes?: number[];
  85230. /**
  85231. * Define if a depth buffer is required
  85232. */
  85233. generateDepthBuffer?: boolean;
  85234. /**
  85235. * Define if a stencil buffer is required
  85236. */
  85237. generateStencilBuffer?: boolean;
  85238. /**
  85239. * Define if a depth texture is required instead of a depth buffer
  85240. */
  85241. generateDepthTexture?: boolean;
  85242. /**
  85243. * Define the number of desired draw buffers
  85244. */
  85245. textureCount?: number;
  85246. /**
  85247. * Define if aspect ratio should be adapted to the texture or stay the scene one
  85248. */
  85249. doNotChangeAspectRatio?: boolean;
  85250. /**
  85251. * Define the default type of the buffers we are creating
  85252. */
  85253. defaultType?: number;
  85254. }
  85255. /**
  85256. * A multi render target, like a render target provides the ability to render to a texture.
  85257. * Unlike the render target, it can render to several draw buffers in one draw.
  85258. * This is specially interesting in deferred rendering or for any effects requiring more than
  85259. * just one color from a single pass.
  85260. */
  85261. export class MultiRenderTarget extends RenderTargetTexture {
  85262. private _internalTextures;
  85263. private _textures;
  85264. private _multiRenderTargetOptions;
  85265. /**
  85266. * Get if draw buffers are currently supported by the used hardware and browser.
  85267. */
  85268. readonly isSupported: boolean;
  85269. /**
  85270. * Get the list of textures generated by the multi render target.
  85271. */
  85272. readonly textures: Texture[];
  85273. /**
  85274. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  85275. */
  85276. readonly depthTexture: Texture;
  85277. /**
  85278. * Set the wrapping mode on U of all the textures we are rendering to.
  85279. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85280. */
  85281. wrapU: number;
  85282. /**
  85283. * Set the wrapping mode on V of all the textures we are rendering to.
  85284. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85285. */
  85286. wrapV: number;
  85287. /**
  85288. * Instantiate a new multi render target texture.
  85289. * A multi render target, like a render target provides the ability to render to a texture.
  85290. * Unlike the render target, it can render to several draw buffers in one draw.
  85291. * This is specially interesting in deferred rendering or for any effects requiring more than
  85292. * just one color from a single pass.
  85293. * @param name Define the name of the texture
  85294. * @param size Define the size of the buffers to render to
  85295. * @param count Define the number of target we are rendering into
  85296. * @param scene Define the scene the texture belongs to
  85297. * @param options Define the options used to create the multi render target
  85298. */
  85299. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  85300. /** @hidden */
  85301. _rebuild(): void;
  85302. private _createInternalTextures;
  85303. private _createTextures;
  85304. /**
  85305. * Define the number of samples used if MSAA is enabled.
  85306. */
  85307. samples: number;
  85308. /**
  85309. * Resize all the textures in the multi render target.
  85310. * Be carrefull as it will recreate all the data in the new texture.
  85311. * @param size Define the new size
  85312. */
  85313. resize(size: any): void;
  85314. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85315. /**
  85316. * Dispose the render targets and their associated resources
  85317. */
  85318. dispose(): void;
  85319. /**
  85320. * Release all the underlying texture used as draw buffers.
  85321. */
  85322. releaseInternalTextures(): void;
  85323. }
  85324. }
  85325. declare module BABYLON {
  85326. /**
  85327. * Class used to work with sound analyzer using fast fourier transform (FFT)
  85328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85329. */
  85330. export class Analyser {
  85331. /**
  85332. * Gets or sets the smoothing
  85333. * @ignorenaming
  85334. */
  85335. SMOOTHING: number;
  85336. /**
  85337. * Gets or sets the FFT table size
  85338. * @ignorenaming
  85339. */
  85340. FFT_SIZE: number;
  85341. /**
  85342. * Gets or sets the bar graph amplitude
  85343. * @ignorenaming
  85344. */
  85345. BARGRAPHAMPLITUDE: number;
  85346. /**
  85347. * Gets or sets the position of the debug canvas
  85348. * @ignorenaming
  85349. */
  85350. DEBUGCANVASPOS: {
  85351. x: number;
  85352. y: number;
  85353. };
  85354. /**
  85355. * Gets or sets the debug canvas size
  85356. * @ignorenaming
  85357. */
  85358. DEBUGCANVASSIZE: {
  85359. width: number;
  85360. height: number;
  85361. };
  85362. private _byteFreqs;
  85363. private _byteTime;
  85364. private _floatFreqs;
  85365. private _webAudioAnalyser;
  85366. private _debugCanvas;
  85367. private _debugCanvasContext;
  85368. private _scene;
  85369. private _registerFunc;
  85370. private _audioEngine;
  85371. /**
  85372. * Creates a new analyser
  85373. * @param scene defines hosting scene
  85374. */
  85375. constructor(scene: Scene);
  85376. /**
  85377. * Get the number of data values you will have to play with for the visualization
  85378. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  85379. * @returns a number
  85380. */
  85381. getFrequencyBinCount(): number;
  85382. /**
  85383. * Gets the current frequency data as a byte array
  85384. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85385. * @returns a Uint8Array
  85386. */
  85387. getByteFrequencyData(): Uint8Array;
  85388. /**
  85389. * Gets the current waveform as a byte array
  85390. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  85391. * @returns a Uint8Array
  85392. */
  85393. getByteTimeDomainData(): Uint8Array;
  85394. /**
  85395. * Gets the current frequency data as a float array
  85396. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85397. * @returns a Float32Array
  85398. */
  85399. getFloatFrequencyData(): Float32Array;
  85400. /**
  85401. * Renders the debug canvas
  85402. */
  85403. drawDebugCanvas(): void;
  85404. /**
  85405. * Stops rendering the debug canvas and removes it
  85406. */
  85407. stopDebugCanvas(): void;
  85408. /**
  85409. * Connects two audio nodes
  85410. * @param inputAudioNode defines first node to connect
  85411. * @param outputAudioNode defines second node to connect
  85412. */
  85413. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  85414. /**
  85415. * Releases all associated resources
  85416. */
  85417. dispose(): void;
  85418. }
  85419. }
  85420. declare module BABYLON {
  85421. /**
  85422. * This represents an audio engine and it is responsible
  85423. * to play, synchronize and analyse sounds throughout the application.
  85424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85425. */
  85426. export interface IAudioEngine extends IDisposable {
  85427. /**
  85428. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85429. */
  85430. readonly canUseWebAudio: boolean;
  85431. /**
  85432. * Gets the current AudioContext if available.
  85433. */
  85434. readonly audioContext: Nullable<AudioContext>;
  85435. /**
  85436. * The master gain node defines the global audio volume of your audio engine.
  85437. */
  85438. readonly masterGain: GainNode;
  85439. /**
  85440. * Gets whether or not mp3 are supported by your browser.
  85441. */
  85442. readonly isMP3supported: boolean;
  85443. /**
  85444. * Gets whether or not ogg are supported by your browser.
  85445. */
  85446. readonly isOGGsupported: boolean;
  85447. /**
  85448. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85449. * @ignoreNaming
  85450. */
  85451. WarnedWebAudioUnsupported: boolean;
  85452. /**
  85453. * Defines if the audio engine relies on a custom unlocked button.
  85454. * In this case, the embedded button will not be displayed.
  85455. */
  85456. useCustomUnlockedButton: boolean;
  85457. /**
  85458. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  85459. */
  85460. readonly unlocked: boolean;
  85461. /**
  85462. * Event raised when audio has been unlocked on the browser.
  85463. */
  85464. onAudioUnlockedObservable: Observable<AudioEngine>;
  85465. /**
  85466. * Event raised when audio has been locked on the browser.
  85467. */
  85468. onAudioLockedObservable: Observable<AudioEngine>;
  85469. /**
  85470. * Flags the audio engine in Locked state.
  85471. * This happens due to new browser policies preventing audio to autoplay.
  85472. */
  85473. lock(): void;
  85474. /**
  85475. * Unlocks the audio engine once a user action has been done on the dom.
  85476. * This is helpful to resume play once browser policies have been satisfied.
  85477. */
  85478. unlock(): void;
  85479. }
  85480. /**
  85481. * This represents the default audio engine used in babylon.
  85482. * It is responsible to play, synchronize and analyse sounds throughout the application.
  85483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85484. */
  85485. export class AudioEngine implements IAudioEngine {
  85486. private _audioContext;
  85487. private _audioContextInitialized;
  85488. private _muteButton;
  85489. private _hostElement;
  85490. /**
  85491. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85492. */
  85493. canUseWebAudio: boolean;
  85494. /**
  85495. * The master gain node defines the global audio volume of your audio engine.
  85496. */
  85497. masterGain: GainNode;
  85498. /**
  85499. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85500. * @ignoreNaming
  85501. */
  85502. WarnedWebAudioUnsupported: boolean;
  85503. /**
  85504. * Gets whether or not mp3 are supported by your browser.
  85505. */
  85506. isMP3supported: boolean;
  85507. /**
  85508. * Gets whether or not ogg are supported by your browser.
  85509. */
  85510. isOGGsupported: boolean;
  85511. /**
  85512. * Gets whether audio has been unlocked on the device.
  85513. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  85514. * a user interaction has happened.
  85515. */
  85516. unlocked: boolean;
  85517. /**
  85518. * Defines if the audio engine relies on a custom unlocked button.
  85519. * In this case, the embedded button will not be displayed.
  85520. */
  85521. useCustomUnlockedButton: boolean;
  85522. /**
  85523. * Event raised when audio has been unlocked on the browser.
  85524. */
  85525. onAudioUnlockedObservable: Observable<AudioEngine>;
  85526. /**
  85527. * Event raised when audio has been locked on the browser.
  85528. */
  85529. onAudioLockedObservable: Observable<AudioEngine>;
  85530. /**
  85531. * Gets the current AudioContext if available.
  85532. */
  85533. readonly audioContext: Nullable<AudioContext>;
  85534. private _connectedAnalyser;
  85535. /**
  85536. * Instantiates a new audio engine.
  85537. *
  85538. * There should be only one per page as some browsers restrict the number
  85539. * of audio contexts you can create.
  85540. * @param hostElement defines the host element where to display the mute icon if necessary
  85541. */
  85542. constructor(hostElement?: Nullable<HTMLElement>);
  85543. /**
  85544. * Flags the audio engine in Locked state.
  85545. * This happens due to new browser policies preventing audio to autoplay.
  85546. */
  85547. lock(): void;
  85548. /**
  85549. * Unlocks the audio engine once a user action has been done on the dom.
  85550. * This is helpful to resume play once browser policies have been satisfied.
  85551. */
  85552. unlock(): void;
  85553. private _resumeAudioContext;
  85554. private _initializeAudioContext;
  85555. private _tryToRun;
  85556. private _triggerRunningState;
  85557. private _triggerSuspendedState;
  85558. private _displayMuteButton;
  85559. private _moveButtonToTopLeft;
  85560. private _onResize;
  85561. private _hideMuteButton;
  85562. /**
  85563. * Destroy and release the resources associated with the audio ccontext.
  85564. */
  85565. dispose(): void;
  85566. /**
  85567. * Gets the global volume sets on the master gain.
  85568. * @returns the global volume if set or -1 otherwise
  85569. */
  85570. getGlobalVolume(): number;
  85571. /**
  85572. * Sets the global volume of your experience (sets on the master gain).
  85573. * @param newVolume Defines the new global volume of the application
  85574. */
  85575. setGlobalVolume(newVolume: number): void;
  85576. /**
  85577. * Connect the audio engine to an audio analyser allowing some amazing
  85578. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  85579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  85580. * @param analyser The analyser to connect to the engine
  85581. */
  85582. connectToAnalyser(analyser: Analyser): void;
  85583. }
  85584. }
  85585. declare module BABYLON {
  85586. /**
  85587. * Interface used to present a loading screen while loading a scene
  85588. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85589. */
  85590. export interface ILoadingScreen {
  85591. /**
  85592. * Function called to display the loading screen
  85593. */
  85594. displayLoadingUI: () => void;
  85595. /**
  85596. * Function called to hide the loading screen
  85597. */
  85598. hideLoadingUI: () => void;
  85599. /**
  85600. * Gets or sets the color to use for the background
  85601. */
  85602. loadingUIBackgroundColor: string;
  85603. /**
  85604. * Gets or sets the text to display while loading
  85605. */
  85606. loadingUIText: string;
  85607. }
  85608. /**
  85609. * Class used for the default loading screen
  85610. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85611. */
  85612. export class DefaultLoadingScreen implements ILoadingScreen {
  85613. private _renderingCanvas;
  85614. private _loadingText;
  85615. private _loadingDivBackgroundColor;
  85616. private _loadingDiv;
  85617. private _loadingTextDiv;
  85618. /**
  85619. * Creates a new default loading screen
  85620. * @param _renderingCanvas defines the canvas used to render the scene
  85621. * @param _loadingText defines the default text to display
  85622. * @param _loadingDivBackgroundColor defines the default background color
  85623. */
  85624. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  85625. /**
  85626. * Function called to display the loading screen
  85627. */
  85628. displayLoadingUI(): void;
  85629. /**
  85630. * Function called to hide the loading screen
  85631. */
  85632. hideLoadingUI(): void;
  85633. /**
  85634. * Gets or sets the text to display while loading
  85635. */
  85636. loadingUIText: string;
  85637. /**
  85638. * Gets or sets the color to use for the background
  85639. */
  85640. loadingUIBackgroundColor: string;
  85641. private _resizeLoadingUI;
  85642. }
  85643. }
  85644. declare module BABYLON {
  85645. /**
  85646. * Settings for finer control over video usage
  85647. */
  85648. export interface VideoTextureSettings {
  85649. /**
  85650. * Applies `autoplay` to video, if specified
  85651. */
  85652. autoPlay?: boolean;
  85653. /**
  85654. * Applies `loop` to video, if specified
  85655. */
  85656. loop?: boolean;
  85657. /**
  85658. * Automatically updates internal texture from video at every frame in the render loop
  85659. */
  85660. autoUpdateTexture: boolean;
  85661. /**
  85662. * Image src displayed during the video loading or until the user interacts with the video.
  85663. */
  85664. poster?: string;
  85665. }
  85666. /**
  85667. * If you want to display a video in your scene, this is the special texture for that.
  85668. * This special texture works similar to other textures, with the exception of a few parameters.
  85669. * @see https://doc.babylonjs.com/how_to/video_texture
  85670. */
  85671. export class VideoTexture extends Texture {
  85672. /**
  85673. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  85674. */
  85675. readonly autoUpdateTexture: boolean;
  85676. /**
  85677. * The video instance used by the texture internally
  85678. */
  85679. readonly video: HTMLVideoElement;
  85680. private _onUserActionRequestedObservable;
  85681. /**
  85682. * Event triggerd when a dom action is required by the user to play the video.
  85683. * This happens due to recent changes in browser policies preventing video to auto start.
  85684. */
  85685. readonly onUserActionRequestedObservable: Observable<Texture>;
  85686. private _generateMipMaps;
  85687. private _engine;
  85688. private _stillImageCaptured;
  85689. private _displayingPosterTexture;
  85690. private _settings;
  85691. private _createInternalTextureOnEvent;
  85692. /**
  85693. * Creates a video texture.
  85694. * If you want to display a video in your scene, this is the special texture for that.
  85695. * This special texture works similar to other textures, with the exception of a few parameters.
  85696. * @see https://doc.babylonjs.com/how_to/video_texture
  85697. * @param name optional name, will detect from video source, if not defined
  85698. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  85699. * @param scene is obviously the current scene.
  85700. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  85701. * @param invertY is false by default but can be used to invert video on Y axis
  85702. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  85703. * @param settings allows finer control over video usage
  85704. */
  85705. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  85706. private _getName;
  85707. private _getVideo;
  85708. private _createInternalTexture;
  85709. private reset;
  85710. /**
  85711. * @hidden Internal method to initiate `update`.
  85712. */
  85713. _rebuild(): void;
  85714. /**
  85715. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  85716. */
  85717. update(): void;
  85718. /**
  85719. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  85720. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  85721. */
  85722. updateTexture(isVisible: boolean): void;
  85723. protected _updateInternalTexture: () => void;
  85724. /**
  85725. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  85726. * @param url New url.
  85727. */
  85728. updateURL(url: string): void;
  85729. /**
  85730. * Dispose the texture and release its associated resources.
  85731. */
  85732. dispose(): void;
  85733. /**
  85734. * Creates a video texture straight from a stream.
  85735. * @param scene Define the scene the texture should be created in
  85736. * @param stream Define the stream the texture should be created from
  85737. * @returns The created video texture as a promise
  85738. */
  85739. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  85740. /**
  85741. * Creates a video texture straight from your WebCam video feed.
  85742. * @param scene Define the scene the texture should be created in
  85743. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  85744. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  85745. * @returns The created video texture as a promise
  85746. */
  85747. static CreateFromWebCamAsync(scene: Scene, constraints: {
  85748. minWidth: number;
  85749. maxWidth: number;
  85750. minHeight: number;
  85751. maxHeight: number;
  85752. deviceId: string;
  85753. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  85754. /**
  85755. * Creates a video texture straight from your WebCam video feed.
  85756. * @param scene Define the scene the texture should be created in
  85757. * @param onReady Define a callback to triggered once the texture will be ready
  85758. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  85759. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  85760. */
  85761. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  85762. minWidth: number;
  85763. maxWidth: number;
  85764. minHeight: number;
  85765. maxHeight: number;
  85766. deviceId: string;
  85767. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  85768. }
  85769. }
  85770. declare module BABYLON {
  85771. /**
  85772. * Interface for attribute information associated with buffer instanciation
  85773. */
  85774. export class InstancingAttributeInfo {
  85775. /**
  85776. * Index/offset of the attribute in the vertex shader
  85777. */
  85778. index: number;
  85779. /**
  85780. * size of the attribute, 1, 2, 3 or 4
  85781. */
  85782. attributeSize: number;
  85783. /**
  85784. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  85785. * default is FLOAT
  85786. */
  85787. attribyteType: number;
  85788. /**
  85789. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  85790. */
  85791. normalized: boolean;
  85792. /**
  85793. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  85794. */
  85795. offset: number;
  85796. /**
  85797. * Name of the GLSL attribute, for debugging purpose only
  85798. */
  85799. attributeName: string;
  85800. }
  85801. /**
  85802. * Define options used to create a depth texture
  85803. */
  85804. export class DepthTextureCreationOptions {
  85805. /** Specifies whether or not a stencil should be allocated in the texture */
  85806. generateStencil?: boolean;
  85807. /** Specifies whether or not bilinear filtering is enable on the texture */
  85808. bilinearFiltering?: boolean;
  85809. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85810. comparisonFunction?: number;
  85811. /** Specifies if the created texture is a cube texture */
  85812. isCube?: boolean;
  85813. }
  85814. /**
  85815. * Class used to describe the capabilities of the engine relatively to the current browser
  85816. */
  85817. export class EngineCapabilities {
  85818. /** Maximum textures units per fragment shader */
  85819. maxTexturesImageUnits: number;
  85820. /** Maximum texture units per vertex shader */
  85821. maxVertexTextureImageUnits: number;
  85822. /** Maximum textures units in the entire pipeline */
  85823. maxCombinedTexturesImageUnits: number;
  85824. /** Maximum texture size */
  85825. maxTextureSize: number;
  85826. /** Maximum cube texture size */
  85827. maxCubemapTextureSize: number;
  85828. /** Maximum render texture size */
  85829. maxRenderTextureSize: number;
  85830. /** Maximum number of vertex attributes */
  85831. maxVertexAttribs: number;
  85832. /** Maximum number of varyings */
  85833. maxVaryingVectors: number;
  85834. /** Maximum number of uniforms per vertex shader */
  85835. maxVertexUniformVectors: number;
  85836. /** Maximum number of uniforms per fragment shader */
  85837. maxFragmentUniformVectors: number;
  85838. /** Defines if standard derivates (dx/dy) are supported */
  85839. standardDerivatives: boolean;
  85840. /** Defines if s3tc texture compression is supported */
  85841. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  85842. /** Defines if pvrtc texture compression is supported */
  85843. pvrtc: any;
  85844. /** Defines if etc1 texture compression is supported */
  85845. etc1: any;
  85846. /** Defines if etc2 texture compression is supported */
  85847. etc2: any;
  85848. /** Defines if astc texture compression is supported */
  85849. astc: any;
  85850. /** Defines if float textures are supported */
  85851. textureFloat: boolean;
  85852. /** Defines if vertex array objects are supported */
  85853. vertexArrayObject: boolean;
  85854. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  85855. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  85856. /** Gets the maximum level of anisotropy supported */
  85857. maxAnisotropy: number;
  85858. /** Defines if instancing is supported */
  85859. instancedArrays: boolean;
  85860. /** Defines if 32 bits indices are supported */
  85861. uintIndices: boolean;
  85862. /** Defines if high precision shaders are supported */
  85863. highPrecisionShaderSupported: boolean;
  85864. /** Defines if depth reading in the fragment shader is supported */
  85865. fragmentDepthSupported: boolean;
  85866. /** Defines if float texture linear filtering is supported*/
  85867. textureFloatLinearFiltering: boolean;
  85868. /** Defines if rendering to float textures is supported */
  85869. textureFloatRender: boolean;
  85870. /** Defines if half float textures are supported*/
  85871. textureHalfFloat: boolean;
  85872. /** Defines if half float texture linear filtering is supported*/
  85873. textureHalfFloatLinearFiltering: boolean;
  85874. /** Defines if rendering to half float textures is supported */
  85875. textureHalfFloatRender: boolean;
  85876. /** Defines if textureLOD shader command is supported */
  85877. textureLOD: boolean;
  85878. /** Defines if draw buffers extension is supported */
  85879. drawBuffersExtension: boolean;
  85880. /** Defines if depth textures are supported */
  85881. depthTextureExtension: boolean;
  85882. /** Defines if float color buffer are supported */
  85883. colorBufferFloat: boolean;
  85884. /** Gets disjoint timer query extension (null if not supported) */
  85885. timerQuery: EXT_disjoint_timer_query;
  85886. /** Defines if timestamp can be used with timer query */
  85887. canUseTimestampForTimerQuery: boolean;
  85888. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  85889. multiview: any;
  85890. /** Function used to let the system compiles shaders in background */
  85891. parallelShaderCompile: {
  85892. COMPLETION_STATUS_KHR: number;
  85893. };
  85894. }
  85895. /** Interface defining initialization parameters for Engine class */
  85896. export interface EngineOptions extends WebGLContextAttributes {
  85897. /**
  85898. * Defines if the engine should no exceed a specified device ratio
  85899. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  85900. */
  85901. limitDeviceRatio?: number;
  85902. /**
  85903. * Defines if webvr should be enabled automatically
  85904. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85905. */
  85906. autoEnableWebVR?: boolean;
  85907. /**
  85908. * Defines if webgl2 should be turned off even if supported
  85909. * @see http://doc.babylonjs.com/features/webgl2
  85910. */
  85911. disableWebGL2Support?: boolean;
  85912. /**
  85913. * Defines if webaudio should be initialized as well
  85914. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85915. */
  85916. audioEngine?: boolean;
  85917. /**
  85918. * Defines if animations should run using a deterministic lock step
  85919. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85920. */
  85921. deterministicLockstep?: boolean;
  85922. /** Defines the maximum steps to use with deterministic lock step mode */
  85923. lockstepMaxSteps?: number;
  85924. /**
  85925. * Defines that engine should ignore context lost events
  85926. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  85927. */
  85928. doNotHandleContextLost?: boolean;
  85929. /**
  85930. * Defines that engine should ignore modifying touch action attribute and style
  85931. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  85932. */
  85933. doNotHandleTouchAction?: boolean;
  85934. /**
  85935. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  85936. */
  85937. useHighPrecisionFloats?: boolean;
  85938. }
  85939. /**
  85940. * Defines the interface used by display changed events
  85941. */
  85942. export interface IDisplayChangedEventArgs {
  85943. /** Gets the vrDisplay object (if any) */
  85944. vrDisplay: Nullable<any>;
  85945. /** Gets a boolean indicating if webVR is supported */
  85946. vrSupported: boolean;
  85947. }
  85948. /**
  85949. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  85950. */
  85951. export class Engine {
  85952. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  85953. static ExceptionList: ({
  85954. key: string;
  85955. capture: string;
  85956. captureConstraint: number;
  85957. targets: string[];
  85958. } | {
  85959. key: string;
  85960. capture: null;
  85961. captureConstraint: null;
  85962. targets: string[];
  85963. })[];
  85964. /** Gets the list of created engines */
  85965. static readonly Instances: Engine[];
  85966. /**
  85967. * Gets the latest created engine
  85968. */
  85969. static readonly LastCreatedEngine: Nullable<Engine>;
  85970. /**
  85971. * Gets the latest created scene
  85972. */
  85973. static readonly LastCreatedScene: Nullable<Scene>;
  85974. /**
  85975. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  85976. * @param flag defines which part of the materials must be marked as dirty
  85977. * @param predicate defines a predicate used to filter which materials should be affected
  85978. */
  85979. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  85980. /**
  85981. * Hidden
  85982. */
  85983. static _TextureLoaders: IInternalTextureLoader[];
  85984. /** Defines that alpha blending is disabled */
  85985. static readonly ALPHA_DISABLE: number;
  85986. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  85987. static readonly ALPHA_ADD: number;
  85988. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  85989. static readonly ALPHA_COMBINE: number;
  85990. /** Defines that alpha blending to DEST - SRC * DEST */
  85991. static readonly ALPHA_SUBTRACT: number;
  85992. /** Defines that alpha blending to SRC * DEST */
  85993. static readonly ALPHA_MULTIPLY: number;
  85994. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  85995. static readonly ALPHA_MAXIMIZED: number;
  85996. /** Defines that alpha blending to SRC + DEST */
  85997. static readonly ALPHA_ONEONE: number;
  85998. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  85999. static readonly ALPHA_PREMULTIPLIED: number;
  86000. /**
  86001. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  86002. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86003. */
  86004. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86005. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  86006. static readonly ALPHA_INTERPOLATE: number;
  86007. /**
  86008. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  86009. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86010. */
  86011. static readonly ALPHA_SCREENMODE: number;
  86012. /** Defines that the ressource is not delayed*/
  86013. static readonly DELAYLOADSTATE_NONE: number;
  86014. /** Defines that the ressource was successfully delay loaded */
  86015. static readonly DELAYLOADSTATE_LOADED: number;
  86016. /** Defines that the ressource is currently delay loading */
  86017. static readonly DELAYLOADSTATE_LOADING: number;
  86018. /** Defines that the ressource is delayed and has not started loading */
  86019. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86020. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86021. static readonly NEVER: number;
  86022. /** 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 */
  86023. static readonly ALWAYS: number;
  86024. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86025. static readonly LESS: number;
  86026. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86027. static readonly EQUAL: number;
  86028. /** 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 */
  86029. static readonly LEQUAL: number;
  86030. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86031. static readonly GREATER: number;
  86032. /** 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 */
  86033. static readonly GEQUAL: number;
  86034. /** 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 */
  86035. static readonly NOTEQUAL: number;
  86036. /** Passed to stencilOperation to specify that stencil value must be kept */
  86037. static readonly KEEP: number;
  86038. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86039. static readonly REPLACE: number;
  86040. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86041. static readonly INCR: number;
  86042. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86043. static readonly DECR: number;
  86044. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86045. static readonly INVERT: number;
  86046. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86047. static readonly INCR_WRAP: number;
  86048. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86049. static readonly DECR_WRAP: number;
  86050. /** Texture is not repeating outside of 0..1 UVs */
  86051. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86052. /** Texture is repeating outside of 0..1 UVs */
  86053. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86054. /** Texture is repeating and mirrored */
  86055. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86056. /** ALPHA */
  86057. static readonly TEXTUREFORMAT_ALPHA: number;
  86058. /** LUMINANCE */
  86059. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86060. /** LUMINANCE_ALPHA */
  86061. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86062. /** RGB */
  86063. static readonly TEXTUREFORMAT_RGB: number;
  86064. /** RGBA */
  86065. static readonly TEXTUREFORMAT_RGBA: number;
  86066. /** RED */
  86067. static readonly TEXTUREFORMAT_RED: number;
  86068. /** RED (2nd reference) */
  86069. static readonly TEXTUREFORMAT_R: number;
  86070. /** RG */
  86071. static readonly TEXTUREFORMAT_RG: number;
  86072. /** RED_INTEGER */
  86073. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86074. /** RED_INTEGER (2nd reference) */
  86075. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86076. /** RG_INTEGER */
  86077. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86078. /** RGB_INTEGER */
  86079. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86080. /** RGBA_INTEGER */
  86081. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86082. /** UNSIGNED_BYTE */
  86083. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86084. /** UNSIGNED_BYTE (2nd reference) */
  86085. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86086. /** FLOAT */
  86087. static readonly TEXTURETYPE_FLOAT: number;
  86088. /** HALF_FLOAT */
  86089. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86090. /** BYTE */
  86091. static readonly TEXTURETYPE_BYTE: number;
  86092. /** SHORT */
  86093. static readonly TEXTURETYPE_SHORT: number;
  86094. /** UNSIGNED_SHORT */
  86095. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86096. /** INT */
  86097. static readonly TEXTURETYPE_INT: number;
  86098. /** UNSIGNED_INT */
  86099. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86100. /** UNSIGNED_SHORT_4_4_4_4 */
  86101. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86102. /** UNSIGNED_SHORT_5_5_5_1 */
  86103. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86104. /** UNSIGNED_SHORT_5_6_5 */
  86105. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86106. /** UNSIGNED_INT_2_10_10_10_REV */
  86107. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86108. /** UNSIGNED_INT_24_8 */
  86109. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86110. /** UNSIGNED_INT_10F_11F_11F_REV */
  86111. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86112. /** UNSIGNED_INT_5_9_9_9_REV */
  86113. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86114. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86115. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86116. /** nearest is mag = nearest and min = nearest and mip = linear */
  86117. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86118. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86119. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86120. /** Trilinear is mag = linear and min = linear and mip = linear */
  86121. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86122. /** nearest is mag = nearest and min = nearest and mip = linear */
  86123. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86124. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86125. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86126. /** Trilinear is mag = linear and min = linear and mip = linear */
  86127. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86128. /** mag = nearest and min = nearest and mip = nearest */
  86129. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86130. /** mag = nearest and min = linear and mip = nearest */
  86131. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86132. /** mag = nearest and min = linear and mip = linear */
  86133. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86134. /** mag = nearest and min = linear and mip = none */
  86135. static readonly TEXTURE_NEAREST_LINEAR: number;
  86136. /** mag = nearest and min = nearest and mip = none */
  86137. static readonly TEXTURE_NEAREST_NEAREST: number;
  86138. /** mag = linear and min = nearest and mip = nearest */
  86139. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86140. /** mag = linear and min = nearest and mip = linear */
  86141. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86142. /** mag = linear and min = linear and mip = none */
  86143. static readonly TEXTURE_LINEAR_LINEAR: number;
  86144. /** mag = linear and min = nearest and mip = none */
  86145. static readonly TEXTURE_LINEAR_NEAREST: number;
  86146. /** Explicit coordinates mode */
  86147. static readonly TEXTURE_EXPLICIT_MODE: number;
  86148. /** Spherical coordinates mode */
  86149. static readonly TEXTURE_SPHERICAL_MODE: number;
  86150. /** Planar coordinates mode */
  86151. static readonly TEXTURE_PLANAR_MODE: number;
  86152. /** Cubic coordinates mode */
  86153. static readonly TEXTURE_CUBIC_MODE: number;
  86154. /** Projection coordinates mode */
  86155. static readonly TEXTURE_PROJECTION_MODE: number;
  86156. /** Skybox coordinates mode */
  86157. static readonly TEXTURE_SKYBOX_MODE: number;
  86158. /** Inverse Cubic coordinates mode */
  86159. static readonly TEXTURE_INVCUBIC_MODE: number;
  86160. /** Equirectangular coordinates mode */
  86161. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  86162. /** Equirectangular Fixed coordinates mode */
  86163. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  86164. /** Equirectangular Fixed Mirrored coordinates mode */
  86165. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86166. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  86167. static readonly SCALEMODE_FLOOR: number;
  86168. /** Defines that texture rescaling will look for the nearest power of 2 size */
  86169. static readonly SCALEMODE_NEAREST: number;
  86170. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  86171. static readonly SCALEMODE_CEILING: number;
  86172. /**
  86173. * Returns the current npm package of the sdk
  86174. */
  86175. static readonly NpmPackage: string;
  86176. /**
  86177. * Returns the current version of the framework
  86178. */
  86179. static readonly Version: string;
  86180. /**
  86181. * Returns a string describing the current engine
  86182. */
  86183. readonly description: string;
  86184. /**
  86185. * Gets or sets the epsilon value used by collision engine
  86186. */
  86187. static CollisionsEpsilon: number;
  86188. /**
  86189. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86190. */
  86191. static ShadersRepository: string;
  86192. /**
  86193. * Method called to create the default loading screen.
  86194. * This can be overriden in your own app.
  86195. * @param canvas The rendering canvas element
  86196. * @returns The loading screen
  86197. */
  86198. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  86199. /**
  86200. * Method called to create the default rescale post process on each engine.
  86201. */
  86202. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  86203. /**
  86204. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  86205. */
  86206. forcePOTTextures: boolean;
  86207. /**
  86208. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  86209. */
  86210. isFullscreen: boolean;
  86211. /**
  86212. * Gets a boolean indicating if the pointer is currently locked
  86213. */
  86214. isPointerLock: boolean;
  86215. /**
  86216. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  86217. */
  86218. cullBackFaces: boolean;
  86219. /**
  86220. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  86221. */
  86222. renderEvenInBackground: boolean;
  86223. /**
  86224. * Gets or sets a boolean indicating that cache can be kept between frames
  86225. */
  86226. preventCacheWipeBetweenFrames: boolean;
  86227. /**
  86228. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  86229. **/
  86230. enableOfflineSupport: boolean;
  86231. /**
  86232. * 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)
  86233. **/
  86234. disableManifestCheck: boolean;
  86235. /**
  86236. * Gets the list of created scenes
  86237. */
  86238. scenes: Scene[];
  86239. /**
  86240. * Event raised when a new scene is created
  86241. */
  86242. onNewSceneAddedObservable: Observable<Scene>;
  86243. /**
  86244. * Gets the list of created postprocesses
  86245. */
  86246. postProcesses: PostProcess[];
  86247. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  86248. validateShaderPrograms: boolean;
  86249. /**
  86250. * Observable event triggered each time the rendering canvas is resized
  86251. */
  86252. onResizeObservable: Observable<Engine>;
  86253. /**
  86254. * Observable event triggered each time the canvas loses focus
  86255. */
  86256. onCanvasBlurObservable: Observable<Engine>;
  86257. /**
  86258. * Observable event triggered each time the canvas gains focus
  86259. */
  86260. onCanvasFocusObservable: Observable<Engine>;
  86261. /**
  86262. * Observable event triggered each time the canvas receives pointerout event
  86263. */
  86264. onCanvasPointerOutObservable: Observable<PointerEvent>;
  86265. /**
  86266. * Observable event triggered before each texture is initialized
  86267. */
  86268. onBeforeTextureInitObservable: Observable<Texture>;
  86269. private _vrDisplay;
  86270. private _vrSupported;
  86271. private _oldSize;
  86272. private _oldHardwareScaleFactor;
  86273. private _vrExclusivePointerMode;
  86274. private _webVRInitPromise;
  86275. /**
  86276. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86277. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86278. */
  86279. readonly isInVRExclusivePointerMode: boolean;
  86280. /**
  86281. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  86282. */
  86283. disableUniformBuffers: boolean;
  86284. /** @hidden */
  86285. _uniformBuffers: UniformBuffer[];
  86286. /**
  86287. * Gets a boolean indicating that the engine supports uniform buffers
  86288. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86289. */
  86290. readonly supportsUniformBuffers: boolean;
  86291. /**
  86292. * Observable raised when the engine begins a new frame
  86293. */
  86294. onBeginFrameObservable: Observable<Engine>;
  86295. /**
  86296. * If set, will be used to request the next animation frame for the render loop
  86297. */
  86298. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  86299. /**
  86300. * Observable raised when the engine ends the current frame
  86301. */
  86302. onEndFrameObservable: Observable<Engine>;
  86303. /**
  86304. * Observable raised when the engine is about to compile a shader
  86305. */
  86306. onBeforeShaderCompilationObservable: Observable<Engine>;
  86307. /**
  86308. * Observable raised when the engine has jsut compiled a shader
  86309. */
  86310. onAfterShaderCompilationObservable: Observable<Engine>;
  86311. /** @hidden */
  86312. _gl: WebGLRenderingContext;
  86313. private _renderingCanvas;
  86314. private _windowIsBackground;
  86315. private _webGLVersion;
  86316. protected _highPrecisionShadersAllowed: boolean;
  86317. /** @hidden */
  86318. readonly _shouldUseHighPrecisionShader: boolean;
  86319. /**
  86320. * Gets a boolean indicating that only power of 2 textures are supported
  86321. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  86322. */
  86323. readonly needPOTTextures: boolean;
  86324. /** @hidden */
  86325. _badOS: boolean;
  86326. /** @hidden */
  86327. _badDesktopOS: boolean;
  86328. /**
  86329. * Gets or sets a value indicating if we want to disable texture binding optimization.
  86330. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  86331. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  86332. */
  86333. disableTextureBindingOptimization: boolean;
  86334. /**
  86335. * Gets the audio engine
  86336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86337. * @ignorenaming
  86338. */
  86339. static audioEngine: IAudioEngine;
  86340. /**
  86341. * Default AudioEngine factory responsible of creating the Audio Engine.
  86342. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  86343. */
  86344. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  86345. /**
  86346. * Default offline support factory responsible of creating a tool used to store data locally.
  86347. * By default, this will create a Database object if the workload has been embedded.
  86348. */
  86349. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  86350. private _onFocus;
  86351. private _onBlur;
  86352. private _onCanvasPointerOut;
  86353. private _onCanvasBlur;
  86354. private _onCanvasFocus;
  86355. private _onFullscreenChange;
  86356. private _onPointerLockChange;
  86357. private _onVRDisplayPointerRestricted;
  86358. private _onVRDisplayPointerUnrestricted;
  86359. private _onVrDisplayConnect;
  86360. private _onVrDisplayDisconnect;
  86361. private _onVrDisplayPresentChange;
  86362. /**
  86363. * Observable signaled when VR display mode changes
  86364. */
  86365. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  86366. /**
  86367. * Observable signaled when VR request present is complete
  86368. */
  86369. onVRRequestPresentComplete: Observable<boolean>;
  86370. /**
  86371. * Observable signaled when VR request present starts
  86372. */
  86373. onVRRequestPresentStart: Observable<Engine>;
  86374. private _hardwareScalingLevel;
  86375. /** @hidden */
  86376. protected _caps: EngineCapabilities;
  86377. private _pointerLockRequested;
  86378. private _isStencilEnable;
  86379. private _colorWrite;
  86380. private _loadingScreen;
  86381. /** @hidden */
  86382. _drawCalls: PerfCounter;
  86383. /** @hidden */
  86384. _textureCollisions: PerfCounter;
  86385. private _glVersion;
  86386. private _glRenderer;
  86387. private _glVendor;
  86388. private _videoTextureSupported;
  86389. private _renderingQueueLaunched;
  86390. private _activeRenderLoops;
  86391. private _deterministicLockstep;
  86392. private _lockstepMaxSteps;
  86393. /**
  86394. * Observable signaled when a context lost event is raised
  86395. */
  86396. onContextLostObservable: Observable<Engine>;
  86397. /**
  86398. * Observable signaled when a context restored event is raised
  86399. */
  86400. onContextRestoredObservable: Observable<Engine>;
  86401. private _onContextLost;
  86402. private _onContextRestored;
  86403. private _contextWasLost;
  86404. private _doNotHandleContextLost;
  86405. /**
  86406. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  86407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  86408. */
  86409. doNotHandleContextLost: boolean;
  86410. private _performanceMonitor;
  86411. private _fps;
  86412. private _deltaTime;
  86413. /**
  86414. * Turn this value on if you want to pause FPS computation when in background
  86415. */
  86416. disablePerformanceMonitorInBackground: boolean;
  86417. /**
  86418. * Gets the performance monitor attached to this engine
  86419. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  86420. */
  86421. readonly performanceMonitor: PerformanceMonitor;
  86422. /**
  86423. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  86424. */
  86425. disableVertexArrayObjects: boolean;
  86426. /** @hidden */
  86427. protected _depthCullingState: _DepthCullingState;
  86428. /** @hidden */
  86429. protected _stencilState: _StencilState;
  86430. /** @hidden */
  86431. protected _alphaState: _AlphaState;
  86432. /** @hidden */
  86433. protected _alphaMode: number;
  86434. protected _internalTexturesCache: InternalTexture[];
  86435. /** @hidden */
  86436. protected _activeChannel: number;
  86437. private _currentTextureChannel;
  86438. /** @hidden */
  86439. protected _boundTexturesCache: {
  86440. [key: string]: Nullable<InternalTexture>;
  86441. };
  86442. /** @hidden */
  86443. protected _currentEffect: Nullable<Effect>;
  86444. /** @hidden */
  86445. protected _currentProgram: Nullable<WebGLProgram>;
  86446. private _compiledEffects;
  86447. private _vertexAttribArraysEnabled;
  86448. /** @hidden */
  86449. protected _cachedViewport: Nullable<Viewport>;
  86450. private _cachedVertexArrayObject;
  86451. /** @hidden */
  86452. protected _cachedVertexBuffers: any;
  86453. /** @hidden */
  86454. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  86455. /** @hidden */
  86456. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  86457. /** @hidden */
  86458. protected _currentRenderTarget: Nullable<InternalTexture>;
  86459. private _uintIndicesCurrentlySet;
  86460. private _currentBoundBuffer;
  86461. /** @hidden */
  86462. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  86463. private _currentBufferPointers;
  86464. private _currentInstanceLocations;
  86465. private _currentInstanceBuffers;
  86466. private _textureUnits;
  86467. private _firstBoundInternalTextureTracker;
  86468. private _lastBoundInternalTextureTracker;
  86469. private _workingCanvas;
  86470. private _workingContext;
  86471. private _rescalePostProcess;
  86472. private _dummyFramebuffer;
  86473. private _externalData;
  86474. private _bindedRenderFunction;
  86475. private _vaoRecordInProgress;
  86476. private _mustWipeVertexAttributes;
  86477. private _emptyTexture;
  86478. private _emptyCubeTexture;
  86479. private _emptyTexture3D;
  86480. /** @hidden */
  86481. _frameHandler: number;
  86482. private _nextFreeTextureSlots;
  86483. private _maxSimultaneousTextures;
  86484. private _activeRequests;
  86485. private _texturesSupported;
  86486. private _textureFormatInUse;
  86487. /**
  86488. * Gets the list of texture formats supported
  86489. */
  86490. readonly texturesSupported: Array<string>;
  86491. /**
  86492. * Gets the list of texture formats in use
  86493. */
  86494. readonly textureFormatInUse: Nullable<string>;
  86495. /**
  86496. * Gets the current viewport
  86497. */
  86498. readonly currentViewport: Nullable<Viewport>;
  86499. /**
  86500. * Gets the default empty texture
  86501. */
  86502. readonly emptyTexture: InternalTexture;
  86503. /**
  86504. * Gets the default empty 3D texture
  86505. */
  86506. readonly emptyTexture3D: InternalTexture;
  86507. /**
  86508. * Gets the default empty cube texture
  86509. */
  86510. readonly emptyCubeTexture: InternalTexture;
  86511. /**
  86512. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  86513. */
  86514. readonly premultipliedAlpha: boolean;
  86515. /**
  86516. * Creates a new engine
  86517. * @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
  86518. * @param antialias defines enable antialiasing (default: false)
  86519. * @param options defines further options to be sent to the getContext() function
  86520. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  86521. */
  86522. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  86523. private _disableTouchAction;
  86524. private _rebuildInternalTextures;
  86525. private _rebuildEffects;
  86526. /**
  86527. * Gets a boolean indicating if all created effects are ready
  86528. * @returns true if all effects are ready
  86529. */
  86530. areAllEffectsReady(): boolean;
  86531. private _rebuildBuffers;
  86532. private _initGLContext;
  86533. /**
  86534. * Gets version of the current webGL context
  86535. */
  86536. readonly webGLVersion: number;
  86537. /**
  86538. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  86539. */
  86540. readonly isStencilEnable: boolean;
  86541. private _prepareWorkingCanvas;
  86542. /**
  86543. * Reset the texture cache to empty state
  86544. */
  86545. resetTextureCache(): void;
  86546. /**
  86547. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  86548. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86549. * @returns true if engine is in deterministic lock step mode
  86550. */
  86551. isDeterministicLockStep(): boolean;
  86552. /**
  86553. * Gets the max steps when engine is running in deterministic lock step
  86554. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86555. * @returns the max steps
  86556. */
  86557. getLockstepMaxSteps(): number;
  86558. /**
  86559. * Gets an object containing information about the current webGL context
  86560. * @returns an object containing the vender, the renderer and the version of the current webGL context
  86561. */
  86562. getGlInfo(): {
  86563. vendor: string;
  86564. renderer: string;
  86565. version: string;
  86566. };
  86567. /**
  86568. * Gets current aspect ratio
  86569. * @param camera defines the camera to use to get the aspect ratio
  86570. * @param useScreen defines if screen size must be used (or the current render target if any)
  86571. * @returns a number defining the aspect ratio
  86572. */
  86573. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  86574. /**
  86575. * Gets current screen aspect ratio
  86576. * @returns a number defining the aspect ratio
  86577. */
  86578. getScreenAspectRatio(): number;
  86579. /**
  86580. * Gets the current render width
  86581. * @param useScreen defines if screen size must be used (or the current render target if any)
  86582. * @returns a number defining the current render width
  86583. */
  86584. getRenderWidth(useScreen?: boolean): number;
  86585. /**
  86586. * Gets the current render height
  86587. * @param useScreen defines if screen size must be used (or the current render target if any)
  86588. * @returns a number defining the current render height
  86589. */
  86590. getRenderHeight(useScreen?: boolean): number;
  86591. /**
  86592. * Gets the HTML canvas attached with the current webGL context
  86593. * @returns a HTML canvas
  86594. */
  86595. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  86596. /**
  86597. * Gets the client rect of the HTML canvas attached with the current webGL context
  86598. * @returns a client rectanglee
  86599. */
  86600. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  86601. /**
  86602. * Defines the hardware scaling level.
  86603. * By default the hardware scaling level is computed from the window device ratio.
  86604. * 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.
  86605. * @param level defines the level to use
  86606. */
  86607. setHardwareScalingLevel(level: number): void;
  86608. /**
  86609. * Gets the current hardware scaling level.
  86610. * By default the hardware scaling level is computed from the window device ratio.
  86611. * 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.
  86612. * @returns a number indicating the current hardware scaling level
  86613. */
  86614. getHardwareScalingLevel(): number;
  86615. /**
  86616. * Gets the list of loaded textures
  86617. * @returns an array containing all loaded textures
  86618. */
  86619. getLoadedTexturesCache(): InternalTexture[];
  86620. /**
  86621. * Gets the object containing all engine capabilities
  86622. * @returns the EngineCapabilities object
  86623. */
  86624. getCaps(): EngineCapabilities;
  86625. /**
  86626. * Gets the current depth function
  86627. * @returns a number defining the depth function
  86628. */
  86629. getDepthFunction(): Nullable<number>;
  86630. /**
  86631. * Sets the current depth function
  86632. * @param depthFunc defines the function to use
  86633. */
  86634. setDepthFunction(depthFunc: number): void;
  86635. /**
  86636. * Sets the current depth function to GREATER
  86637. */
  86638. setDepthFunctionToGreater(): void;
  86639. /**
  86640. * Sets the current depth function to GEQUAL
  86641. */
  86642. setDepthFunctionToGreaterOrEqual(): void;
  86643. /**
  86644. * Sets the current depth function to LESS
  86645. */
  86646. setDepthFunctionToLess(): void;
  86647. private _cachedStencilBuffer;
  86648. private _cachedStencilFunction;
  86649. private _cachedStencilMask;
  86650. private _cachedStencilOperationPass;
  86651. private _cachedStencilOperationFail;
  86652. private _cachedStencilOperationDepthFail;
  86653. private _cachedStencilReference;
  86654. /**
  86655. * Caches the the state of the stencil buffer
  86656. */
  86657. cacheStencilState(): void;
  86658. /**
  86659. * Restores the state of the stencil buffer
  86660. */
  86661. restoreStencilState(): void;
  86662. /**
  86663. * Sets the current depth function to LEQUAL
  86664. */
  86665. setDepthFunctionToLessOrEqual(): void;
  86666. /**
  86667. * Gets a boolean indicating if stencil buffer is enabled
  86668. * @returns the current stencil buffer state
  86669. */
  86670. getStencilBuffer(): boolean;
  86671. /**
  86672. * Enable or disable the stencil buffer
  86673. * @param enable defines if the stencil buffer must be enabled or disabled
  86674. */
  86675. setStencilBuffer(enable: boolean): void;
  86676. /**
  86677. * Gets the current stencil mask
  86678. * @returns a number defining the new stencil mask to use
  86679. */
  86680. getStencilMask(): number;
  86681. /**
  86682. * Sets the current stencil mask
  86683. * @param mask defines the new stencil mask to use
  86684. */
  86685. setStencilMask(mask: number): void;
  86686. /**
  86687. * Gets the current stencil function
  86688. * @returns a number defining the stencil function to use
  86689. */
  86690. getStencilFunction(): number;
  86691. /**
  86692. * Gets the current stencil reference value
  86693. * @returns a number defining the stencil reference value to use
  86694. */
  86695. getStencilFunctionReference(): number;
  86696. /**
  86697. * Gets the current stencil mask
  86698. * @returns a number defining the stencil mask to use
  86699. */
  86700. getStencilFunctionMask(): number;
  86701. /**
  86702. * Sets the current stencil function
  86703. * @param stencilFunc defines the new stencil function to use
  86704. */
  86705. setStencilFunction(stencilFunc: number): void;
  86706. /**
  86707. * Sets the current stencil reference
  86708. * @param reference defines the new stencil reference to use
  86709. */
  86710. setStencilFunctionReference(reference: number): void;
  86711. /**
  86712. * Sets the current stencil mask
  86713. * @param mask defines the new stencil mask to use
  86714. */
  86715. setStencilFunctionMask(mask: number): void;
  86716. /**
  86717. * Gets the current stencil operation when stencil fails
  86718. * @returns a number defining stencil operation to use when stencil fails
  86719. */
  86720. getStencilOperationFail(): number;
  86721. /**
  86722. * Gets the current stencil operation when depth fails
  86723. * @returns a number defining stencil operation to use when depth fails
  86724. */
  86725. getStencilOperationDepthFail(): number;
  86726. /**
  86727. * Gets the current stencil operation when stencil passes
  86728. * @returns a number defining stencil operation to use when stencil passes
  86729. */
  86730. getStencilOperationPass(): number;
  86731. /**
  86732. * Sets the stencil operation to use when stencil fails
  86733. * @param operation defines the stencil operation to use when stencil fails
  86734. */
  86735. setStencilOperationFail(operation: number): void;
  86736. /**
  86737. * Sets the stencil operation to use when depth fails
  86738. * @param operation defines the stencil operation to use when depth fails
  86739. */
  86740. setStencilOperationDepthFail(operation: number): void;
  86741. /**
  86742. * Sets the stencil operation to use when stencil passes
  86743. * @param operation defines the stencil operation to use when stencil passes
  86744. */
  86745. setStencilOperationPass(operation: number): void;
  86746. /**
  86747. * Sets a boolean indicating if the dithering state is enabled or disabled
  86748. * @param value defines the dithering state
  86749. */
  86750. setDitheringState(value: boolean): void;
  86751. /**
  86752. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  86753. * @param value defines the rasterizer state
  86754. */
  86755. setRasterizerState(value: boolean): void;
  86756. /**
  86757. * stop executing a render loop function and remove it from the execution array
  86758. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  86759. */
  86760. stopRenderLoop(renderFunction?: () => void): void;
  86761. /** @hidden */
  86762. _renderLoop(): void;
  86763. /**
  86764. * Register and execute a render loop. The engine can have more than one render function
  86765. * @param renderFunction defines the function to continuously execute
  86766. */
  86767. runRenderLoop(renderFunction: () => void): void;
  86768. /**
  86769. * Toggle full screen mode
  86770. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86771. */
  86772. switchFullscreen(requestPointerLock: boolean): void;
  86773. /**
  86774. * Enters full screen mode
  86775. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86776. */
  86777. enterFullscreen(requestPointerLock: boolean): void;
  86778. /**
  86779. * Exits full screen mode
  86780. */
  86781. exitFullscreen(): void;
  86782. /**
  86783. * Clear the current render buffer or the current render target (if any is set up)
  86784. * @param color defines the color to use
  86785. * @param backBuffer defines if the back buffer must be cleared
  86786. * @param depth defines if the depth buffer must be cleared
  86787. * @param stencil defines if the stencil buffer must be cleared
  86788. */
  86789. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  86790. /**
  86791. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  86792. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86793. * @param y defines the y-coordinate of the corner of the clear rectangle
  86794. * @param width defines the width of the clear rectangle
  86795. * @param height defines the height of the clear rectangle
  86796. * @param clearColor defines the clear color
  86797. */
  86798. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  86799. /**
  86800. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  86801. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86802. * @param y defines the y-coordinate of the corner of the clear rectangle
  86803. * @param width defines the width of the clear rectangle
  86804. * @param height defines the height of the clear rectangle
  86805. */
  86806. enableScissor(x: number, y: number, width: number, height: number): void;
  86807. /**
  86808. * Disable previously set scissor test rectangle
  86809. */
  86810. disableScissor(): void;
  86811. private _viewportCached;
  86812. /** @hidden */
  86813. _viewport(x: number, y: number, width: number, height: number): void;
  86814. /**
  86815. * Set the WebGL's viewport
  86816. * @param viewport defines the viewport element to be used
  86817. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  86818. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  86819. */
  86820. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  86821. /**
  86822. * Directly set the WebGL Viewport
  86823. * @param x defines the x coordinate of the viewport (in screen space)
  86824. * @param y defines the y coordinate of the viewport (in screen space)
  86825. * @param width defines the width of the viewport (in screen space)
  86826. * @param height defines the height of the viewport (in screen space)
  86827. * @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
  86828. */
  86829. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  86830. /**
  86831. * Begin a new frame
  86832. */
  86833. beginFrame(): void;
  86834. /**
  86835. * Enf the current frame
  86836. */
  86837. endFrame(): void;
  86838. /**
  86839. * Resize the view according to the canvas' size
  86840. */
  86841. resize(): void;
  86842. /**
  86843. * Force a specific size of the canvas
  86844. * @param width defines the new canvas' width
  86845. * @param height defines the new canvas' height
  86846. */
  86847. setSize(width: number, height: number): void;
  86848. /**
  86849. * Gets a boolean indicating if a webVR device was detected
  86850. * @returns true if a webVR device was detected
  86851. */
  86852. isVRDevicePresent(): boolean;
  86853. /**
  86854. * Gets the current webVR device
  86855. * @returns the current webVR device (or null)
  86856. */
  86857. getVRDevice(): any;
  86858. /**
  86859. * Initializes a webVR display and starts listening to display change events
  86860. * The onVRDisplayChangedObservable will be notified upon these changes
  86861. * @returns The onVRDisplayChangedObservable
  86862. */
  86863. initWebVR(): Observable<IDisplayChangedEventArgs>;
  86864. /**
  86865. * Initializes a webVR display and starts listening to display change events
  86866. * The onVRDisplayChangedObservable will be notified upon these changes
  86867. * @returns A promise containing a VRDisplay and if vr is supported
  86868. */
  86869. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  86870. /**
  86871. * Call this function to switch to webVR mode
  86872. * Will do nothing if webVR is not supported or if there is no webVR device
  86873. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86874. */
  86875. enableVR(): void;
  86876. /**
  86877. * Call this function to leave webVR mode
  86878. * Will do nothing if webVR is not supported or if there is no webVR device
  86879. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86880. */
  86881. disableVR(): void;
  86882. private _onVRFullScreenTriggered;
  86883. private _getVRDisplaysAsync;
  86884. /**
  86885. * Binds the frame buffer to the specified texture.
  86886. * @param texture The texture to render to or null for the default canvas
  86887. * @param faceIndex The face of the texture to render to in case of cube texture
  86888. * @param requiredWidth The width of the target to render to
  86889. * @param requiredHeight The height of the target to render to
  86890. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  86891. * @param depthStencilTexture The depth stencil texture to use to render
  86892. * @param lodLevel defines le lod level to bind to the frame buffer
  86893. */
  86894. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  86895. private bindUnboundFramebuffer;
  86896. /**
  86897. * Unbind the current render target texture from the webGL context
  86898. * @param texture defines the render target texture to unbind
  86899. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86900. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86901. */
  86902. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86903. /**
  86904. * Unbind a list of render target textures from the webGL context
  86905. * This is used only when drawBuffer extension or webGL2 are active
  86906. * @param textures defines the render target textures to unbind
  86907. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86908. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86909. */
  86910. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86911. /**
  86912. * Force the mipmap generation for the given render target texture
  86913. * @param texture defines the render target texture to use
  86914. */
  86915. generateMipMapsForCubemap(texture: InternalTexture): void;
  86916. /**
  86917. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  86918. */
  86919. flushFramebuffer(): void;
  86920. /**
  86921. * Unbind the current render target and bind the default framebuffer
  86922. */
  86923. restoreDefaultFramebuffer(): void;
  86924. /**
  86925. * Create an uniform buffer
  86926. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86927. * @param elements defines the content of the uniform buffer
  86928. * @returns the webGL uniform buffer
  86929. */
  86930. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  86931. /**
  86932. * Create a dynamic uniform buffer
  86933. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86934. * @param elements defines the content of the uniform buffer
  86935. * @returns the webGL uniform buffer
  86936. */
  86937. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  86938. /**
  86939. * Update an existing uniform buffer
  86940. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86941. * @param uniformBuffer defines the target uniform buffer
  86942. * @param elements defines the content to update
  86943. * @param offset defines the offset in the uniform buffer where update should start
  86944. * @param count defines the size of the data to update
  86945. */
  86946. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86947. private _resetVertexBufferBinding;
  86948. /**
  86949. * Creates a vertex buffer
  86950. * @param data the data for the vertex buffer
  86951. * @returns the new WebGL static buffer
  86952. */
  86953. createVertexBuffer(data: DataArray): WebGLBuffer;
  86954. /**
  86955. * Creates a dynamic vertex buffer
  86956. * @param data the data for the dynamic vertex buffer
  86957. * @returns the new WebGL dynamic buffer
  86958. */
  86959. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  86960. /**
  86961. * Update a dynamic index buffer
  86962. * @param indexBuffer defines the target index buffer
  86963. * @param indices defines the data to update
  86964. * @param offset defines the offset in the target index buffer where update should start
  86965. */
  86966. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  86967. /**
  86968. * Updates a dynamic vertex buffer.
  86969. * @param vertexBuffer the vertex buffer to update
  86970. * @param data the data used to update the vertex buffer
  86971. * @param byteOffset the byte offset of the data
  86972. * @param byteLength the byte length of the data
  86973. */
  86974. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  86975. private _resetIndexBufferBinding;
  86976. /**
  86977. * Creates a new index buffer
  86978. * @param indices defines the content of the index buffer
  86979. * @param updatable defines if the index buffer must be updatable
  86980. * @returns a new webGL buffer
  86981. */
  86982. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  86983. /**
  86984. * Bind a webGL buffer to the webGL context
  86985. * @param buffer defines the buffer to bind
  86986. */
  86987. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  86988. /**
  86989. * Bind an uniform buffer to the current webGL context
  86990. * @param buffer defines the buffer to bind
  86991. */
  86992. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  86993. /**
  86994. * Bind a buffer to the current webGL context at a given location
  86995. * @param buffer defines the buffer to bind
  86996. * @param location defines the index where to bind the buffer
  86997. */
  86998. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  86999. /**
  87000. * Bind a specific block at a given index in a specific shader program
  87001. * @param shaderProgram defines the shader program
  87002. * @param blockName defines the block name
  87003. * @param index defines the index where to bind the block
  87004. */
  87005. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  87006. private bindIndexBuffer;
  87007. private bindBuffer;
  87008. /**
  87009. * update the bound buffer with the given data
  87010. * @param data defines the data to update
  87011. */
  87012. updateArrayBuffer(data: Float32Array): void;
  87013. private _vertexAttribPointer;
  87014. private _bindIndexBufferWithCache;
  87015. private _bindVertexBuffersAttributes;
  87016. /**
  87017. * Records a vertex array object
  87018. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87019. * @param vertexBuffers defines the list of vertex buffers to store
  87020. * @param indexBuffer defines the index buffer to store
  87021. * @param effect defines the effect to store
  87022. * @returns the new vertex array object
  87023. */
  87024. recordVertexArrayObject(vertexBuffers: {
  87025. [key: string]: VertexBuffer;
  87026. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  87027. /**
  87028. * Bind a specific vertex array object
  87029. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87030. * @param vertexArrayObject defines the vertex array object to bind
  87031. * @param indexBuffer defines the index buffer to bind
  87032. */
  87033. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  87034. /**
  87035. * Bind webGl buffers directly to the webGL context
  87036. * @param vertexBuffer defines the vertex buffer to bind
  87037. * @param indexBuffer defines the index buffer to bind
  87038. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  87039. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  87040. * @param effect defines the effect associated with the vertex buffer
  87041. */
  87042. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  87043. private _unbindVertexArrayObject;
  87044. /**
  87045. * Bind a list of vertex buffers to the webGL context
  87046. * @param vertexBuffers defines the list of vertex buffers to bind
  87047. * @param indexBuffer defines the index buffer to bind
  87048. * @param effect defines the effect associated with the vertex buffers
  87049. */
  87050. bindBuffers(vertexBuffers: {
  87051. [key: string]: Nullable<VertexBuffer>;
  87052. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  87053. /**
  87054. * Unbind all instance attributes
  87055. */
  87056. unbindInstanceAttributes(): void;
  87057. /**
  87058. * Release and free the memory of a vertex array object
  87059. * @param vao defines the vertex array object to delete
  87060. */
  87061. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  87062. /** @hidden */
  87063. _releaseBuffer(buffer: WebGLBuffer): boolean;
  87064. /**
  87065. * Creates a webGL buffer to use with instanciation
  87066. * @param capacity defines the size of the buffer
  87067. * @returns the webGL buffer
  87068. */
  87069. createInstancesBuffer(capacity: number): WebGLBuffer;
  87070. /**
  87071. * Delete a webGL buffer used with instanciation
  87072. * @param buffer defines the webGL buffer to delete
  87073. */
  87074. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  87075. /**
  87076. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  87077. * @param instancesBuffer defines the webGL buffer to update and bind
  87078. * @param data defines the data to store in the buffer
  87079. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  87080. */
  87081. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  87082. /**
  87083. * Apply all cached states (depth, culling, stencil and alpha)
  87084. */
  87085. applyStates(): void;
  87086. /**
  87087. * Send a draw order
  87088. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87089. * @param indexStart defines the starting index
  87090. * @param indexCount defines the number of index to draw
  87091. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87092. */
  87093. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  87094. /**
  87095. * Draw a list of points
  87096. * @param verticesStart defines the index of first vertex to draw
  87097. * @param verticesCount defines the count of vertices to draw
  87098. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87099. */
  87100. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87101. /**
  87102. * Draw a list of unindexed primitives
  87103. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87104. * @param verticesStart defines the index of first vertex to draw
  87105. * @param verticesCount defines the count of vertices to draw
  87106. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87107. */
  87108. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87109. /**
  87110. * Draw a list of indexed primitives
  87111. * @param fillMode defines the primitive to use
  87112. * @param indexStart defines the starting index
  87113. * @param indexCount defines the number of index to draw
  87114. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87115. */
  87116. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  87117. /**
  87118. * Draw a list of unindexed primitives
  87119. * @param fillMode defines the primitive to use
  87120. * @param verticesStart defines the index of first vertex to draw
  87121. * @param verticesCount defines the count of vertices to draw
  87122. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87123. */
  87124. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87125. private _drawMode;
  87126. /** @hidden */
  87127. _releaseEffect(effect: Effect): void;
  87128. /** @hidden */
  87129. _deleteProgram(program: WebGLProgram): void;
  87130. /**
  87131. * Create a new effect (used to store vertex/fragment shaders)
  87132. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  87133. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  87134. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  87135. * @param samplers defines an array of string used to represent textures
  87136. * @param defines defines the string containing the defines to use to compile the shaders
  87137. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  87138. * @param onCompiled defines a function to call when the effect creation is successful
  87139. * @param onError defines a function to call when the effect creation has failed
  87140. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  87141. * @returns the new Effect
  87142. */
  87143. 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;
  87144. private _compileShader;
  87145. private _compileRawShader;
  87146. /**
  87147. * Directly creates a webGL program
  87148. * @param vertexCode defines the vertex shader code to use
  87149. * @param fragmentCode defines the fragment shader code to use
  87150. * @param context defines the webGL context to use (if not set, the current one will be used)
  87151. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87152. * @returns the new webGL program
  87153. */
  87154. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87155. /**
  87156. * Creates a webGL program
  87157. * @param vertexCode defines the vertex shader code to use
  87158. * @param fragmentCode defines the fragment shader code to use
  87159. * @param defines defines the string containing the defines to use to compile the shaders
  87160. * @param context defines the webGL context to use (if not set, the current one will be used)
  87161. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87162. * @returns the new webGL program
  87163. */
  87164. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87165. private _createShaderProgram;
  87166. private _finalizeProgram;
  87167. /** @hidden */
  87168. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  87169. /** @hidden */
  87170. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  87171. /**
  87172. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  87173. * @param shaderProgram defines the webGL program to use
  87174. * @param uniformsNames defines the list of uniform names
  87175. * @returns an array of webGL uniform locations
  87176. */
  87177. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  87178. /**
  87179. * Gets the lsit of active attributes for a given webGL program
  87180. * @param shaderProgram defines the webGL program to use
  87181. * @param attributesNames defines the list of attribute names to get
  87182. * @returns an array of indices indicating the offset of each attribute
  87183. */
  87184. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  87185. /**
  87186. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  87187. * @param effect defines the effect to activate
  87188. */
  87189. enableEffect(effect: Nullable<Effect>): void;
  87190. /**
  87191. * Set the value of an uniform to an array of int32
  87192. * @param uniform defines the webGL uniform location where to store the value
  87193. * @param array defines the array of int32 to store
  87194. */
  87195. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87196. /**
  87197. * Set the value of an uniform to an array of int32 (stored as vec2)
  87198. * @param uniform defines the webGL uniform location where to store the value
  87199. * @param array defines the array of int32 to store
  87200. */
  87201. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87202. /**
  87203. * Set the value of an uniform to an array of int32 (stored as vec3)
  87204. * @param uniform defines the webGL uniform location where to store the value
  87205. * @param array defines the array of int32 to store
  87206. */
  87207. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87208. /**
  87209. * Set the value of an uniform to an array of int32 (stored as vec4)
  87210. * @param uniform defines the webGL uniform location where to store the value
  87211. * @param array defines the array of int32 to store
  87212. */
  87213. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87214. /**
  87215. * Set the value of an uniform to an array of float32
  87216. * @param uniform defines the webGL uniform location where to store the value
  87217. * @param array defines the array of float32 to store
  87218. */
  87219. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87220. /**
  87221. * Set the value of an uniform to an array of float32 (stored as vec2)
  87222. * @param uniform defines the webGL uniform location where to store the value
  87223. * @param array defines the array of float32 to store
  87224. */
  87225. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87226. /**
  87227. * Set the value of an uniform to an array of float32 (stored as vec3)
  87228. * @param uniform defines the webGL uniform location where to store the value
  87229. * @param array defines the array of float32 to store
  87230. */
  87231. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87232. /**
  87233. * Set the value of an uniform to an array of float32 (stored as vec4)
  87234. * @param uniform defines the webGL uniform location where to store the value
  87235. * @param array defines the array of float32 to store
  87236. */
  87237. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87238. /**
  87239. * Set the value of an uniform to an array of number
  87240. * @param uniform defines the webGL uniform location where to store the value
  87241. * @param array defines the array of number to store
  87242. */
  87243. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87244. /**
  87245. * Set the value of an uniform to an array of number (stored as vec2)
  87246. * @param uniform defines the webGL uniform location where to store the value
  87247. * @param array defines the array of number to store
  87248. */
  87249. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87250. /**
  87251. * Set the value of an uniform to an array of number (stored as vec3)
  87252. * @param uniform defines the webGL uniform location where to store the value
  87253. * @param array defines the array of number to store
  87254. */
  87255. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87256. /**
  87257. * Set the value of an uniform to an array of number (stored as vec4)
  87258. * @param uniform defines the webGL uniform location where to store the value
  87259. * @param array defines the array of number to store
  87260. */
  87261. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87262. /**
  87263. * Set the value of an uniform to an array of float32 (stored as matrices)
  87264. * @param uniform defines the webGL uniform location where to store the value
  87265. * @param matrices defines the array of float32 to store
  87266. */
  87267. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  87268. /**
  87269. * Set the value of an uniform to a matrix
  87270. * @param uniform defines the webGL uniform location where to store the value
  87271. * @param matrix defines the matrix to store
  87272. */
  87273. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  87274. /**
  87275. * Set the value of an uniform to a matrix (3x3)
  87276. * @param uniform defines the webGL uniform location where to store the value
  87277. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  87278. */
  87279. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87280. /**
  87281. * Set the value of an uniform to a matrix (2x2)
  87282. * @param uniform defines the webGL uniform location where to store the value
  87283. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  87284. */
  87285. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87286. /**
  87287. * Set the value of an uniform to a number (int)
  87288. * @param uniform defines the webGL uniform location where to store the value
  87289. * @param value defines the int number to store
  87290. */
  87291. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87292. /**
  87293. * Set the value of an uniform to a number (float)
  87294. * @param uniform defines the webGL uniform location where to store the value
  87295. * @param value defines the float number to store
  87296. */
  87297. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87298. /**
  87299. * Set the value of an uniform to a vec2
  87300. * @param uniform defines the webGL uniform location where to store the value
  87301. * @param x defines the 1st component of the value
  87302. * @param y defines the 2nd component of the value
  87303. */
  87304. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  87305. /**
  87306. * Set the value of an uniform to a vec3
  87307. * @param uniform defines the webGL uniform location where to store the value
  87308. * @param x defines the 1st component of the value
  87309. * @param y defines the 2nd component of the value
  87310. * @param z defines the 3rd component of the value
  87311. */
  87312. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  87313. /**
  87314. * Set the value of an uniform to a boolean
  87315. * @param uniform defines the webGL uniform location where to store the value
  87316. * @param bool defines the boolean to store
  87317. */
  87318. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  87319. /**
  87320. * Set the value of an uniform to a vec4
  87321. * @param uniform defines the webGL uniform location where to store the value
  87322. * @param x defines the 1st component of the value
  87323. * @param y defines the 2nd component of the value
  87324. * @param z defines the 3rd component of the value
  87325. * @param w defines the 4th component of the value
  87326. */
  87327. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  87328. /**
  87329. * Set the value of an uniform to a Color3
  87330. * @param uniform defines the webGL uniform location where to store the value
  87331. * @param color3 defines the color to store
  87332. */
  87333. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  87334. /**
  87335. * Set the value of an uniform to a Color3 and an alpha value
  87336. * @param uniform defines the webGL uniform location where to store the value
  87337. * @param color3 defines the color to store
  87338. * @param alpha defines the alpha component to store
  87339. */
  87340. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  87341. /**
  87342. * Sets a Color4 on a uniform variable
  87343. * @param uniform defines the uniform location
  87344. * @param color4 defines the value to be set
  87345. */
  87346. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  87347. /**
  87348. * Set various states to the webGL context
  87349. * @param culling defines backface culling state
  87350. * @param zOffset defines the value to apply to zOffset (0 by default)
  87351. * @param force defines if states must be applied even if cache is up to date
  87352. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  87353. */
  87354. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  87355. /**
  87356. * Set the z offset to apply to current rendering
  87357. * @param value defines the offset to apply
  87358. */
  87359. setZOffset(value: number): void;
  87360. /**
  87361. * Gets the current value of the zOffset
  87362. * @returns the current zOffset state
  87363. */
  87364. getZOffset(): number;
  87365. /**
  87366. * Enable or disable depth buffering
  87367. * @param enable defines the state to set
  87368. */
  87369. setDepthBuffer(enable: boolean): void;
  87370. /**
  87371. * Gets a boolean indicating if depth writing is enabled
  87372. * @returns the current depth writing state
  87373. */
  87374. getDepthWrite(): boolean;
  87375. /**
  87376. * Enable or disable depth writing
  87377. * @param enable defines the state to set
  87378. */
  87379. setDepthWrite(enable: boolean): void;
  87380. /**
  87381. * Enable or disable color writing
  87382. * @param enable defines the state to set
  87383. */
  87384. setColorWrite(enable: boolean): void;
  87385. /**
  87386. * Gets a boolean indicating if color writing is enabled
  87387. * @returns the current color writing state
  87388. */
  87389. getColorWrite(): boolean;
  87390. /**
  87391. * Sets alpha constants used by some alpha blending modes
  87392. * @param r defines the red component
  87393. * @param g defines the green component
  87394. * @param b defines the blue component
  87395. * @param a defines the alpha component
  87396. */
  87397. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  87398. /**
  87399. * Sets the current alpha mode
  87400. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  87401. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  87402. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87403. */
  87404. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  87405. /**
  87406. * Gets the current alpha mode
  87407. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87408. * @returns the current alpha mode
  87409. */
  87410. getAlphaMode(): number;
  87411. /**
  87412. * Clears the list of texture accessible through engine.
  87413. * This can help preventing texture load conflict due to name collision.
  87414. */
  87415. clearInternalTexturesCache(): void;
  87416. /**
  87417. * Force the entire cache to be cleared
  87418. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  87419. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  87420. */
  87421. wipeCaches(bruteForce?: boolean): void;
  87422. /**
  87423. * Set the compressed texture format to use, based on the formats you have, and the formats
  87424. * supported by the hardware / browser.
  87425. *
  87426. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  87427. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  87428. * to API arguments needed to compressed textures. This puts the burden on the container
  87429. * generator to house the arcane code for determining these for current & future formats.
  87430. *
  87431. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  87432. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  87433. *
  87434. * Note: The result of this call is not taken into account when a texture is base64.
  87435. *
  87436. * @param formatsAvailable defines the list of those format families you have created
  87437. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  87438. *
  87439. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  87440. * @returns The extension selected.
  87441. */
  87442. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  87443. private _getSamplingParameters;
  87444. private _partialLoadImg;
  87445. private _cascadeLoadImgs;
  87446. /** @hidden */
  87447. _createTexture(): WebGLTexture;
  87448. /**
  87449. * Usually called from Texture.ts.
  87450. * Passed information to create a WebGLTexture
  87451. * @param urlArg defines a value which contains one of the following:
  87452. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  87453. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  87454. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  87455. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  87456. * @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)
  87457. * @param scene needed for loading to the correct scene
  87458. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  87459. * @param onLoad optional callback to be called upon successful completion
  87460. * @param onError optional callback to be called upon failure
  87461. * @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
  87462. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  87463. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  87464. * @param forcedExtension defines the extension to use to pick the right loader
  87465. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  87466. * @returns a InternalTexture for assignment back into BABYLON.Texture
  87467. */
  87468. 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;
  87469. private _rescaleTexture;
  87470. /**
  87471. * Update a raw texture
  87472. * @param texture defines the texture to update
  87473. * @param data defines the data to store in the texture
  87474. * @param format defines the format of the data
  87475. * @param invertY defines if data must be stored with Y axis inverted
  87476. * @param compression defines the compression used (null by default)
  87477. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87478. */
  87479. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  87480. /**
  87481. * Creates a raw texture
  87482. * @param data defines the data to store in the texture
  87483. * @param width defines the width of the texture
  87484. * @param height defines the height of the texture
  87485. * @param format defines the format of the data
  87486. * @param generateMipMaps defines if the engine should generate the mip levels
  87487. * @param invertY defines if data must be stored with Y axis inverted
  87488. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87489. * @param compression defines the compression used (null by default)
  87490. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87491. * @returns the raw texture inside an InternalTexture
  87492. */
  87493. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  87494. private _unpackFlipYCached;
  87495. /**
  87496. * In case you are sharing the context with other applications, it might
  87497. * be interested to not cache the unpack flip y state to ensure a consistent
  87498. * value would be set.
  87499. */
  87500. enableUnpackFlipYCached: boolean;
  87501. /** @hidden */
  87502. _unpackFlipY(value: boolean): void;
  87503. /** @hidden */
  87504. _getUnpackAlignement(): number;
  87505. /**
  87506. * Creates a dynamic texture
  87507. * @param width defines the width of the texture
  87508. * @param height defines the height of the texture
  87509. * @param generateMipMaps defines if the engine should generate the mip levels
  87510. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87511. * @returns the dynamic texture inside an InternalTexture
  87512. */
  87513. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87514. /**
  87515. * Update the sampling mode of a given texture
  87516. * @param samplingMode defines the required sampling mode
  87517. * @param texture defines the texture to update
  87518. */
  87519. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  87520. /**
  87521. * Update the content of a dynamic texture
  87522. * @param texture defines the texture to update
  87523. * @param canvas defines the canvas containing the source
  87524. * @param invertY defines if data must be stored with Y axis inverted
  87525. * @param premulAlpha defines if alpha is stored as premultiplied
  87526. * @param format defines the format of the data
  87527. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87528. */
  87529. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87530. /**
  87531. * Update a video texture
  87532. * @param texture defines the texture to update
  87533. * @param video defines the video element to use
  87534. * @param invertY defines if data must be stored with Y axis inverted
  87535. */
  87536. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  87537. /**
  87538. * Updates a depth texture Comparison Mode and Function.
  87539. * If the comparison Function is equal to 0, the mode will be set to none.
  87540. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  87541. * @param texture The texture to set the comparison function for
  87542. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  87543. */
  87544. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  87545. private _setupDepthStencilTexture;
  87546. /**
  87547. * Creates a depth stencil texture.
  87548. * This is only available in WebGL 2 or with the depth texture extension available.
  87549. * @param size The size of face edge in the texture.
  87550. * @param options The options defining the texture.
  87551. * @returns The texture
  87552. */
  87553. createDepthStencilTexture(size: number | {
  87554. width: number;
  87555. height: number;
  87556. }, options: DepthTextureCreationOptions): InternalTexture;
  87557. /**
  87558. * Creates a depth stencil texture.
  87559. * This is only available in WebGL 2 or with the depth texture extension available.
  87560. * @param size The size of face edge in the texture.
  87561. * @param options The options defining the texture.
  87562. * @returns The texture
  87563. */
  87564. private _createDepthStencilTexture;
  87565. /**
  87566. * Creates a depth stencil cube texture.
  87567. * This is only available in WebGL 2.
  87568. * @param size The size of face edge in the cube texture.
  87569. * @param options The options defining the cube texture.
  87570. * @returns The cube texture
  87571. */
  87572. private _createDepthStencilCubeTexture;
  87573. /**
  87574. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  87575. * @param renderTarget The render target to set the frame buffer for
  87576. */
  87577. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  87578. /**
  87579. * Creates a new render target texture
  87580. * @param size defines the size of the texture
  87581. * @param options defines the options used to create the texture
  87582. * @returns a new render target texture stored in an InternalTexture
  87583. */
  87584. createRenderTargetTexture(size: number | {
  87585. width: number;
  87586. height: number;
  87587. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87588. /**
  87589. * Create a multi render target texture
  87590. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  87591. * @param size defines the size of the texture
  87592. * @param options defines the creation options
  87593. * @returns the cube texture as an InternalTexture
  87594. */
  87595. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  87596. private _setupFramebufferDepthAttachments;
  87597. /**
  87598. * Updates the sample count of a render target texture
  87599. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87600. * @param texture defines the texture to update
  87601. * @param samples defines the sample count to set
  87602. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87603. */
  87604. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  87605. /**
  87606. * Update the sample count for a given multiple render target texture
  87607. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87608. * @param textures defines the textures to update
  87609. * @param samples defines the sample count to set
  87610. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87611. */
  87612. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  87613. /** @hidden */
  87614. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87615. /** @hidden */
  87616. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87617. /** @hidden */
  87618. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87619. /** @hidden */
  87620. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  87621. /**
  87622. * Creates a new render target cube texture
  87623. * @param size defines the size of the texture
  87624. * @param options defines the options used to create the texture
  87625. * @returns a new render target cube texture stored in an InternalTexture
  87626. */
  87627. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87628. /**
  87629. * Creates a cube texture
  87630. * @param rootUrl defines the url where the files to load is located
  87631. * @param scene defines the current scene
  87632. * @param files defines the list of files to load (1 per face)
  87633. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87634. * @param onLoad defines an optional callback raised when the texture is loaded
  87635. * @param onError defines an optional callback raised if there is an issue to load the texture
  87636. * @param format defines the format of the data
  87637. * @param forcedExtension defines the extension to use to pick the right loader
  87638. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87639. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87640. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87641. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87642. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  87643. * @returns the cube texture as an InternalTexture
  87644. */
  87645. 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;
  87646. /**
  87647. * @hidden
  87648. */
  87649. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87650. /**
  87651. * Update a raw cube texture
  87652. * @param texture defines the texture to udpdate
  87653. * @param data defines the data to store
  87654. * @param format defines the data format
  87655. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87656. * @param invertY defines if data must be stored with Y axis inverted
  87657. * @param compression defines the compression used (null by default)
  87658. * @param level defines which level of the texture to update
  87659. */
  87660. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  87661. /**
  87662. * Creates a new raw cube texture
  87663. * @param data defines the array of data to use to create each face
  87664. * @param size defines the size of the textures
  87665. * @param format defines the format of the data
  87666. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87667. * @param generateMipMaps defines if the engine should generate the mip levels
  87668. * @param invertY defines if data must be stored with Y axis inverted
  87669. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87670. * @param compression defines the compression used (null by default)
  87671. * @returns the cube texture as an InternalTexture
  87672. */
  87673. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  87674. /**
  87675. * Creates a new raw cube texture from a specified url
  87676. * @param url defines the url where the data is located
  87677. * @param scene defines the current scene
  87678. * @param size defines the size of the textures
  87679. * @param format defines the format of the data
  87680. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87681. * @param noMipmap defines if the engine should avoid generating the mip levels
  87682. * @param callback defines a callback used to extract texture data from loaded data
  87683. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  87684. * @param onLoad defines a callback called when texture is loaded
  87685. * @param onError defines a callback called if there is an error
  87686. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87687. * @param invertY defines if data must be stored with Y axis inverted
  87688. * @returns the cube texture as an InternalTexture
  87689. */
  87690. 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;
  87691. /**
  87692. * Update a raw 3D texture
  87693. * @param texture defines the texture to update
  87694. * @param data defines the data to store
  87695. * @param format defines the data format
  87696. * @param invertY defines if data must be stored with Y axis inverted
  87697. * @param compression defines the used compression (can be null)
  87698. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  87699. */
  87700. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  87701. /**
  87702. * Creates a new raw 3D texture
  87703. * @param data defines the data used to create the texture
  87704. * @param width defines the width of the texture
  87705. * @param height defines the height of the texture
  87706. * @param depth defines the depth of the texture
  87707. * @param format defines the format of the texture
  87708. * @param generateMipMaps defines if the engine must generate mip levels
  87709. * @param invertY defines if data must be stored with Y axis inverted
  87710. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87711. * @param compression defines the compressed used (can be null)
  87712. * @param textureType defines the compressed used (can be null)
  87713. * @returns a new raw 3D texture (stored in an InternalTexture)
  87714. */
  87715. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  87716. private _prepareWebGLTextureContinuation;
  87717. private _prepareWebGLTexture;
  87718. private _convertRGBtoRGBATextureData;
  87719. /** @hidden */
  87720. _releaseFramebufferObjects(texture: InternalTexture): void;
  87721. /** @hidden */
  87722. _releaseTexture(texture: InternalTexture): void;
  87723. private setProgram;
  87724. private _boundUniforms;
  87725. /**
  87726. * Binds an effect to the webGL context
  87727. * @param effect defines the effect to bind
  87728. */
  87729. bindSamplers(effect: Effect): void;
  87730. private _moveBoundTextureOnTop;
  87731. private _getCorrectTextureChannel;
  87732. private _linkTrackers;
  87733. private _removeDesignatedSlot;
  87734. private _activateCurrentTexture;
  87735. /** @hidden */
  87736. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  87737. /** @hidden */
  87738. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  87739. /**
  87740. * Sets a texture to the webGL context from a postprocess
  87741. * @param channel defines the channel to use
  87742. * @param postProcess defines the source postprocess
  87743. */
  87744. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  87745. /**
  87746. * Binds the output of the passed in post process to the texture channel specified
  87747. * @param channel The channel the texture should be bound to
  87748. * @param postProcess The post process which's output should be bound
  87749. */
  87750. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  87751. /**
  87752. * Unbind all textures from the webGL context
  87753. */
  87754. unbindAllTextures(): void;
  87755. /**
  87756. * Sets a texture to the according uniform.
  87757. * @param channel The texture channel
  87758. * @param uniform The uniform to set
  87759. * @param texture The texture to apply
  87760. */
  87761. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  87762. /**
  87763. * Sets a depth stencil texture from a render target to the according uniform.
  87764. * @param channel The texture channel
  87765. * @param uniform The uniform to set
  87766. * @param texture The render target texture containing the depth stencil texture to apply
  87767. */
  87768. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  87769. private _bindSamplerUniformToChannel;
  87770. private _getTextureWrapMode;
  87771. private _setTexture;
  87772. /**
  87773. * Sets an array of texture to the webGL context
  87774. * @param channel defines the channel where the texture array must be set
  87775. * @param uniform defines the associated uniform location
  87776. * @param textures defines the array of textures to bind
  87777. */
  87778. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  87779. /** @hidden */
  87780. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  87781. private _setTextureParameterFloat;
  87782. private _setTextureParameterInteger;
  87783. /**
  87784. * Reads pixels from the current frame buffer. Please note that this function can be slow
  87785. * @param x defines the x coordinate of the rectangle where pixels must be read
  87786. * @param y defines the y coordinate of the rectangle where pixels must be read
  87787. * @param width defines the width of the rectangle where pixels must be read
  87788. * @param height defines the height of the rectangle where pixels must be read
  87789. * @returns a Uint8Array containing RGBA colors
  87790. */
  87791. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  87792. /**
  87793. * Add an externaly attached data from its key.
  87794. * This method call will fail and return false, if such key already exists.
  87795. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  87796. * @param key the unique key that identifies the data
  87797. * @param data the data object to associate to the key for this Engine instance
  87798. * @return true if no such key were already present and the data was added successfully, false otherwise
  87799. */
  87800. addExternalData<T>(key: string, data: T): boolean;
  87801. /**
  87802. * Get an externaly attached data from its key
  87803. * @param key the unique key that identifies the data
  87804. * @return the associated data, if present (can be null), or undefined if not present
  87805. */
  87806. getExternalData<T>(key: string): T;
  87807. /**
  87808. * Get an externaly attached data from its key, create it using a factory if it's not already present
  87809. * @param key the unique key that identifies the data
  87810. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  87811. * @return the associated data, can be null if the factory returned null.
  87812. */
  87813. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  87814. /**
  87815. * Remove an externaly attached data from the Engine instance
  87816. * @param key the unique key that identifies the data
  87817. * @return true if the data was successfully removed, false if it doesn't exist
  87818. */
  87819. removeExternalData(key: string): boolean;
  87820. /**
  87821. * Unbind all vertex attributes from the webGL context
  87822. */
  87823. unbindAllAttributes(): void;
  87824. /**
  87825. * 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
  87826. */
  87827. releaseEffects(): void;
  87828. /**
  87829. * Dispose and release all associated resources
  87830. */
  87831. dispose(): void;
  87832. /**
  87833. * Display the loading screen
  87834. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87835. */
  87836. displayLoadingUI(): void;
  87837. /**
  87838. * Hide the loading screen
  87839. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87840. */
  87841. hideLoadingUI(): void;
  87842. /**
  87843. * Gets the current loading screen object
  87844. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87845. */
  87846. /**
  87847. * Sets the current loading screen object
  87848. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87849. */
  87850. loadingScreen: ILoadingScreen;
  87851. /**
  87852. * Sets the current loading screen text
  87853. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87854. */
  87855. loadingUIText: string;
  87856. /**
  87857. * Sets the current loading screen background color
  87858. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87859. */
  87860. loadingUIBackgroundColor: string;
  87861. /**
  87862. * Attach a new callback raised when context lost event is fired
  87863. * @param callback defines the callback to call
  87864. */
  87865. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87866. /**
  87867. * Attach a new callback raised when context restored event is fired
  87868. * @param callback defines the callback to call
  87869. */
  87870. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87871. /**
  87872. * Gets the source code of the vertex shader associated with a specific webGL program
  87873. * @param program defines the program to use
  87874. * @returns a string containing the source code of the vertex shader associated with the program
  87875. */
  87876. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  87877. /**
  87878. * Gets the source code of the fragment shader associated with a specific webGL program
  87879. * @param program defines the program to use
  87880. * @returns a string containing the source code of the fragment shader associated with the program
  87881. */
  87882. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  87883. /**
  87884. * Get the current error code of the webGL context
  87885. * @returns the error code
  87886. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  87887. */
  87888. getError(): number;
  87889. /**
  87890. * Gets the current framerate
  87891. * @returns a number representing the framerate
  87892. */
  87893. getFps(): number;
  87894. /**
  87895. * Gets the time spent between current and previous frame
  87896. * @returns a number representing the delta time in ms
  87897. */
  87898. getDeltaTime(): number;
  87899. private _measureFps;
  87900. /** @hidden */
  87901. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  87902. private _canRenderToFloatFramebuffer;
  87903. private _canRenderToHalfFloatFramebuffer;
  87904. private _canRenderToFramebuffer;
  87905. /** @hidden */
  87906. _getWebGLTextureType(type: number): number;
  87907. private _getInternalFormat;
  87908. /** @hidden */
  87909. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  87910. /** @hidden */
  87911. _getRGBAMultiSampleBufferFormat(type: number): number;
  87912. /** @hidden */
  87913. _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;
  87914. /** @hidden */
  87915. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  87916. private _partialLoadFile;
  87917. private _cascadeLoadFiles;
  87918. /**
  87919. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  87920. * @returns true if the engine can be created
  87921. * @ignorenaming
  87922. */
  87923. static isSupported(): boolean;
  87924. }
  87925. }
  87926. declare module BABYLON {
  87927. /**
  87928. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87929. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87930. */
  87931. export class EffectFallbacks {
  87932. private _defines;
  87933. private _currentRank;
  87934. private _maxRank;
  87935. private _mesh;
  87936. /**
  87937. * Removes the fallback from the bound mesh.
  87938. */
  87939. unBindMesh(): void;
  87940. /**
  87941. * Adds a fallback on the specified property.
  87942. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87943. * @param define The name of the define in the shader
  87944. */
  87945. addFallback(rank: number, define: string): void;
  87946. /**
  87947. * Sets the mesh to use CPU skinning when needing to fallback.
  87948. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87949. * @param mesh The mesh to use the fallbacks.
  87950. */
  87951. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87952. /**
  87953. * Checks to see if more fallbacks are still availible.
  87954. */
  87955. readonly isMoreFallbacks: boolean;
  87956. /**
  87957. * Removes the defines that shoould be removed when falling back.
  87958. * @param currentDefines defines the current define statements for the shader.
  87959. * @param effect defines the current effect we try to compile
  87960. * @returns The resulting defines with defines of the current rank removed.
  87961. */
  87962. reduce(currentDefines: string, effect: Effect): string;
  87963. }
  87964. /**
  87965. * Options to be used when creating an effect.
  87966. */
  87967. export class EffectCreationOptions {
  87968. /**
  87969. * Atrributes that will be used in the shader.
  87970. */
  87971. attributes: string[];
  87972. /**
  87973. * Uniform varible names that will be set in the shader.
  87974. */
  87975. uniformsNames: string[];
  87976. /**
  87977. * Uniform buffer varible names that will be set in the shader.
  87978. */
  87979. uniformBuffersNames: string[];
  87980. /**
  87981. * Sampler texture variable names that will be set in the shader.
  87982. */
  87983. samplers: string[];
  87984. /**
  87985. * Define statements that will be set in the shader.
  87986. */
  87987. defines: any;
  87988. /**
  87989. * Possible fallbacks for this effect to improve performance when needed.
  87990. */
  87991. fallbacks: Nullable<EffectFallbacks>;
  87992. /**
  87993. * Callback that will be called when the shader is compiled.
  87994. */
  87995. onCompiled: Nullable<(effect: Effect) => void>;
  87996. /**
  87997. * Callback that will be called if an error occurs during shader compilation.
  87998. */
  87999. onError: Nullable<(effect: Effect, errors: string) => void>;
  88000. /**
  88001. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88002. */
  88003. indexParameters: any;
  88004. /**
  88005. * Max number of lights that can be used in the shader.
  88006. */
  88007. maxSimultaneousLights: number;
  88008. /**
  88009. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88010. */
  88011. transformFeedbackVaryings: Nullable<string[]>;
  88012. }
  88013. /**
  88014. * Effect containing vertex and fragment shader that can be executed on an object.
  88015. */
  88016. export class Effect {
  88017. /**
  88018. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88019. */
  88020. static ShadersRepository: string;
  88021. /**
  88022. * Name of the effect.
  88023. */
  88024. name: any;
  88025. /**
  88026. * String container all the define statements that should be set on the shader.
  88027. */
  88028. defines: string;
  88029. /**
  88030. * Callback that will be called when the shader is compiled.
  88031. */
  88032. onCompiled: Nullable<(effect: Effect) => void>;
  88033. /**
  88034. * Callback that will be called if an error occurs during shader compilation.
  88035. */
  88036. onError: Nullable<(effect: Effect, errors: string) => void>;
  88037. /**
  88038. * Callback that will be called when effect is bound.
  88039. */
  88040. onBind: Nullable<(effect: Effect) => void>;
  88041. /**
  88042. * Unique ID of the effect.
  88043. */
  88044. uniqueId: number;
  88045. /**
  88046. * Observable that will be called when the shader is compiled.
  88047. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88048. */
  88049. onCompileObservable: Observable<Effect>;
  88050. /**
  88051. * Observable that will be called if an error occurs during shader compilation.
  88052. */
  88053. onErrorObservable: Observable<Effect>;
  88054. /** @hidden */
  88055. _onBindObservable: Nullable<Observable<Effect>>;
  88056. /**
  88057. * Observable that will be called when effect is bound.
  88058. */
  88059. readonly onBindObservable: Observable<Effect>;
  88060. /** @hidden */
  88061. _bonesComputationForcedToCPU: boolean;
  88062. private static _uniqueIdSeed;
  88063. private _engine;
  88064. private _uniformBuffersNames;
  88065. private _uniformsNames;
  88066. private _samplers;
  88067. private _isReady;
  88068. private _compilationError;
  88069. private _attributesNames;
  88070. private _attributes;
  88071. private _uniforms;
  88072. /**
  88073. * Key for the effect.
  88074. * @hidden
  88075. */
  88076. _key: string;
  88077. private _indexParameters;
  88078. private _fallbacks;
  88079. private _vertexSourceCode;
  88080. private _fragmentSourceCode;
  88081. private _vertexSourceCodeOverride;
  88082. private _fragmentSourceCodeOverride;
  88083. private _transformFeedbackVaryings;
  88084. /**
  88085. * Compiled shader to webGL program.
  88086. * @hidden
  88087. */
  88088. _program: WebGLProgram;
  88089. private _valueCache;
  88090. private static _baseCache;
  88091. /**
  88092. * Instantiates an effect.
  88093. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88094. * @param baseName Name of the effect.
  88095. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88096. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88097. * @param samplers List of sampler variables that will be passed to the shader.
  88098. * @param engine Engine to be used to render the effect
  88099. * @param defines Define statements to be added to the shader.
  88100. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  88101. * @param onCompiled Callback that will be called when the shader is compiled.
  88102. * @param onError Callback that will be called if an error occurs during shader compilation.
  88103. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88104. */
  88105. 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);
  88106. /**
  88107. * Unique key for this effect
  88108. */
  88109. readonly key: string;
  88110. /**
  88111. * If the effect has been compiled and prepared.
  88112. * @returns if the effect is compiled and prepared.
  88113. */
  88114. isReady(): boolean;
  88115. /**
  88116. * The engine the effect was initialized with.
  88117. * @returns the engine.
  88118. */
  88119. getEngine(): Engine;
  88120. /**
  88121. * The compiled webGL program for the effect
  88122. * @returns the webGL program.
  88123. */
  88124. getProgram(): WebGLProgram;
  88125. /**
  88126. * The set of names of attribute variables for the shader.
  88127. * @returns An array of attribute names.
  88128. */
  88129. getAttributesNames(): string[];
  88130. /**
  88131. * Returns the attribute at the given index.
  88132. * @param index The index of the attribute.
  88133. * @returns The location of the attribute.
  88134. */
  88135. getAttributeLocation(index: number): number;
  88136. /**
  88137. * Returns the attribute based on the name of the variable.
  88138. * @param name of the attribute to look up.
  88139. * @returns the attribute location.
  88140. */
  88141. getAttributeLocationByName(name: string): number;
  88142. /**
  88143. * The number of attributes.
  88144. * @returns the numnber of attributes.
  88145. */
  88146. getAttributesCount(): number;
  88147. /**
  88148. * Gets the index of a uniform variable.
  88149. * @param uniformName of the uniform to look up.
  88150. * @returns the index.
  88151. */
  88152. getUniformIndex(uniformName: string): number;
  88153. /**
  88154. * Returns the attribute based on the name of the variable.
  88155. * @param uniformName of the uniform to look up.
  88156. * @returns the location of the uniform.
  88157. */
  88158. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  88159. /**
  88160. * Returns an array of sampler variable names
  88161. * @returns The array of sampler variable neames.
  88162. */
  88163. getSamplers(): string[];
  88164. /**
  88165. * The error from the last compilation.
  88166. * @returns the error string.
  88167. */
  88168. getCompilationError(): string;
  88169. /**
  88170. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  88171. * @param func The callback to be used.
  88172. */
  88173. executeWhenCompiled(func: (effect: Effect) => void): void;
  88174. private _checkIsReady;
  88175. /** @hidden */
  88176. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  88177. /** @hidden */
  88178. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  88179. /** @hidden */
  88180. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  88181. private _processShaderConversion;
  88182. private _processIncludes;
  88183. private _processPrecision;
  88184. /**
  88185. * Recompiles the webGL program
  88186. * @param vertexSourceCode The source code for the vertex shader.
  88187. * @param fragmentSourceCode The source code for the fragment shader.
  88188. * @param onCompiled Callback called when completed.
  88189. * @param onError Callback called on error.
  88190. * @hidden
  88191. */
  88192. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  88193. /**
  88194. * Gets the uniform locations of the the specified variable names
  88195. * @param names THe names of the variables to lookup.
  88196. * @returns Array of locations in the same order as variable names.
  88197. */
  88198. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  88199. /**
  88200. * Prepares the effect
  88201. * @hidden
  88202. */
  88203. _prepareEffect(): void;
  88204. /**
  88205. * Checks if the effect is supported. (Must be called after compilation)
  88206. */
  88207. readonly isSupported: boolean;
  88208. /**
  88209. * Binds a texture to the engine to be used as output of the shader.
  88210. * @param channel Name of the output variable.
  88211. * @param texture Texture to bind.
  88212. * @hidden
  88213. */
  88214. _bindTexture(channel: string, texture: InternalTexture): void;
  88215. /**
  88216. * Sets a texture on the engine to be used in the shader.
  88217. * @param channel Name of the sampler variable.
  88218. * @param texture Texture to set.
  88219. */
  88220. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  88221. /**
  88222. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  88223. * @param channel Name of the sampler variable.
  88224. * @param texture Texture to set.
  88225. */
  88226. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  88227. /**
  88228. * Sets an array of textures on the engine to be used in the shader.
  88229. * @param channel Name of the variable.
  88230. * @param textures Textures to set.
  88231. */
  88232. setTextureArray(channel: string, textures: BaseTexture[]): void;
  88233. /**
  88234. * 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)
  88235. * @param channel Name of the sampler variable.
  88236. * @param postProcess Post process to get the input texture from.
  88237. */
  88238. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  88239. /**
  88240. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  88241. * 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)
  88242. * @param channel Name of the sampler variable.
  88243. * @param postProcess Post process to get the output texture from.
  88244. */
  88245. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  88246. /** @hidden */
  88247. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  88248. /** @hidden */
  88249. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  88250. /** @hidden */
  88251. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  88252. /** @hidden */
  88253. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  88254. /**
  88255. * Binds a buffer to a uniform.
  88256. * @param buffer Buffer to bind.
  88257. * @param name Name of the uniform variable to bind to.
  88258. */
  88259. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  88260. /**
  88261. * Binds block to a uniform.
  88262. * @param blockName Name of the block to bind.
  88263. * @param index Index to bind.
  88264. */
  88265. bindUniformBlock(blockName: string, index: number): void;
  88266. /**
  88267. * Sets an interger value on a uniform variable.
  88268. * @param uniformName Name of the variable.
  88269. * @param value Value to be set.
  88270. * @returns this effect.
  88271. */
  88272. setInt(uniformName: string, value: number): Effect;
  88273. /**
  88274. * Sets an int array on a uniform variable.
  88275. * @param uniformName Name of the variable.
  88276. * @param array array to be set.
  88277. * @returns this effect.
  88278. */
  88279. setIntArray(uniformName: string, array: Int32Array): Effect;
  88280. /**
  88281. * 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)
  88282. * @param uniformName Name of the variable.
  88283. * @param array array to be set.
  88284. * @returns this effect.
  88285. */
  88286. setIntArray2(uniformName: string, array: Int32Array): Effect;
  88287. /**
  88288. * 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)
  88289. * @param uniformName Name of the variable.
  88290. * @param array array to be set.
  88291. * @returns this effect.
  88292. */
  88293. setIntArray3(uniformName: string, array: Int32Array): Effect;
  88294. /**
  88295. * 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)
  88296. * @param uniformName Name of the variable.
  88297. * @param array array to be set.
  88298. * @returns this effect.
  88299. */
  88300. setIntArray4(uniformName: string, array: Int32Array): Effect;
  88301. /**
  88302. * Sets an float array on a uniform variable.
  88303. * @param uniformName Name of the variable.
  88304. * @param array array to be set.
  88305. * @returns this effect.
  88306. */
  88307. setFloatArray(uniformName: string, array: Float32Array): Effect;
  88308. /**
  88309. * 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)
  88310. * @param uniformName Name of the variable.
  88311. * @param array array to be set.
  88312. * @returns this effect.
  88313. */
  88314. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  88315. /**
  88316. * 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)
  88317. * @param uniformName Name of the variable.
  88318. * @param array array to be set.
  88319. * @returns this effect.
  88320. */
  88321. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  88322. /**
  88323. * 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)
  88324. * @param uniformName Name of the variable.
  88325. * @param array array to be set.
  88326. * @returns this effect.
  88327. */
  88328. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  88329. /**
  88330. * Sets an array on a uniform variable.
  88331. * @param uniformName Name of the variable.
  88332. * @param array array to be set.
  88333. * @returns this effect.
  88334. */
  88335. setArray(uniformName: string, array: number[]): Effect;
  88336. /**
  88337. * 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)
  88338. * @param uniformName Name of the variable.
  88339. * @param array array to be set.
  88340. * @returns this effect.
  88341. */
  88342. setArray2(uniformName: string, array: number[]): Effect;
  88343. /**
  88344. * 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)
  88345. * @param uniformName Name of the variable.
  88346. * @param array array to be set.
  88347. * @returns this effect.
  88348. */
  88349. setArray3(uniformName: string, array: number[]): Effect;
  88350. /**
  88351. * 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)
  88352. * @param uniformName Name of the variable.
  88353. * @param array array to be set.
  88354. * @returns this effect.
  88355. */
  88356. setArray4(uniformName: string, array: number[]): Effect;
  88357. /**
  88358. * Sets matrices on a uniform variable.
  88359. * @param uniformName Name of the variable.
  88360. * @param matrices matrices to be set.
  88361. * @returns this effect.
  88362. */
  88363. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  88364. /**
  88365. * Sets matrix on a uniform variable.
  88366. * @param uniformName Name of the variable.
  88367. * @param matrix matrix to be set.
  88368. * @returns this effect.
  88369. */
  88370. setMatrix(uniformName: string, matrix: Matrix): Effect;
  88371. /**
  88372. * 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)
  88373. * @param uniformName Name of the variable.
  88374. * @param matrix matrix to be set.
  88375. * @returns this effect.
  88376. */
  88377. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  88378. /**
  88379. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  88380. * @param uniformName Name of the variable.
  88381. * @param matrix matrix to be set.
  88382. * @returns this effect.
  88383. */
  88384. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  88385. /**
  88386. * Sets a float on a uniform variable.
  88387. * @param uniformName Name of the variable.
  88388. * @param value value to be set.
  88389. * @returns this effect.
  88390. */
  88391. setFloat(uniformName: string, value: number): Effect;
  88392. /**
  88393. * Sets a boolean on a uniform variable.
  88394. * @param uniformName Name of the variable.
  88395. * @param bool value to be set.
  88396. * @returns this effect.
  88397. */
  88398. setBool(uniformName: string, bool: boolean): Effect;
  88399. /**
  88400. * Sets a Vector2 on a uniform variable.
  88401. * @param uniformName Name of the variable.
  88402. * @param vector2 vector2 to be set.
  88403. * @returns this effect.
  88404. */
  88405. setVector2(uniformName: string, vector2: Vector2): Effect;
  88406. /**
  88407. * Sets a float2 on a uniform variable.
  88408. * @param uniformName Name of the variable.
  88409. * @param x First float in float2.
  88410. * @param y Second float in float2.
  88411. * @returns this effect.
  88412. */
  88413. setFloat2(uniformName: string, x: number, y: number): Effect;
  88414. /**
  88415. * Sets a Vector3 on a uniform variable.
  88416. * @param uniformName Name of the variable.
  88417. * @param vector3 Value to be set.
  88418. * @returns this effect.
  88419. */
  88420. setVector3(uniformName: string, vector3: Vector3): Effect;
  88421. /**
  88422. * Sets a float3 on a uniform variable.
  88423. * @param uniformName Name of the variable.
  88424. * @param x First float in float3.
  88425. * @param y Second float in float3.
  88426. * @param z Third float in float3.
  88427. * @returns this effect.
  88428. */
  88429. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88430. /**
  88431. * Sets a Vector4 on a uniform variable.
  88432. * @param uniformName Name of the variable.
  88433. * @param vector4 Value to be set.
  88434. * @returns this effect.
  88435. */
  88436. setVector4(uniformName: string, vector4: Vector4): Effect;
  88437. /**
  88438. * Sets a float4 on a uniform variable.
  88439. * @param uniformName Name of the variable.
  88440. * @param x First float in float4.
  88441. * @param y Second float in float4.
  88442. * @param z Third float in float4.
  88443. * @param w Fourth float in float4.
  88444. * @returns this effect.
  88445. */
  88446. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  88447. /**
  88448. * Sets a Color3 on a uniform variable.
  88449. * @param uniformName Name of the variable.
  88450. * @param color3 Value to be set.
  88451. * @returns this effect.
  88452. */
  88453. setColor3(uniformName: string, color3: Color3): Effect;
  88454. /**
  88455. * Sets a Color4 on a uniform variable.
  88456. * @param uniformName Name of the variable.
  88457. * @param color3 Value to be set.
  88458. * @param alpha Alpha value to be set.
  88459. * @returns this effect.
  88460. */
  88461. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  88462. /**
  88463. * Sets a Color4 on a uniform variable
  88464. * @param uniformName defines the name of the variable
  88465. * @param color4 defines the value to be set
  88466. * @returns this effect.
  88467. */
  88468. setDirectColor4(uniformName: string, color4: Color4): Effect;
  88469. /**
  88470. * This function will add a new shader to the shader store
  88471. * @param name the name of the shader
  88472. * @param pixelShader optional pixel shader content
  88473. * @param vertexShader optional vertex shader content
  88474. */
  88475. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  88476. /**
  88477. * Store of each shader (The can be looked up using effect.key)
  88478. */
  88479. static ShadersStore: {
  88480. [key: string]: string;
  88481. };
  88482. /**
  88483. * Store of each included file for a shader (The can be looked up using effect.key)
  88484. */
  88485. static IncludesShadersStore: {
  88486. [key: string]: string;
  88487. };
  88488. /**
  88489. * Resets the cache of effects.
  88490. */
  88491. static ResetCache(): void;
  88492. }
  88493. }
  88494. declare module BABYLON {
  88495. /**
  88496. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88497. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88498. * 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;
  88499. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88500. */
  88501. export class ColorCurves {
  88502. private _dirty;
  88503. private _tempColor;
  88504. private _globalCurve;
  88505. private _highlightsCurve;
  88506. private _midtonesCurve;
  88507. private _shadowsCurve;
  88508. private _positiveCurve;
  88509. private _negativeCurve;
  88510. private _globalHue;
  88511. private _globalDensity;
  88512. private _globalSaturation;
  88513. private _globalExposure;
  88514. /**
  88515. * Gets the global Hue value.
  88516. * 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).
  88517. */
  88518. /**
  88519. * Sets the global Hue value.
  88520. * 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).
  88521. */
  88522. globalHue: number;
  88523. /**
  88524. * Gets the global Density value.
  88525. * 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.
  88526. * Values less than zero provide a filter of opposite hue.
  88527. */
  88528. /**
  88529. * Sets the global Density value.
  88530. * 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.
  88531. * Values less than zero provide a filter of opposite hue.
  88532. */
  88533. globalDensity: number;
  88534. /**
  88535. * Gets the global Saturation value.
  88536. * 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.
  88537. */
  88538. /**
  88539. * Sets the global Saturation value.
  88540. * 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.
  88541. */
  88542. globalSaturation: number;
  88543. /**
  88544. * Gets the global Exposure value.
  88545. * 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.
  88546. */
  88547. /**
  88548. * Sets the global Exposure value.
  88549. * 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.
  88550. */
  88551. globalExposure: number;
  88552. private _highlightsHue;
  88553. private _highlightsDensity;
  88554. private _highlightsSaturation;
  88555. private _highlightsExposure;
  88556. /**
  88557. * Gets the highlights Hue value.
  88558. * 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).
  88559. */
  88560. /**
  88561. * Sets the highlights Hue value.
  88562. * 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).
  88563. */
  88564. highlightsHue: number;
  88565. /**
  88566. * Gets the highlights Density value.
  88567. * 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.
  88568. * Values less than zero provide a filter of opposite hue.
  88569. */
  88570. /**
  88571. * Sets the highlights Density value.
  88572. * 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.
  88573. * Values less than zero provide a filter of opposite hue.
  88574. */
  88575. highlightsDensity: number;
  88576. /**
  88577. * Gets the highlights Saturation value.
  88578. * 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.
  88579. */
  88580. /**
  88581. * Sets the highlights Saturation value.
  88582. * 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.
  88583. */
  88584. highlightsSaturation: number;
  88585. /**
  88586. * Gets the highlights Exposure value.
  88587. * 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.
  88588. */
  88589. /**
  88590. * Sets the highlights Exposure value.
  88591. * 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.
  88592. */
  88593. highlightsExposure: number;
  88594. private _midtonesHue;
  88595. private _midtonesDensity;
  88596. private _midtonesSaturation;
  88597. private _midtonesExposure;
  88598. /**
  88599. * Gets the midtones Hue value.
  88600. * 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).
  88601. */
  88602. /**
  88603. * Sets the midtones Hue value.
  88604. * 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).
  88605. */
  88606. midtonesHue: number;
  88607. /**
  88608. * Gets the midtones Density value.
  88609. * 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.
  88610. * Values less than zero provide a filter of opposite hue.
  88611. */
  88612. /**
  88613. * Sets the midtones Density value.
  88614. * 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.
  88615. * Values less than zero provide a filter of opposite hue.
  88616. */
  88617. midtonesDensity: number;
  88618. /**
  88619. * Gets the midtones Saturation value.
  88620. * 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.
  88621. */
  88622. /**
  88623. * Sets the midtones Saturation value.
  88624. * 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.
  88625. */
  88626. midtonesSaturation: number;
  88627. /**
  88628. * Gets the midtones Exposure value.
  88629. * 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.
  88630. */
  88631. /**
  88632. * Sets the midtones Exposure value.
  88633. * 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.
  88634. */
  88635. midtonesExposure: number;
  88636. private _shadowsHue;
  88637. private _shadowsDensity;
  88638. private _shadowsSaturation;
  88639. private _shadowsExposure;
  88640. /**
  88641. * Gets the shadows Hue value.
  88642. * 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).
  88643. */
  88644. /**
  88645. * Sets the shadows Hue value.
  88646. * 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).
  88647. */
  88648. shadowsHue: number;
  88649. /**
  88650. * Gets the shadows Density value.
  88651. * 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.
  88652. * Values less than zero provide a filter of opposite hue.
  88653. */
  88654. /**
  88655. * Sets the shadows Density value.
  88656. * 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.
  88657. * Values less than zero provide a filter of opposite hue.
  88658. */
  88659. shadowsDensity: number;
  88660. /**
  88661. * Gets the shadows Saturation value.
  88662. * 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.
  88663. */
  88664. /**
  88665. * Sets the shadows Saturation value.
  88666. * 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.
  88667. */
  88668. shadowsSaturation: number;
  88669. /**
  88670. * Gets the shadows Exposure value.
  88671. * 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.
  88672. */
  88673. /**
  88674. * Sets the shadows Exposure value.
  88675. * 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.
  88676. */
  88677. shadowsExposure: number;
  88678. /**
  88679. * Returns the class name
  88680. * @returns The class name
  88681. */
  88682. getClassName(): string;
  88683. /**
  88684. * Binds the color curves to the shader.
  88685. * @param colorCurves The color curve to bind
  88686. * @param effect The effect to bind to
  88687. * @param positiveUniform The positive uniform shader parameter
  88688. * @param neutralUniform The neutral uniform shader parameter
  88689. * @param negativeUniform The negative uniform shader parameter
  88690. */
  88691. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88692. /**
  88693. * Prepare the list of uniforms associated with the ColorCurves effects.
  88694. * @param uniformsList The list of uniforms used in the effect
  88695. */
  88696. static PrepareUniforms(uniformsList: string[]): void;
  88697. /**
  88698. * Returns color grading data based on a hue, density, saturation and exposure value.
  88699. * @param filterHue The hue of the color filter.
  88700. * @param filterDensity The density of the color filter.
  88701. * @param saturation The saturation.
  88702. * @param exposure The exposure.
  88703. * @param result The result data container.
  88704. */
  88705. private getColorGradingDataToRef;
  88706. /**
  88707. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88708. * @param value The input slider value in range [-100,100].
  88709. * @returns Adjusted value.
  88710. */
  88711. private static applyColorGradingSliderNonlinear;
  88712. /**
  88713. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88714. * @param hue The hue (H) input.
  88715. * @param saturation The saturation (S) input.
  88716. * @param brightness The brightness (B) input.
  88717. * @result An RGBA color represented as Vector4.
  88718. */
  88719. private static fromHSBToRef;
  88720. /**
  88721. * Returns a value clamped between min and max
  88722. * @param value The value to clamp
  88723. * @param min The minimum of value
  88724. * @param max The maximum of value
  88725. * @returns The clamped value.
  88726. */
  88727. private static clamp;
  88728. /**
  88729. * Clones the current color curve instance.
  88730. * @return The cloned curves
  88731. */
  88732. clone(): ColorCurves;
  88733. /**
  88734. * Serializes the current color curve instance to a json representation.
  88735. * @return a JSON representation
  88736. */
  88737. serialize(): any;
  88738. /**
  88739. * Parses the color curve from a json representation.
  88740. * @param source the JSON source to parse
  88741. * @return The parsed curves
  88742. */
  88743. static Parse(source: any): ColorCurves;
  88744. }
  88745. }
  88746. declare module BABYLON {
  88747. /**
  88748. * Interface to follow in your material defines to integrate easily the
  88749. * Image proccessing functions.
  88750. * @hidden
  88751. */
  88752. export interface IImageProcessingConfigurationDefines {
  88753. IMAGEPROCESSING: boolean;
  88754. VIGNETTE: boolean;
  88755. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88756. VIGNETTEBLENDMODEOPAQUE: boolean;
  88757. TONEMAPPING: boolean;
  88758. TONEMAPPING_ACES: boolean;
  88759. CONTRAST: boolean;
  88760. EXPOSURE: boolean;
  88761. COLORCURVES: boolean;
  88762. COLORGRADING: boolean;
  88763. COLORGRADING3D: boolean;
  88764. SAMPLER3DGREENDEPTH: boolean;
  88765. SAMPLER3DBGRMAP: boolean;
  88766. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88767. }
  88768. /**
  88769. * @hidden
  88770. */
  88771. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88772. IMAGEPROCESSING: boolean;
  88773. VIGNETTE: boolean;
  88774. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88775. VIGNETTEBLENDMODEOPAQUE: boolean;
  88776. TONEMAPPING: boolean;
  88777. TONEMAPPING_ACES: boolean;
  88778. CONTRAST: boolean;
  88779. COLORCURVES: boolean;
  88780. COLORGRADING: boolean;
  88781. COLORGRADING3D: boolean;
  88782. SAMPLER3DGREENDEPTH: boolean;
  88783. SAMPLER3DBGRMAP: boolean;
  88784. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88785. EXPOSURE: boolean;
  88786. constructor();
  88787. }
  88788. /**
  88789. * This groups together the common properties used for image processing either in direct forward pass
  88790. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88791. * or not.
  88792. */
  88793. export class ImageProcessingConfiguration {
  88794. /**
  88795. * Default tone mapping applied in BabylonJS.
  88796. */
  88797. static readonly TONEMAPPING_STANDARD: number;
  88798. /**
  88799. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88800. * to other engines rendering to increase portability.
  88801. */
  88802. static readonly TONEMAPPING_ACES: number;
  88803. /**
  88804. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88805. */
  88806. colorCurves: Nullable<ColorCurves>;
  88807. private _colorCurvesEnabled;
  88808. /**
  88809. * Gets wether the color curves effect is enabled.
  88810. */
  88811. /**
  88812. * Sets wether the color curves effect is enabled.
  88813. */
  88814. colorCurvesEnabled: boolean;
  88815. private _colorGradingTexture;
  88816. /**
  88817. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88818. */
  88819. /**
  88820. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88821. */
  88822. colorGradingTexture: Nullable<BaseTexture>;
  88823. private _colorGradingEnabled;
  88824. /**
  88825. * Gets wether the color grading effect is enabled.
  88826. */
  88827. /**
  88828. * Sets wether the color grading effect is enabled.
  88829. */
  88830. colorGradingEnabled: boolean;
  88831. private _colorGradingWithGreenDepth;
  88832. /**
  88833. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88834. */
  88835. /**
  88836. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88837. */
  88838. colorGradingWithGreenDepth: boolean;
  88839. private _colorGradingBGR;
  88840. /**
  88841. * Gets wether the color grading texture contains BGR values.
  88842. */
  88843. /**
  88844. * Sets wether the color grading texture contains BGR values.
  88845. */
  88846. colorGradingBGR: boolean;
  88847. /** @hidden */
  88848. _exposure: number;
  88849. /**
  88850. * Gets the Exposure used in the effect.
  88851. */
  88852. /**
  88853. * Sets the Exposure used in the effect.
  88854. */
  88855. exposure: number;
  88856. private _toneMappingEnabled;
  88857. /**
  88858. * Gets wether the tone mapping effect is enabled.
  88859. */
  88860. /**
  88861. * Sets wether the tone mapping effect is enabled.
  88862. */
  88863. toneMappingEnabled: boolean;
  88864. private _toneMappingType;
  88865. /**
  88866. * Gets the type of tone mapping effect.
  88867. */
  88868. /**
  88869. * Sets the type of tone mapping effect used in BabylonJS.
  88870. */
  88871. toneMappingType: number;
  88872. protected _contrast: number;
  88873. /**
  88874. * Gets the contrast used in the effect.
  88875. */
  88876. /**
  88877. * Sets the contrast used in the effect.
  88878. */
  88879. contrast: number;
  88880. /**
  88881. * Vignette stretch size.
  88882. */
  88883. vignetteStretch: number;
  88884. /**
  88885. * Vignette centre X Offset.
  88886. */
  88887. vignetteCentreX: number;
  88888. /**
  88889. * Vignette centre Y Offset.
  88890. */
  88891. vignetteCentreY: number;
  88892. /**
  88893. * Vignette weight or intensity of the vignette effect.
  88894. */
  88895. vignetteWeight: number;
  88896. /**
  88897. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88898. * if vignetteEnabled is set to true.
  88899. */
  88900. vignetteColor: Color4;
  88901. /**
  88902. * Camera field of view used by the Vignette effect.
  88903. */
  88904. vignetteCameraFov: number;
  88905. private _vignetteBlendMode;
  88906. /**
  88907. * Gets the vignette blend mode allowing different kind of effect.
  88908. */
  88909. /**
  88910. * Sets the vignette blend mode allowing different kind of effect.
  88911. */
  88912. vignetteBlendMode: number;
  88913. private _vignetteEnabled;
  88914. /**
  88915. * Gets wether the vignette effect is enabled.
  88916. */
  88917. /**
  88918. * Sets wether the vignette effect is enabled.
  88919. */
  88920. vignetteEnabled: boolean;
  88921. private _applyByPostProcess;
  88922. /**
  88923. * Gets wether the image processing is applied through a post process or not.
  88924. */
  88925. /**
  88926. * Sets wether the image processing is applied through a post process or not.
  88927. */
  88928. applyByPostProcess: boolean;
  88929. private _isEnabled;
  88930. /**
  88931. * Gets wether the image processing is enabled or not.
  88932. */
  88933. /**
  88934. * Sets wether the image processing is enabled or not.
  88935. */
  88936. isEnabled: boolean;
  88937. /**
  88938. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88939. */
  88940. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88941. /**
  88942. * Method called each time the image processing information changes requires to recompile the effect.
  88943. */
  88944. protected _updateParameters(): void;
  88945. /**
  88946. * Gets the current class name.
  88947. * @return "ImageProcessingConfiguration"
  88948. */
  88949. getClassName(): string;
  88950. /**
  88951. * Prepare the list of uniforms associated with the Image Processing effects.
  88952. * @param uniforms The list of uniforms used in the effect
  88953. * @param defines the list of defines currently in use
  88954. */
  88955. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88956. /**
  88957. * Prepare the list of samplers associated with the Image Processing effects.
  88958. * @param samplersList The list of uniforms used in the effect
  88959. * @param defines the list of defines currently in use
  88960. */
  88961. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88962. /**
  88963. * Prepare the list of defines associated to the shader.
  88964. * @param defines the list of defines to complete
  88965. * @param forPostProcess Define if we are currently in post process mode or not
  88966. */
  88967. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88968. /**
  88969. * Returns true if all the image processing information are ready.
  88970. * @returns True if ready, otherwise, false
  88971. */
  88972. isReady(): boolean;
  88973. /**
  88974. * Binds the image processing to the shader.
  88975. * @param effect The effect to bind to
  88976. * @param aspectRatio Define the current aspect ratio of the effect
  88977. */
  88978. bind(effect: Effect, aspectRatio?: number): void;
  88979. /**
  88980. * Clones the current image processing instance.
  88981. * @return The cloned image processing
  88982. */
  88983. clone(): ImageProcessingConfiguration;
  88984. /**
  88985. * Serializes the current image processing instance to a json representation.
  88986. * @return a JSON representation
  88987. */
  88988. serialize(): any;
  88989. /**
  88990. * Parses the image processing from a json representation.
  88991. * @param source the JSON source to parse
  88992. * @return The parsed image processing
  88993. */
  88994. static Parse(source: any): ImageProcessingConfiguration;
  88995. private static _VIGNETTEMODE_MULTIPLY;
  88996. private static _VIGNETTEMODE_OPAQUE;
  88997. /**
  88998. * Used to apply the vignette as a mix with the pixel color.
  88999. */
  89000. static readonly VIGNETTEMODE_MULTIPLY: number;
  89001. /**
  89002. * Used to apply the vignette as a replacement of the pixel color.
  89003. */
  89004. static readonly VIGNETTEMODE_OPAQUE: number;
  89005. }
  89006. }
  89007. declare module BABYLON {
  89008. /**
  89009. * This represents all the required information to add a fresnel effect on a material:
  89010. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89011. */
  89012. export class FresnelParameters {
  89013. private _isEnabled;
  89014. /**
  89015. * Define if the fresnel effect is enable or not.
  89016. */
  89017. isEnabled: boolean;
  89018. /**
  89019. * Define the color used on edges (grazing angle)
  89020. */
  89021. leftColor: Color3;
  89022. /**
  89023. * Define the color used on center
  89024. */
  89025. rightColor: Color3;
  89026. /**
  89027. * Define bias applied to computed fresnel term
  89028. */
  89029. bias: number;
  89030. /**
  89031. * Defined the power exponent applied to fresnel term
  89032. */
  89033. power: number;
  89034. /**
  89035. * Clones the current fresnel and its valuues
  89036. * @returns a clone fresnel configuration
  89037. */
  89038. clone(): FresnelParameters;
  89039. /**
  89040. * Serializes the current fresnel parameters to a JSON representation.
  89041. * @return the JSON serialization
  89042. */
  89043. serialize(): any;
  89044. /**
  89045. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89046. * @param parsedFresnelParameters Define the JSON representation
  89047. * @returns the parsed parameters
  89048. */
  89049. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89050. }
  89051. }
  89052. declare module BABYLON {
  89053. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89054. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89055. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89056. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89057. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89058. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89059. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89060. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89061. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89062. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89063. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89064. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89065. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89066. /**
  89067. * Decorator used to define property that can be serialized as reference to a camera
  89068. * @param sourceName defines the name of the property to decorate
  89069. */
  89070. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89071. /**
  89072. * Class used to help serialization objects
  89073. */
  89074. export class SerializationHelper {
  89075. /** hidden */
  89076. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89077. /** hidden */
  89078. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89079. /** hidden */
  89080. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89081. /** hidden */
  89082. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89083. /**
  89084. * Appends the serialized animations from the source animations
  89085. * @param source Source containing the animations
  89086. * @param destination Target to store the animations
  89087. */
  89088. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89089. /**
  89090. * Static function used to serialized a specific entity
  89091. * @param entity defines the entity to serialize
  89092. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89093. * @returns a JSON compatible object representing the serialization of the entity
  89094. */
  89095. static Serialize<T>(entity: T, serializationObject?: any): any;
  89096. /**
  89097. * Creates a new entity from a serialization data object
  89098. * @param creationFunction defines a function used to instanciated the new entity
  89099. * @param source defines the source serialization data
  89100. * @param scene defines the hosting scene
  89101. * @param rootUrl defines the root url for resources
  89102. * @returns a new entity
  89103. */
  89104. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  89105. /**
  89106. * Clones an object
  89107. * @param creationFunction defines the function used to instanciate the new object
  89108. * @param source defines the source object
  89109. * @returns the cloned object
  89110. */
  89111. static Clone<T>(creationFunction: () => T, source: T): T;
  89112. /**
  89113. * Instanciates a new object based on a source one (some data will be shared between both object)
  89114. * @param creationFunction defines the function used to instanciate the new object
  89115. * @param source defines the source object
  89116. * @returns the new object
  89117. */
  89118. static Instanciate<T>(creationFunction: () => T, source: T): T;
  89119. }
  89120. }
  89121. declare module BABYLON {
  89122. /**
  89123. * This is the base class of all the camera used in the application.
  89124. * @see http://doc.babylonjs.com/features/cameras
  89125. */
  89126. export class Camera extends Node {
  89127. /** @hidden */
  89128. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89129. /**
  89130. * This is the default projection mode used by the cameras.
  89131. * It helps recreating a feeling of perspective and better appreciate depth.
  89132. * This is the best way to simulate real life cameras.
  89133. */
  89134. static readonly PERSPECTIVE_CAMERA: number;
  89135. /**
  89136. * This helps creating camera with an orthographic mode.
  89137. * 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.
  89138. */
  89139. static readonly ORTHOGRAPHIC_CAMERA: number;
  89140. /**
  89141. * This is the default FOV mode for perspective cameras.
  89142. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89143. */
  89144. static readonly FOVMODE_VERTICAL_FIXED: number;
  89145. /**
  89146. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89147. */
  89148. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89149. /**
  89150. * This specifies ther is no need for a camera rig.
  89151. * Basically only one eye is rendered corresponding to the camera.
  89152. */
  89153. static readonly RIG_MODE_NONE: number;
  89154. /**
  89155. * Simulates a camera Rig with one blue eye and one red eye.
  89156. * This can be use with 3d blue and red glasses.
  89157. */
  89158. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89159. /**
  89160. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89161. */
  89162. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89163. /**
  89164. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89165. */
  89166. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89167. /**
  89168. * Defines that both eyes of the camera will be rendered over under each other.
  89169. */
  89170. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89171. /**
  89172. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89173. */
  89174. static readonly RIG_MODE_VR: number;
  89175. /**
  89176. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89177. */
  89178. static readonly RIG_MODE_WEBVR: number;
  89179. /**
  89180. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89181. */
  89182. static readonly RIG_MODE_CUSTOM: number;
  89183. /**
  89184. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89185. */
  89186. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89187. /**
  89188. * Define the input manager associated with the camera.
  89189. */
  89190. inputs: CameraInputsManager<Camera>;
  89191. /** @hidden */
  89192. _position: Vector3;
  89193. /**
  89194. * Define the current local position of the camera in the scene
  89195. */
  89196. position: Vector3;
  89197. /**
  89198. * The vector the camera should consider as up.
  89199. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89200. */
  89201. upVector: Vector3;
  89202. /**
  89203. * Define the current limit on the left side for an orthographic camera
  89204. * In scene unit
  89205. */
  89206. orthoLeft: Nullable<number>;
  89207. /**
  89208. * Define the current limit on the right side for an orthographic camera
  89209. * In scene unit
  89210. */
  89211. orthoRight: Nullable<number>;
  89212. /**
  89213. * Define the current limit on the bottom side for an orthographic camera
  89214. * In scene unit
  89215. */
  89216. orthoBottom: Nullable<number>;
  89217. /**
  89218. * Define the current limit on the top side for an orthographic camera
  89219. * In scene unit
  89220. */
  89221. orthoTop: Nullable<number>;
  89222. /**
  89223. * Field Of View is set in Radians. (default is 0.8)
  89224. */
  89225. fov: number;
  89226. /**
  89227. * Define the minimum distance the camera can see from.
  89228. * This is important to note that the depth buffer are not infinite and the closer it starts
  89229. * the more your scene might encounter depth fighting issue.
  89230. */
  89231. minZ: number;
  89232. /**
  89233. * Define the maximum distance the camera can see to.
  89234. * This is important to note that the depth buffer are not infinite and the further it end
  89235. * the more your scene might encounter depth fighting issue.
  89236. */
  89237. maxZ: number;
  89238. /**
  89239. * Define the default inertia of the camera.
  89240. * This helps giving a smooth feeling to the camera movement.
  89241. */
  89242. inertia: number;
  89243. /**
  89244. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  89245. */
  89246. mode: number;
  89247. /**
  89248. * Define wether the camera is intermediate.
  89249. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89250. */
  89251. isIntermediate: boolean;
  89252. /**
  89253. * Define the viewport of the camera.
  89254. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89255. */
  89256. viewport: Viewport;
  89257. /**
  89258. * Restricts the camera to viewing objects with the same layerMask.
  89259. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89260. */
  89261. layerMask: number;
  89262. /**
  89263. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89264. */
  89265. fovMode: number;
  89266. /**
  89267. * Rig mode of the camera.
  89268. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89269. * This is normally controlled byt the camera themselves as internal use.
  89270. */
  89271. cameraRigMode: number;
  89272. /**
  89273. * Defines the distance between both "eyes" in case of a RIG
  89274. */
  89275. interaxialDistance: number;
  89276. /**
  89277. * Defines if stereoscopic rendering is done side by side or over under.
  89278. */
  89279. isStereoscopicSideBySide: boolean;
  89280. /**
  89281. * 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
  89282. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89283. * else in the scene.
  89284. */
  89285. customRenderTargets: RenderTargetTexture[];
  89286. /**
  89287. * When set, the camera will render to this render target instead of the default canvas
  89288. */
  89289. outputRenderTarget: Nullable<RenderTargetTexture>;
  89290. /**
  89291. * Observable triggered when the camera view matrix has changed.
  89292. */
  89293. onViewMatrixChangedObservable: Observable<Camera>;
  89294. /**
  89295. * Observable triggered when the camera Projection matrix has changed.
  89296. */
  89297. onProjectionMatrixChangedObservable: Observable<Camera>;
  89298. /**
  89299. * Observable triggered when the inputs have been processed.
  89300. */
  89301. onAfterCheckInputsObservable: Observable<Camera>;
  89302. /**
  89303. * Observable triggered when reset has been called and applied to the camera.
  89304. */
  89305. onRestoreStateObservable: Observable<Camera>;
  89306. /** @hidden */
  89307. _cameraRigParams: any;
  89308. /** @hidden */
  89309. _rigCameras: Camera[];
  89310. /** @hidden */
  89311. _rigPostProcess: Nullable<PostProcess>;
  89312. protected _webvrViewMatrix: Matrix;
  89313. /** @hidden */
  89314. _skipRendering: boolean;
  89315. /** @hidden */
  89316. _projectionMatrix: Matrix;
  89317. /** @hidden */
  89318. _postProcesses: Nullable<PostProcess>[];
  89319. /** @hidden */
  89320. _activeMeshes: SmartArray<AbstractMesh>;
  89321. protected _globalPosition: Vector3;
  89322. /** hidden */
  89323. _computedViewMatrix: Matrix;
  89324. private _doNotComputeProjectionMatrix;
  89325. private _transformMatrix;
  89326. private _frustumPlanes;
  89327. private _refreshFrustumPlanes;
  89328. private _storedFov;
  89329. private _stateStored;
  89330. /**
  89331. * Instantiates a new camera object.
  89332. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89333. * @see http://doc.babylonjs.com/features/cameras
  89334. * @param name Defines the name of the camera in the scene
  89335. * @param position Defines the position of the camera
  89336. * @param scene Defines the scene the camera belongs too
  89337. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89338. */
  89339. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89340. /**
  89341. * Store current camera state (fov, position, etc..)
  89342. * @returns the camera
  89343. */
  89344. storeState(): Camera;
  89345. /**
  89346. * Restores the camera state values if it has been stored. You must call storeState() first
  89347. */
  89348. protected _restoreStateValues(): boolean;
  89349. /**
  89350. * Restored camera state. You must call storeState() first.
  89351. * @returns true if restored and false otherwise
  89352. */
  89353. restoreState(): boolean;
  89354. /**
  89355. * Gets the class name of the camera.
  89356. * @returns the class name
  89357. */
  89358. getClassName(): string;
  89359. /** @hidden */
  89360. readonly _isCamera: boolean;
  89361. /**
  89362. * Gets a string representation of the camera useful for debug purpose.
  89363. * @param fullDetails Defines that a more verboe level of logging is required
  89364. * @returns the string representation
  89365. */
  89366. toString(fullDetails?: boolean): string;
  89367. /**
  89368. * Gets the current world space position of the camera.
  89369. */
  89370. readonly globalPosition: Vector3;
  89371. /**
  89372. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89373. * @returns the active meshe list
  89374. */
  89375. getActiveMeshes(): SmartArray<AbstractMesh>;
  89376. /**
  89377. * Check wether a mesh is part of the current active mesh list of the camera
  89378. * @param mesh Defines the mesh to check
  89379. * @returns true if active, false otherwise
  89380. */
  89381. isActiveMesh(mesh: Mesh): boolean;
  89382. /**
  89383. * Is this camera ready to be used/rendered
  89384. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89385. * @return true if the camera is ready
  89386. */
  89387. isReady(completeCheck?: boolean): boolean;
  89388. /** @hidden */
  89389. _initCache(): void;
  89390. /** @hidden */
  89391. _updateCache(ignoreParentClass?: boolean): void;
  89392. /** @hidden */
  89393. _isSynchronized(): boolean;
  89394. /** @hidden */
  89395. _isSynchronizedViewMatrix(): boolean;
  89396. /** @hidden */
  89397. _isSynchronizedProjectionMatrix(): boolean;
  89398. /**
  89399. * Attach the input controls to a specific dom element to get the input from.
  89400. * @param element Defines the element the controls should be listened from
  89401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89402. */
  89403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89404. /**
  89405. * Detach the current controls from the specified dom element.
  89406. * @param element Defines the element to stop listening the inputs from
  89407. */
  89408. detachControl(element: HTMLElement): void;
  89409. /**
  89410. * Update the camera state according to the different inputs gathered during the frame.
  89411. */
  89412. update(): void;
  89413. /** @hidden */
  89414. _checkInputs(): void;
  89415. /** @hidden */
  89416. readonly rigCameras: Camera[];
  89417. /**
  89418. * Gets the post process used by the rig cameras
  89419. */
  89420. readonly rigPostProcess: Nullable<PostProcess>;
  89421. /**
  89422. * Internal, gets the first post proces.
  89423. * @returns the first post process to be run on this camera.
  89424. */
  89425. _getFirstPostProcess(): Nullable<PostProcess>;
  89426. private _cascadePostProcessesToRigCams;
  89427. /**
  89428. * Attach a post process to the camera.
  89429. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89430. * @param postProcess The post process to attach to the camera
  89431. * @param insertAt The position of the post process in case several of them are in use in the scene
  89432. * @returns the position the post process has been inserted at
  89433. */
  89434. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89435. /**
  89436. * Detach a post process to the camera.
  89437. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89438. * @param postProcess The post process to detach from the camera
  89439. */
  89440. detachPostProcess(postProcess: PostProcess): void;
  89441. /**
  89442. * Gets the current world matrix of the camera
  89443. */
  89444. getWorldMatrix(): Matrix;
  89445. /** @hidden */
  89446. _getViewMatrix(): Matrix;
  89447. /**
  89448. * Gets the current view matrix of the camera.
  89449. * @param force forces the camera to recompute the matrix without looking at the cached state
  89450. * @returns the view matrix
  89451. */
  89452. getViewMatrix(force?: boolean): Matrix;
  89453. /**
  89454. * Freeze the projection matrix.
  89455. * It will prevent the cache check of the camera projection compute and can speed up perf
  89456. * if no parameter of the camera are meant to change
  89457. * @param projection Defines manually a projection if necessary
  89458. */
  89459. freezeProjectionMatrix(projection?: Matrix): void;
  89460. /**
  89461. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89462. */
  89463. unfreezeProjectionMatrix(): void;
  89464. /**
  89465. * Gets the current projection matrix of the camera.
  89466. * @param force forces the camera to recompute the matrix without looking at the cached state
  89467. * @returns the projection matrix
  89468. */
  89469. getProjectionMatrix(force?: boolean): Matrix;
  89470. /**
  89471. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89472. * @returns a Matrix
  89473. */
  89474. getTransformationMatrix(): Matrix;
  89475. private _updateFrustumPlanes;
  89476. /**
  89477. * Checks if a cullable object (mesh...) is in the camera frustum
  89478. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89479. * @param target The object to check
  89480. * @returns true if the object is in frustum otherwise false
  89481. */
  89482. isInFrustum(target: ICullable): boolean;
  89483. /**
  89484. * Checks if a cullable object (mesh...) is in the camera frustum
  89485. * Unlike isInFrustum this cheks the full bounding box
  89486. * @param target The object to check
  89487. * @returns true if the object is in frustum otherwise false
  89488. */
  89489. isCompletelyInFrustum(target: ICullable): boolean;
  89490. /**
  89491. * Gets a ray in the forward direction from the camera.
  89492. * @param length Defines the length of the ray to create
  89493. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89494. * @param origin Defines the start point of the ray which defaults to the camera position
  89495. * @returns the forward ray
  89496. */
  89497. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89498. /**
  89499. * Releases resources associated with this node.
  89500. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89501. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89502. */
  89503. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89504. /** @hidden */
  89505. _isLeftCamera: boolean;
  89506. /**
  89507. * Gets the left camera of a rig setup in case of Rigged Camera
  89508. */
  89509. readonly isLeftCamera: boolean;
  89510. /** @hidden */
  89511. _isRightCamera: boolean;
  89512. /**
  89513. * Gets the right camera of a rig setup in case of Rigged Camera
  89514. */
  89515. readonly isRightCamera: boolean;
  89516. /**
  89517. * Gets the left camera of a rig setup in case of Rigged Camera
  89518. */
  89519. readonly leftCamera: Nullable<FreeCamera>;
  89520. /**
  89521. * Gets the right camera of a rig setup in case of Rigged Camera
  89522. */
  89523. readonly rightCamera: Nullable<FreeCamera>;
  89524. /**
  89525. * Gets the left camera target of a rig setup in case of Rigged Camera
  89526. * @returns the target position
  89527. */
  89528. getLeftTarget(): Nullable<Vector3>;
  89529. /**
  89530. * Gets the right camera target of a rig setup in case of Rigged Camera
  89531. * @returns the target position
  89532. */
  89533. getRightTarget(): Nullable<Vector3>;
  89534. /**
  89535. * @hidden
  89536. */
  89537. setCameraRigMode(mode: number, rigParams: any): void;
  89538. /** @hidden */
  89539. static _setStereoscopicRigMode(camera: Camera): void;
  89540. /** @hidden */
  89541. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89542. /** @hidden */
  89543. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89544. /** @hidden */
  89545. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89546. /** @hidden */
  89547. _getVRProjectionMatrix(): Matrix;
  89548. protected _updateCameraRotationMatrix(): void;
  89549. protected _updateWebVRCameraRotationMatrix(): void;
  89550. /**
  89551. * This function MUST be overwritten by the different WebVR cameras available.
  89552. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89553. * @hidden
  89554. */
  89555. _getWebVRProjectionMatrix(): Matrix;
  89556. /**
  89557. * This function MUST be overwritten by the different WebVR cameras available.
  89558. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89559. * @hidden
  89560. */
  89561. _getWebVRViewMatrix(): Matrix;
  89562. /** @hidden */
  89563. setCameraRigParameter(name: string, value: any): void;
  89564. /**
  89565. * needs to be overridden by children so sub has required properties to be copied
  89566. * @hidden
  89567. */
  89568. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89569. /**
  89570. * May need to be overridden by children
  89571. * @hidden
  89572. */
  89573. _updateRigCameras(): void;
  89574. /** @hidden */
  89575. _setupInputs(): void;
  89576. /**
  89577. * Serialiaze the camera setup to a json represention
  89578. * @returns the JSON representation
  89579. */
  89580. serialize(): any;
  89581. /**
  89582. * Clones the current camera.
  89583. * @param name The cloned camera name
  89584. * @returns the cloned camera
  89585. */
  89586. clone(name: string): Camera;
  89587. /**
  89588. * Gets the direction of the camera relative to a given local axis.
  89589. * @param localAxis Defines the reference axis to provide a relative direction.
  89590. * @return the direction
  89591. */
  89592. getDirection(localAxis: Vector3): Vector3;
  89593. /**
  89594. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89595. * @param localAxis Defines the reference axis to provide a relative direction.
  89596. * @param result Defines the vector to store the result in
  89597. */
  89598. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89599. /**
  89600. * Gets a camera constructor for a given camera type
  89601. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89602. * @param name The name of the camera the result will be able to instantiate
  89603. * @param scene The scene the result will construct the camera in
  89604. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89605. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89606. * @returns a factory method to construc the camera
  89607. */
  89608. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89609. /**
  89610. * Compute the world matrix of the camera.
  89611. * @returns the camera workd matrix
  89612. */
  89613. computeWorldMatrix(): Matrix;
  89614. /**
  89615. * Parse a JSON and creates the camera from the parsed information
  89616. * @param parsedCamera The JSON to parse
  89617. * @param scene The scene to instantiate the camera in
  89618. * @returns the newly constructed camera
  89619. */
  89620. static Parse(parsedCamera: any, scene: Scene): Camera;
  89621. }
  89622. }
  89623. declare module BABYLON {
  89624. /**
  89625. * Interface for any object that can request an animation frame
  89626. */
  89627. export interface ICustomAnimationFrameRequester {
  89628. /**
  89629. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  89630. */
  89631. renderFunction?: Function;
  89632. /**
  89633. * Called to request the next frame to render to
  89634. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  89635. */
  89636. requestAnimationFrame: Function;
  89637. /**
  89638. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  89639. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  89640. */
  89641. requestID?: number;
  89642. }
  89643. /**
  89644. * Interface containing an array of animations
  89645. */
  89646. export interface IAnimatable {
  89647. /**
  89648. * Array of animations
  89649. */
  89650. animations: Array<Animation>;
  89651. }
  89652. /** Interface used by value gradients (color, factor, ...) */
  89653. export interface IValueGradient {
  89654. /**
  89655. * Gets or sets the gradient value (between 0 and 1)
  89656. */
  89657. gradient: number;
  89658. }
  89659. /** Class used to store color4 gradient */
  89660. export class ColorGradient implements IValueGradient {
  89661. /**
  89662. * Gets or sets the gradient value (between 0 and 1)
  89663. */
  89664. gradient: number;
  89665. /**
  89666. * Gets or sets first associated color
  89667. */
  89668. color1: Color4;
  89669. /**
  89670. * Gets or sets second associated color
  89671. */
  89672. color2?: Color4;
  89673. /**
  89674. * Will get a color picked randomly between color1 and color2.
  89675. * If color2 is undefined then color1 will be used
  89676. * @param result defines the target Color4 to store the result in
  89677. */
  89678. getColorToRef(result: Color4): void;
  89679. }
  89680. /** Class used to store color 3 gradient */
  89681. export class Color3Gradient implements IValueGradient {
  89682. /**
  89683. * Gets or sets the gradient value (between 0 and 1)
  89684. */
  89685. gradient: number;
  89686. /**
  89687. * Gets or sets the associated color
  89688. */
  89689. color: Color3;
  89690. }
  89691. /** Class used to store factor gradient */
  89692. export class FactorGradient implements IValueGradient {
  89693. /**
  89694. * Gets or sets the gradient value (between 0 and 1)
  89695. */
  89696. gradient: number;
  89697. /**
  89698. * Gets or sets first associated factor
  89699. */
  89700. factor1: number;
  89701. /**
  89702. * Gets or sets second associated factor
  89703. */
  89704. factor2?: number;
  89705. /**
  89706. * Will get a number picked randomly between factor1 and factor2.
  89707. * If factor2 is undefined then factor1 will be used
  89708. * @returns the picked number
  89709. */
  89710. getFactor(): number;
  89711. }
  89712. /**
  89713. * @ignore
  89714. * Application error to support additional information when loading a file
  89715. */
  89716. export class LoadFileError extends Error {
  89717. /** defines the optional web request */
  89718. request?: WebRequest | undefined;
  89719. private static _setPrototypeOf;
  89720. /**
  89721. * Creates a new LoadFileError
  89722. * @param message defines the message of the error
  89723. * @param request defines the optional web request
  89724. */
  89725. constructor(message: string,
  89726. /** defines the optional web request */
  89727. request?: WebRequest | undefined);
  89728. }
  89729. /**
  89730. * Class used to define a retry strategy when error happens while loading assets
  89731. */
  89732. export class RetryStrategy {
  89733. /**
  89734. * Function used to defines an exponential back off strategy
  89735. * @param maxRetries defines the maximum number of retries (3 by default)
  89736. * @param baseInterval defines the interval between retries
  89737. * @returns the strategy function to use
  89738. */
  89739. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  89740. }
  89741. /**
  89742. * File request interface
  89743. */
  89744. export interface IFileRequest {
  89745. /**
  89746. * Raised when the request is complete (success or error).
  89747. */
  89748. onCompleteObservable: Observable<IFileRequest>;
  89749. /**
  89750. * Aborts the request for a file.
  89751. */
  89752. abort: () => void;
  89753. }
  89754. /**
  89755. * Class containing a set of static utilities functions
  89756. */
  89757. export class Tools {
  89758. /**
  89759. * Gets or sets the base URL to use to load assets
  89760. */
  89761. static BaseUrl: string;
  89762. /**
  89763. * Enable/Disable Custom HTTP Request Headers globally.
  89764. * default = false
  89765. * @see CustomRequestHeaders
  89766. */
  89767. static UseCustomRequestHeaders: boolean;
  89768. /**
  89769. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  89770. * i.e. when loading files, where the server/service expects an Authorization header
  89771. */
  89772. static CustomRequestHeaders: {
  89773. [key: string]: string;
  89774. };
  89775. /**
  89776. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  89777. */
  89778. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  89779. /**
  89780. * Default behaviour for cors in the application.
  89781. * It can be a string if the expected behavior is identical in the entire app.
  89782. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  89783. */
  89784. static CorsBehavior: string | ((url: string | string[]) => string);
  89785. /**
  89786. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  89787. * @ignorenaming
  89788. */
  89789. static UseFallbackTexture: boolean;
  89790. /**
  89791. * Use this object to register external classes like custom textures or material
  89792. * to allow the laoders to instantiate them
  89793. */
  89794. static RegisteredExternalClasses: {
  89795. [key: string]: Object;
  89796. };
  89797. /**
  89798. * Texture content used if a texture cannot loaded
  89799. * @ignorenaming
  89800. */
  89801. static fallbackTexture: string;
  89802. /**
  89803. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  89804. * @param u defines the coordinate on X axis
  89805. * @param v defines the coordinate on Y axis
  89806. * @param width defines the width of the source data
  89807. * @param height defines the height of the source data
  89808. * @param pixels defines the source byte array
  89809. * @param color defines the output color
  89810. */
  89811. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  89812. /**
  89813. * Interpolates between a and b via alpha
  89814. * @param a The lower value (returned when alpha = 0)
  89815. * @param b The upper value (returned when alpha = 1)
  89816. * @param alpha The interpolation-factor
  89817. * @return The mixed value
  89818. */
  89819. static Mix(a: number, b: number, alpha: number): number;
  89820. /**
  89821. * Tries to instantiate a new object from a given class name
  89822. * @param className defines the class name to instantiate
  89823. * @returns the new object or null if the system was not able to do the instantiation
  89824. */
  89825. static Instantiate(className: string): any;
  89826. /**
  89827. * Provides a slice function that will work even on IE
  89828. * @param data defines the array to slice
  89829. * @param start defines the start of the data (optional)
  89830. * @param end defines the end of the data (optional)
  89831. * @returns the new sliced array
  89832. */
  89833. static Slice<T>(data: T, start?: number, end?: number): T;
  89834. /**
  89835. * Polyfill for setImmediate
  89836. * @param action defines the action to execute after the current execution block
  89837. */
  89838. static SetImmediate(action: () => void): void;
  89839. /**
  89840. * Function indicating if a number is an exponent of 2
  89841. * @param value defines the value to test
  89842. * @returns true if the value is an exponent of 2
  89843. */
  89844. static IsExponentOfTwo(value: number): boolean;
  89845. private static _tmpFloatArray;
  89846. /**
  89847. * Returns the nearest 32-bit single precision float representation of a Number
  89848. * @param value A Number. If the parameter is of a different type, it will get converted
  89849. * to a number or to NaN if it cannot be converted
  89850. * @returns number
  89851. */
  89852. static FloatRound(value: number): number;
  89853. /**
  89854. * Find the next highest power of two.
  89855. * @param x Number to start search from.
  89856. * @return Next highest power of two.
  89857. */
  89858. static CeilingPOT(x: number): number;
  89859. /**
  89860. * Find the next lowest power of two.
  89861. * @param x Number to start search from.
  89862. * @return Next lowest power of two.
  89863. */
  89864. static FloorPOT(x: number): number;
  89865. /**
  89866. * Find the nearest power of two.
  89867. * @param x Number to start search from.
  89868. * @return Next nearest power of two.
  89869. */
  89870. static NearestPOT(x: number): number;
  89871. /**
  89872. * Get the closest exponent of two
  89873. * @param value defines the value to approximate
  89874. * @param max defines the maximum value to return
  89875. * @param mode defines how to define the closest value
  89876. * @returns closest exponent of two of the given value
  89877. */
  89878. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  89879. /**
  89880. * Extracts the filename from a path
  89881. * @param path defines the path to use
  89882. * @returns the filename
  89883. */
  89884. static GetFilename(path: string): string;
  89885. /**
  89886. * Extracts the "folder" part of a path (everything before the filename).
  89887. * @param uri The URI to extract the info from
  89888. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  89889. * @returns The "folder" part of the path
  89890. */
  89891. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  89892. /**
  89893. * Extracts text content from a DOM element hierarchy
  89894. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  89895. */
  89896. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  89897. /**
  89898. * Convert an angle in radians to degrees
  89899. * @param angle defines the angle to convert
  89900. * @returns the angle in degrees
  89901. */
  89902. static ToDegrees(angle: number): number;
  89903. /**
  89904. * Convert an angle in degrees to radians
  89905. * @param angle defines the angle to convert
  89906. * @returns the angle in radians
  89907. */
  89908. static ToRadians(angle: number): number;
  89909. /**
  89910. * Encode a buffer to a base64 string
  89911. * @param buffer defines the buffer to encode
  89912. * @returns the encoded string
  89913. */
  89914. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  89915. /**
  89916. * Extracts minimum and maximum values from a list of indexed positions
  89917. * @param positions defines the positions to use
  89918. * @param indices defines the indices to the positions
  89919. * @param indexStart defines the start index
  89920. * @param indexCount defines the end index
  89921. * @param bias defines bias value to add to the result
  89922. * @return minimum and maximum values
  89923. */
  89924. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  89925. minimum: Vector3;
  89926. maximum: Vector3;
  89927. };
  89928. /**
  89929. * Extracts minimum and maximum values from a list of positions
  89930. * @param positions defines the positions to use
  89931. * @param start defines the start index in the positions array
  89932. * @param count defines the number of positions to handle
  89933. * @param bias defines bias value to add to the result
  89934. * @param stride defines the stride size to use (distance between two positions in the positions array)
  89935. * @return minimum and maximum values
  89936. */
  89937. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  89938. minimum: Vector3;
  89939. maximum: Vector3;
  89940. };
  89941. /**
  89942. * Returns an array if obj is not an array
  89943. * @param obj defines the object to evaluate as an array
  89944. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  89945. * @returns either obj directly if obj is an array or a new array containing obj
  89946. */
  89947. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  89948. /**
  89949. * Gets the pointer prefix to use
  89950. * @returns "pointer" if touch is enabled. Else returns "mouse"
  89951. */
  89952. static GetPointerPrefix(): string;
  89953. /**
  89954. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  89955. * @param func - the function to be called
  89956. * @param requester - the object that will request the next frame. Falls back to window.
  89957. * @returns frame number
  89958. */
  89959. static QueueNewFrame(func: () => void, requester?: any): number;
  89960. /**
  89961. * Ask the browser to promote the current element to fullscreen rendering mode
  89962. * @param element defines the DOM element to promote
  89963. */
  89964. static RequestFullscreen(element: HTMLElement): void;
  89965. /**
  89966. * Asks the browser to exit fullscreen mode
  89967. */
  89968. static ExitFullscreen(): void;
  89969. /**
  89970. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  89971. * @param url define the url we are trying
  89972. * @param element define the dom element where to configure the cors policy
  89973. */
  89974. static SetCorsBehavior(url: string | string[], element: {
  89975. crossOrigin: string | null;
  89976. }): void;
  89977. /**
  89978. * Removes unwanted characters from an url
  89979. * @param url defines the url to clean
  89980. * @returns the cleaned url
  89981. */
  89982. static CleanUrl(url: string): string;
  89983. /**
  89984. * Gets or sets a function used to pre-process url before using them to load assets
  89985. */
  89986. static PreprocessUrl: (url: string) => string;
  89987. /**
  89988. * Loads an image as an HTMLImageElement.
  89989. * @param input url string, ArrayBuffer, or Blob to load
  89990. * @param onLoad callback called when the image successfully loads
  89991. * @param onError callback called when the image fails to load
  89992. * @param offlineProvider offline provider for caching
  89993. * @returns the HTMLImageElement of the loaded image
  89994. */
  89995. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  89996. /**
  89997. * Loads a file
  89998. * @param url url string, ArrayBuffer, or Blob to load
  89999. * @param onSuccess callback called when the file successfully loads
  90000. * @param onProgress callback called while file is loading (if the server supports this mode)
  90001. * @param offlineProvider defines the offline provider for caching
  90002. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90003. * @param onError callback called when the file fails to load
  90004. * @returns a file request object
  90005. */
  90006. 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;
  90007. /**
  90008. * Load a script (identified by an url). When the url returns, the
  90009. * content of this file is added into a new script element, attached to the DOM (body element)
  90010. * @param scriptUrl defines the url of the script to laod
  90011. * @param onSuccess defines the callback called when the script is loaded
  90012. * @param onError defines the callback to call if an error occurs
  90013. * @param scriptId defines the id of the script element
  90014. */
  90015. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90016. /**
  90017. * Load an asynchronous script (identified by an url). When the url returns, the
  90018. * content of this file is added into a new script element, attached to the DOM (body element)
  90019. * @param scriptUrl defines the url of the script to laod
  90020. * @param scriptId defines the id of the script element
  90021. * @returns a promise request object
  90022. */
  90023. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90024. /**
  90025. * Loads a file from a blob
  90026. * @param fileToLoad defines the blob to use
  90027. * @param callback defines the callback to call when data is loaded
  90028. * @param progressCallback defines the callback to call during loading process
  90029. * @returns a file request object
  90030. */
  90031. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90032. /**
  90033. * Loads a file
  90034. * @param fileToLoad defines the file to load
  90035. * @param callback defines the callback to call when data is loaded
  90036. * @param progressCallBack defines the callback to call during loading process
  90037. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90038. * @returns a file request object
  90039. */
  90040. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90041. /**
  90042. * Creates a data url from a given string content
  90043. * @param content defines the content to convert
  90044. * @returns the new data url link
  90045. */
  90046. static FileAsURL(content: string): string;
  90047. /**
  90048. * Format the given number to a specific decimal format
  90049. * @param value defines the number to format
  90050. * @param decimals defines the number of decimals to use
  90051. * @returns the formatted string
  90052. */
  90053. static Format(value: number, decimals?: number): string;
  90054. /**
  90055. * Checks if a given vector is inside a specific range
  90056. * @param v defines the vector to test
  90057. * @param min defines the minimum range
  90058. * @param max defines the maximum range
  90059. */
  90060. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90061. /**
  90062. * Tries to copy an object by duplicating every property
  90063. * @param source defines the source object
  90064. * @param destination defines the target object
  90065. * @param doNotCopyList defines a list of properties to avoid
  90066. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90067. */
  90068. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90069. /**
  90070. * Gets a boolean indicating if the given object has no own property
  90071. * @param obj defines the object to test
  90072. * @returns true if object has no own property
  90073. */
  90074. static IsEmpty(obj: any): boolean;
  90075. /**
  90076. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90077. * @param str Source string
  90078. * @param suffix Suffix to search for in the source string
  90079. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90080. */
  90081. static EndsWith(str: string, suffix: string): boolean;
  90082. /**
  90083. * Function used to register events at window level
  90084. * @param events defines the events to register
  90085. */
  90086. static RegisterTopRootEvents(events: {
  90087. name: string;
  90088. handler: Nullable<(e: FocusEvent) => any>;
  90089. }[]): void;
  90090. /**
  90091. * Function used to unregister events from window level
  90092. * @param events defines the events to unregister
  90093. */
  90094. static UnregisterTopRootEvents(events: {
  90095. name: string;
  90096. handler: Nullable<(e: FocusEvent) => any>;
  90097. }[]): void;
  90098. /**
  90099. * @ignore
  90100. */
  90101. static _ScreenshotCanvas: HTMLCanvasElement;
  90102. /**
  90103. * Dumps the current bound framebuffer
  90104. * @param width defines the rendering width
  90105. * @param height defines the rendering height
  90106. * @param engine defines the hosting engine
  90107. * @param successCallback defines the callback triggered once the data are available
  90108. * @param mimeType defines the mime type of the result
  90109. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  90110. */
  90111. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90112. /**
  90113. * Converts the canvas data to blob.
  90114. * This acts as a polyfill for browsers not supporting the to blob function.
  90115. * @param canvas Defines the canvas to extract the data from
  90116. * @param successCallback Defines the callback triggered once the data are available
  90117. * @param mimeType Defines the mime type of the result
  90118. */
  90119. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  90120. /**
  90121. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  90122. * @param successCallback defines the callback triggered once the data are available
  90123. * @param mimeType defines the mime type of the result
  90124. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  90125. */
  90126. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90127. /**
  90128. * Downloads a blob in the browser
  90129. * @param blob defines the blob to download
  90130. * @param fileName defines the name of the downloaded file
  90131. */
  90132. static Download(blob: Blob, fileName: string): void;
  90133. /**
  90134. * Captures a screenshot of the current rendering
  90135. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90136. * @param engine defines the rendering engine
  90137. * @param camera defines the source camera
  90138. * @param size This parameter can be set to a single number or to an object with the
  90139. * following (optional) properties: precision, width, height. If a single number is passed,
  90140. * it will be used for both width and height. If an object is passed, the screenshot size
  90141. * will be derived from the parameters. The precision property is a multiplier allowing
  90142. * rendering at a higher or lower resolution
  90143. * @param successCallback defines the callback receives a single parameter which contains the
  90144. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90145. * src parameter of an <img> to display it
  90146. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  90147. * Check your browser for supported MIME types
  90148. */
  90149. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  90150. /**
  90151. * Generates an image screenshot from the specified camera.
  90152. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90153. * @param engine The engine to use for rendering
  90154. * @param camera The camera to use for rendering
  90155. * @param size This parameter can be set to a single number or to an object with the
  90156. * following (optional) properties: precision, width, height. If a single number is passed,
  90157. * it will be used for both width and height. If an object is passed, the screenshot size
  90158. * will be derived from the parameters. The precision property is a multiplier allowing
  90159. * rendering at a higher or lower resolution
  90160. * @param successCallback The callback receives a single parameter which contains the
  90161. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90162. * src parameter of an <img> to display it
  90163. * @param mimeType The MIME type of the screenshot image (default: image/png).
  90164. * Check your browser for supported MIME types
  90165. * @param samples Texture samples (default: 1)
  90166. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  90167. * @param fileName A name for for the downloaded file.
  90168. */
  90169. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  90170. /**
  90171. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90172. * Be aware Math.random() could cause collisions, but:
  90173. * "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"
  90174. * @returns a pseudo random id
  90175. */
  90176. static RandomId(): string;
  90177. /**
  90178. * Test if the given uri is a base64 string
  90179. * @param uri The uri to test
  90180. * @return True if the uri is a base64 string or false otherwise
  90181. */
  90182. static IsBase64(uri: string): boolean;
  90183. /**
  90184. * Decode the given base64 uri.
  90185. * @param uri The uri to decode
  90186. * @return The decoded base64 data.
  90187. */
  90188. static DecodeBase64(uri: string): ArrayBuffer;
  90189. /**
  90190. * No log
  90191. */
  90192. static readonly NoneLogLevel: number;
  90193. /**
  90194. * Only message logs
  90195. */
  90196. static readonly MessageLogLevel: number;
  90197. /**
  90198. * Only warning logs
  90199. */
  90200. static readonly WarningLogLevel: number;
  90201. /**
  90202. * Only error logs
  90203. */
  90204. static readonly ErrorLogLevel: number;
  90205. /**
  90206. * All logs
  90207. */
  90208. static readonly AllLogLevel: number;
  90209. /**
  90210. * Gets a value indicating the number of loading errors
  90211. * @ignorenaming
  90212. */
  90213. static readonly errorsCount: number;
  90214. /**
  90215. * Callback called when a new log is added
  90216. */
  90217. static OnNewCacheEntry: (entry: string) => void;
  90218. /**
  90219. * Log a message to the console
  90220. * @param message defines the message to log
  90221. */
  90222. static Log(message: string): void;
  90223. /**
  90224. * Write a warning message to the console
  90225. * @param message defines the message to log
  90226. */
  90227. static Warn(message: string): void;
  90228. /**
  90229. * Write an error message to the console
  90230. * @param message defines the message to log
  90231. */
  90232. static Error(message: string): void;
  90233. /**
  90234. * Gets current log cache (list of logs)
  90235. */
  90236. static readonly LogCache: string;
  90237. /**
  90238. * Clears the log cache
  90239. */
  90240. static ClearLogCache(): void;
  90241. /**
  90242. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  90243. */
  90244. static LogLevels: number;
  90245. /**
  90246. * Checks if the loaded document was accessed via `file:`-Protocol.
  90247. * @returns boolean
  90248. */
  90249. static IsFileURL(): boolean;
  90250. /**
  90251. * Checks if the window object exists
  90252. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  90253. */
  90254. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  90255. /**
  90256. * No performance log
  90257. */
  90258. static readonly PerformanceNoneLogLevel: number;
  90259. /**
  90260. * Use user marks to log performance
  90261. */
  90262. static readonly PerformanceUserMarkLogLevel: number;
  90263. /**
  90264. * Log performance to the console
  90265. */
  90266. static readonly PerformanceConsoleLogLevel: number;
  90267. private static _performance;
  90268. /**
  90269. * Sets the current performance log level
  90270. */
  90271. static PerformanceLogLevel: number;
  90272. private static _StartPerformanceCounterDisabled;
  90273. private static _EndPerformanceCounterDisabled;
  90274. private static _StartUserMark;
  90275. private static _EndUserMark;
  90276. private static _StartPerformanceConsole;
  90277. private static _EndPerformanceConsole;
  90278. /**
  90279. * Starts a performance counter
  90280. */
  90281. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90282. /**
  90283. * Ends a specific performance coutner
  90284. */
  90285. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90286. /**
  90287. * Gets either window.performance.now() if supported or Date.now() else
  90288. */
  90289. static readonly Now: number;
  90290. /**
  90291. * This method will return the name of the class used to create the instance of the given object.
  90292. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  90293. * @param object the object to get the class name from
  90294. * @param isType defines if the object is actually a type
  90295. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  90296. */
  90297. static GetClassName(object: any, isType?: boolean): string;
  90298. /**
  90299. * Gets the first element of an array satisfying a given predicate
  90300. * @param array defines the array to browse
  90301. * @param predicate defines the predicate to use
  90302. * @returns null if not found or the element
  90303. */
  90304. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  90305. /**
  90306. * This method will return the name of the full name of the class, including its owning module (if any).
  90307. * 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).
  90308. * @param object the object to get the class name from
  90309. * @param isType defines if the object is actually a type
  90310. * @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.
  90311. * @ignorenaming
  90312. */
  90313. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  90314. /**
  90315. * Returns a promise that resolves after the given amount of time.
  90316. * @param delay Number of milliseconds to delay
  90317. * @returns Promise that resolves after the given amount of time
  90318. */
  90319. static DelayAsync(delay: number): Promise<void>;
  90320. /**
  90321. * Gets the current gradient from an array of IValueGradient
  90322. * @param ratio defines the current ratio to get
  90323. * @param gradients defines the array of IValueGradient
  90324. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90325. */
  90326. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90327. }
  90328. /**
  90329. * This class is used to track a performance counter which is number based.
  90330. * The user has access to many properties which give statistics of different nature.
  90331. *
  90332. * The implementer can track two kinds of Performance Counter: time and count.
  90333. * 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.
  90334. * 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.
  90335. */
  90336. export class PerfCounter {
  90337. /**
  90338. * Gets or sets a global boolean to turn on and off all the counters
  90339. */
  90340. static Enabled: boolean;
  90341. /**
  90342. * Returns the smallest value ever
  90343. */
  90344. readonly min: number;
  90345. /**
  90346. * Returns the biggest value ever
  90347. */
  90348. readonly max: number;
  90349. /**
  90350. * Returns the average value since the performance counter is running
  90351. */
  90352. readonly average: number;
  90353. /**
  90354. * Returns the average value of the last second the counter was monitored
  90355. */
  90356. readonly lastSecAverage: number;
  90357. /**
  90358. * Returns the current value
  90359. */
  90360. readonly current: number;
  90361. /**
  90362. * Gets the accumulated total
  90363. */
  90364. readonly total: number;
  90365. /**
  90366. * Gets the total value count
  90367. */
  90368. readonly count: number;
  90369. /**
  90370. * Creates a new counter
  90371. */
  90372. constructor();
  90373. /**
  90374. * Call this method to start monitoring a new frame.
  90375. * 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.
  90376. */
  90377. fetchNewFrame(): void;
  90378. /**
  90379. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  90380. * @param newCount the count value to add to the monitored count
  90381. * @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.
  90382. */
  90383. addCount(newCount: number, fetchResult: boolean): void;
  90384. /**
  90385. * Start monitoring this performance counter
  90386. */
  90387. beginMonitoring(): void;
  90388. /**
  90389. * Compute the time lapsed since the previous beginMonitoring() call.
  90390. * @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
  90391. */
  90392. endMonitoring(newFrame?: boolean): void;
  90393. private _fetchResult;
  90394. private _startMonitoringTime;
  90395. private _min;
  90396. private _max;
  90397. private _average;
  90398. private _current;
  90399. private _totalValueCount;
  90400. private _totalAccumulated;
  90401. private _lastSecAverage;
  90402. private _lastSecAccumulated;
  90403. private _lastSecTime;
  90404. private _lastSecValueCount;
  90405. }
  90406. /**
  90407. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  90408. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  90409. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  90410. * @param name The name of the class, case should be preserved
  90411. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  90412. */
  90413. export function className(name: string, module?: string): (target: Object) => void;
  90414. /**
  90415. * An implementation of a loop for asynchronous functions.
  90416. */
  90417. export class AsyncLoop {
  90418. /**
  90419. * Defines the number of iterations for the loop
  90420. */
  90421. iterations: number;
  90422. /**
  90423. * Defines the current index of the loop.
  90424. */
  90425. index: number;
  90426. private _done;
  90427. private _fn;
  90428. private _successCallback;
  90429. /**
  90430. * Constructor.
  90431. * @param iterations the number of iterations.
  90432. * @param func the function to run each iteration
  90433. * @param successCallback the callback that will be called upon succesful execution
  90434. * @param offset starting offset.
  90435. */
  90436. constructor(
  90437. /**
  90438. * Defines the number of iterations for the loop
  90439. */
  90440. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  90441. /**
  90442. * Execute the next iteration. Must be called after the last iteration was finished.
  90443. */
  90444. executeNext(): void;
  90445. /**
  90446. * Break the loop and run the success callback.
  90447. */
  90448. breakLoop(): void;
  90449. /**
  90450. * Create and run an async loop.
  90451. * @param iterations the number of iterations.
  90452. * @param fn the function to run each iteration
  90453. * @param successCallback the callback that will be called upon succesful execution
  90454. * @param offset starting offset.
  90455. * @returns the created async loop object
  90456. */
  90457. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  90458. /**
  90459. * A for-loop that will run a given number of iterations synchronous and the rest async.
  90460. * @param iterations total number of iterations
  90461. * @param syncedIterations number of synchronous iterations in each async iteration.
  90462. * @param fn the function to call each iteration.
  90463. * @param callback a success call back that will be called when iterating stops.
  90464. * @param breakFunction a break condition (optional)
  90465. * @param timeout timeout settings for the setTimeout function. default - 0.
  90466. * @returns the created async loop object
  90467. */
  90468. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  90469. }
  90470. }
  90471. declare module BABYLON {
  90472. /** @hidden */
  90473. export interface ICollisionCoordinator {
  90474. createCollider(): Collider;
  90475. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90476. init(scene: Scene): void;
  90477. }
  90478. /** @hidden */
  90479. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  90480. private _scene;
  90481. private _scaledPosition;
  90482. private _scaledVelocity;
  90483. private _finalPosition;
  90484. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90485. createCollider(): Collider;
  90486. init(scene: Scene): void;
  90487. private _collideWithWorld;
  90488. }
  90489. }
  90490. declare module BABYLON {
  90491. /**
  90492. * This class defines the direct association between an animation and a target
  90493. */
  90494. export class TargetedAnimation {
  90495. /**
  90496. * Animation to perform
  90497. */
  90498. animation: Animation;
  90499. /**
  90500. * Target to animate
  90501. */
  90502. target: any;
  90503. }
  90504. /**
  90505. * Use this class to create coordinated animations on multiple targets
  90506. */
  90507. export class AnimationGroup implements IDisposable {
  90508. /** The name of the animation group */
  90509. name: string;
  90510. private _scene;
  90511. private _targetedAnimations;
  90512. private _animatables;
  90513. private _from;
  90514. private _to;
  90515. private _isStarted;
  90516. private _isPaused;
  90517. private _speedRatio;
  90518. /**
  90519. * Gets or sets the unique id of the node
  90520. */
  90521. uniqueId: number;
  90522. /**
  90523. * This observable will notify when one animation have ended
  90524. */
  90525. onAnimationEndObservable: Observable<TargetedAnimation>;
  90526. /**
  90527. * Observer raised when one animation loops
  90528. */
  90529. onAnimationLoopObservable: Observable<TargetedAnimation>;
  90530. /**
  90531. * This observable will notify when all animations have ended.
  90532. */
  90533. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  90534. /**
  90535. * This observable will notify when all animations have paused.
  90536. */
  90537. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  90538. /**
  90539. * This observable will notify when all animations are playing.
  90540. */
  90541. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  90542. /**
  90543. * Gets the first frame
  90544. */
  90545. readonly from: number;
  90546. /**
  90547. * Gets the last frame
  90548. */
  90549. readonly to: number;
  90550. /**
  90551. * Define if the animations are started
  90552. */
  90553. readonly isStarted: boolean;
  90554. /**
  90555. * Gets a value indicating that the current group is playing
  90556. */
  90557. readonly isPlaying: boolean;
  90558. /**
  90559. * Gets or sets the speed ratio to use for all animations
  90560. */
  90561. /**
  90562. * Gets or sets the speed ratio to use for all animations
  90563. */
  90564. speedRatio: number;
  90565. /**
  90566. * Gets the targeted animations for this animation group
  90567. */
  90568. readonly targetedAnimations: Array<TargetedAnimation>;
  90569. /**
  90570. * returning the list of animatables controlled by this animation group.
  90571. */
  90572. readonly animatables: Array<Animatable>;
  90573. /**
  90574. * Instantiates a new Animation Group.
  90575. * This helps managing several animations at once.
  90576. * @see http://doc.babylonjs.com/how_to/group
  90577. * @param name Defines the name of the group
  90578. * @param scene Defines the scene the group belongs to
  90579. */
  90580. constructor(
  90581. /** The name of the animation group */
  90582. name: string, scene?: Nullable<Scene>);
  90583. /**
  90584. * Add an animation (with its target) in the group
  90585. * @param animation defines the animation we want to add
  90586. * @param target defines the target of the animation
  90587. * @returns the TargetedAnimation object
  90588. */
  90589. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  90590. /**
  90591. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  90592. * It can add constant keys at begin or end
  90593. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  90594. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  90595. * @returns the animation group
  90596. */
  90597. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  90598. /**
  90599. * Start all animations on given targets
  90600. * @param loop defines if animations must loop
  90601. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  90602. * @param from defines the from key (optional)
  90603. * @param to defines the to key (optional)
  90604. * @returns the current animation group
  90605. */
  90606. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  90607. /**
  90608. * Pause all animations
  90609. * @returns the animation group
  90610. */
  90611. pause(): AnimationGroup;
  90612. /**
  90613. * Play all animations to initial state
  90614. * This function will start() the animations if they were not started or will restart() them if they were paused
  90615. * @param loop defines if animations must loop
  90616. * @returns the animation group
  90617. */
  90618. play(loop?: boolean): AnimationGroup;
  90619. /**
  90620. * Reset all animations to initial state
  90621. * @returns the animation group
  90622. */
  90623. reset(): AnimationGroup;
  90624. /**
  90625. * Restart animations from key 0
  90626. * @returns the animation group
  90627. */
  90628. restart(): AnimationGroup;
  90629. /**
  90630. * Stop all animations
  90631. * @returns the animation group
  90632. */
  90633. stop(): AnimationGroup;
  90634. /**
  90635. * Set animation weight for all animatables
  90636. * @param weight defines the weight to use
  90637. * @return the animationGroup
  90638. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90639. */
  90640. setWeightForAllAnimatables(weight: number): AnimationGroup;
  90641. /**
  90642. * Synchronize and normalize all animatables with a source animatable
  90643. * @param root defines the root animatable to synchronize with
  90644. * @return the animationGroup
  90645. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90646. */
  90647. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  90648. /**
  90649. * Goes to a specific frame in this animation group
  90650. * @param frame the frame number to go to
  90651. * @return the animationGroup
  90652. */
  90653. goToFrame(frame: number): AnimationGroup;
  90654. /**
  90655. * Dispose all associated resources
  90656. */
  90657. dispose(): void;
  90658. private _checkAnimationGroupEnded;
  90659. /**
  90660. * Clone the current animation group and returns a copy
  90661. * @param newName defines the name of the new group
  90662. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  90663. * @returns the new aniamtion group
  90664. */
  90665. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  90666. /**
  90667. * Returns a new AnimationGroup object parsed from the source provided.
  90668. * @param parsedAnimationGroup defines the source
  90669. * @param scene defines the scene that will receive the animationGroup
  90670. * @returns a new AnimationGroup
  90671. */
  90672. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  90673. /**
  90674. * Returns the string "AnimationGroup"
  90675. * @returns "AnimationGroup"
  90676. */
  90677. getClassName(): string;
  90678. /**
  90679. * Creates a detailled string about the object
  90680. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  90681. * @returns a string representing the object
  90682. */
  90683. toString(fullDetails?: boolean): string;
  90684. }
  90685. }
  90686. declare module BABYLON {
  90687. /**
  90688. * Define an interface for all classes that will hold resources
  90689. */
  90690. export interface IDisposable {
  90691. /**
  90692. * Releases all held resources
  90693. */
  90694. dispose(): void;
  90695. }
  90696. /** Interface defining initialization parameters for Scene class */
  90697. export interface SceneOptions {
  90698. /**
  90699. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  90700. * It will improve performance when the number of geometries becomes important.
  90701. */
  90702. useGeometryUniqueIdsMap?: boolean;
  90703. /**
  90704. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  90705. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90706. */
  90707. useMaterialMeshMap?: boolean;
  90708. /**
  90709. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  90710. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90711. */
  90712. useClonedMeshhMap?: boolean;
  90713. }
  90714. /**
  90715. * Represents a scene to be rendered by the engine.
  90716. * @see http://doc.babylonjs.com/features/scene
  90717. */
  90718. export class Scene extends AbstractScene implements IAnimatable {
  90719. private static _uniqueIdCounter;
  90720. /** The fog is deactivated */
  90721. static readonly FOGMODE_NONE: number;
  90722. /** The fog density is following an exponential function */
  90723. static readonly FOGMODE_EXP: number;
  90724. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  90725. static readonly FOGMODE_EXP2: number;
  90726. /** The fog density is following a linear function. */
  90727. static readonly FOGMODE_LINEAR: number;
  90728. /**
  90729. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  90730. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90731. */
  90732. static MinDeltaTime: number;
  90733. /**
  90734. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  90735. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90736. */
  90737. static MaxDeltaTime: number;
  90738. /**
  90739. * Factory used to create the default material.
  90740. * @param name The name of the material to create
  90741. * @param scene The scene to create the material for
  90742. * @returns The default material
  90743. */
  90744. static DefaultMaterialFactory(scene: Scene): Material;
  90745. /**
  90746. * Factory used to create the a collision coordinator.
  90747. * @returns The collision coordinator
  90748. */
  90749. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  90750. /** @hidden */
  90751. readonly _isScene: boolean;
  90752. /**
  90753. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  90754. */
  90755. autoClear: boolean;
  90756. /**
  90757. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  90758. */
  90759. autoClearDepthAndStencil: boolean;
  90760. /**
  90761. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  90762. */
  90763. clearColor: Color4;
  90764. /**
  90765. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  90766. */
  90767. ambientColor: Color3;
  90768. /**
  90769. * This is use to store the default BRDF lookup for PBR materials in your scene.
  90770. * It should only be one of the following (if not the default embedded one):
  90771. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  90772. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  90773. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  90774. * The material properties need to be setup according to the type of texture in use.
  90775. */
  90776. environmentBRDFTexture: BaseTexture;
  90777. /** @hidden */
  90778. protected _environmentTexture: Nullable<BaseTexture>;
  90779. /**
  90780. * Texture used in all pbr material as the reflection texture.
  90781. * As in the majority of the scene they are the same (exception for multi room and so on),
  90782. * this is easier to reference from here than from all the materials.
  90783. */
  90784. /**
  90785. * Texture used in all pbr material as the reflection texture.
  90786. * As in the majority of the scene they are the same (exception for multi room and so on),
  90787. * this is easier to set here than in all the materials.
  90788. */
  90789. environmentTexture: Nullable<BaseTexture>;
  90790. /** @hidden */
  90791. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90792. /**
  90793. * Default image processing configuration used either in the rendering
  90794. * Forward main pass or through the imageProcessingPostProcess if present.
  90795. * As in the majority of the scene they are the same (exception for multi camera),
  90796. * this is easier to reference from here than from all the materials and post process.
  90797. *
  90798. * No setter as we it is a shared configuration, you can set the values instead.
  90799. */
  90800. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  90801. private _forceWireframe;
  90802. /**
  90803. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  90804. */
  90805. forceWireframe: boolean;
  90806. private _forcePointsCloud;
  90807. /**
  90808. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  90809. */
  90810. forcePointsCloud: boolean;
  90811. /**
  90812. * Gets or sets the active clipplane 1
  90813. */
  90814. clipPlane: Nullable<Plane>;
  90815. /**
  90816. * Gets or sets the active clipplane 2
  90817. */
  90818. clipPlane2: Nullable<Plane>;
  90819. /**
  90820. * Gets or sets the active clipplane 3
  90821. */
  90822. clipPlane3: Nullable<Plane>;
  90823. /**
  90824. * Gets or sets the active clipplane 4
  90825. */
  90826. clipPlane4: Nullable<Plane>;
  90827. /**
  90828. * Gets or sets a boolean indicating if animations are enabled
  90829. */
  90830. animationsEnabled: boolean;
  90831. private _animationPropertiesOverride;
  90832. /**
  90833. * Gets or sets the animation properties override
  90834. */
  90835. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90836. /**
  90837. * Gets or sets a boolean indicating if a constant deltatime has to be used
  90838. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  90839. */
  90840. useConstantAnimationDeltaTime: boolean;
  90841. /**
  90842. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  90843. * Please note that it requires to run a ray cast through the scene on every frame
  90844. */
  90845. constantlyUpdateMeshUnderPointer: boolean;
  90846. /**
  90847. * Defines the HTML cursor to use when hovering over interactive elements
  90848. */
  90849. hoverCursor: string;
  90850. /**
  90851. * Defines the HTML default cursor to use (empty by default)
  90852. */
  90853. defaultCursor: string;
  90854. /**
  90855. * This is used to call preventDefault() on pointer down
  90856. * in order to block unwanted artifacts like system double clicks
  90857. */
  90858. preventDefaultOnPointerDown: boolean;
  90859. /**
  90860. * This is used to call preventDefault() on pointer up
  90861. * in order to block unwanted artifacts like system double clicks
  90862. */
  90863. preventDefaultOnPointerUp: boolean;
  90864. /**
  90865. * Gets or sets user defined metadata
  90866. */
  90867. metadata: any;
  90868. /**
  90869. * For internal use only. Please do not use.
  90870. */
  90871. reservedDataStore: any;
  90872. /**
  90873. * Gets the name of the plugin used to load this scene (null by default)
  90874. */
  90875. loadingPluginName: string;
  90876. /**
  90877. * Use this array to add regular expressions used to disable offline support for specific urls
  90878. */
  90879. disableOfflineSupportExceptionRules: RegExp[];
  90880. /**
  90881. * An event triggered when the scene is disposed.
  90882. */
  90883. onDisposeObservable: Observable<Scene>;
  90884. private _onDisposeObserver;
  90885. /** Sets a function to be executed when this scene is disposed. */
  90886. onDispose: () => void;
  90887. /**
  90888. * An event triggered before rendering the scene (right after animations and physics)
  90889. */
  90890. onBeforeRenderObservable: Observable<Scene>;
  90891. private _onBeforeRenderObserver;
  90892. /** Sets a function to be executed before rendering this scene */
  90893. beforeRender: Nullable<() => void>;
  90894. /**
  90895. * An event triggered after rendering the scene
  90896. */
  90897. onAfterRenderObservable: Observable<Scene>;
  90898. private _onAfterRenderObserver;
  90899. /** Sets a function to be executed after rendering this scene */
  90900. afterRender: Nullable<() => void>;
  90901. /**
  90902. * An event triggered before animating the scene
  90903. */
  90904. onBeforeAnimationsObservable: Observable<Scene>;
  90905. /**
  90906. * An event triggered after animations processing
  90907. */
  90908. onAfterAnimationsObservable: Observable<Scene>;
  90909. /**
  90910. * An event triggered before draw calls are ready to be sent
  90911. */
  90912. onBeforeDrawPhaseObservable: Observable<Scene>;
  90913. /**
  90914. * An event triggered after draw calls have been sent
  90915. */
  90916. onAfterDrawPhaseObservable: Observable<Scene>;
  90917. /**
  90918. * An event triggered when the scene is ready
  90919. */
  90920. onReadyObservable: Observable<Scene>;
  90921. /**
  90922. * An event triggered before rendering a camera
  90923. */
  90924. onBeforeCameraRenderObservable: Observable<Camera>;
  90925. private _onBeforeCameraRenderObserver;
  90926. /** Sets a function to be executed before rendering a camera*/
  90927. beforeCameraRender: () => void;
  90928. /**
  90929. * An event triggered after rendering a camera
  90930. */
  90931. onAfterCameraRenderObservable: Observable<Camera>;
  90932. private _onAfterCameraRenderObserver;
  90933. /** Sets a function to be executed after rendering a camera*/
  90934. afterCameraRender: () => void;
  90935. /**
  90936. * An event triggered when active meshes evaluation is about to start
  90937. */
  90938. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  90939. /**
  90940. * An event triggered when active meshes evaluation is done
  90941. */
  90942. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  90943. /**
  90944. * An event triggered when particles rendering is about to start
  90945. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90946. */
  90947. onBeforeParticlesRenderingObservable: Observable<Scene>;
  90948. /**
  90949. * An event triggered when particles rendering is done
  90950. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90951. */
  90952. onAfterParticlesRenderingObservable: Observable<Scene>;
  90953. /**
  90954. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  90955. */
  90956. onDataLoadedObservable: Observable<Scene>;
  90957. /**
  90958. * An event triggered when a camera is created
  90959. */
  90960. onNewCameraAddedObservable: Observable<Camera>;
  90961. /**
  90962. * An event triggered when a camera is removed
  90963. */
  90964. onCameraRemovedObservable: Observable<Camera>;
  90965. /**
  90966. * An event triggered when a light is created
  90967. */
  90968. onNewLightAddedObservable: Observable<Light>;
  90969. /**
  90970. * An event triggered when a light is removed
  90971. */
  90972. onLightRemovedObservable: Observable<Light>;
  90973. /**
  90974. * An event triggered when a geometry is created
  90975. */
  90976. onNewGeometryAddedObservable: Observable<Geometry>;
  90977. /**
  90978. * An event triggered when a geometry is removed
  90979. */
  90980. onGeometryRemovedObservable: Observable<Geometry>;
  90981. /**
  90982. * An event triggered when a transform node is created
  90983. */
  90984. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  90985. /**
  90986. * An event triggered when a transform node is removed
  90987. */
  90988. onTransformNodeRemovedObservable: Observable<TransformNode>;
  90989. /**
  90990. * An event triggered when a mesh is created
  90991. */
  90992. onNewMeshAddedObservable: Observable<AbstractMesh>;
  90993. /**
  90994. * An event triggered when a mesh is removed
  90995. */
  90996. onMeshRemovedObservable: Observable<AbstractMesh>;
  90997. /**
  90998. * An event triggered when a skeleton is created
  90999. */
  91000. onNewSkeletonAddedObservable: Observable<Skeleton>;
  91001. /**
  91002. * An event triggered when a skeleton is removed
  91003. */
  91004. onSkeletonRemovedObservable: Observable<Skeleton>;
  91005. /**
  91006. * An event triggered when a material is created
  91007. */
  91008. onNewMaterialAddedObservable: Observable<Material>;
  91009. /**
  91010. * An event triggered when a material is removed
  91011. */
  91012. onMaterialRemovedObservable: Observable<Material>;
  91013. /**
  91014. * An event triggered when a texture is created
  91015. */
  91016. onNewTextureAddedObservable: Observable<BaseTexture>;
  91017. /**
  91018. * An event triggered when a texture is removed
  91019. */
  91020. onTextureRemovedObservable: Observable<BaseTexture>;
  91021. /**
  91022. * An event triggered when render targets are about to be rendered
  91023. * Can happen multiple times per frame.
  91024. */
  91025. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  91026. /**
  91027. * An event triggered when render targets were rendered.
  91028. * Can happen multiple times per frame.
  91029. */
  91030. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  91031. /**
  91032. * An event triggered before calculating deterministic simulation step
  91033. */
  91034. onBeforeStepObservable: Observable<Scene>;
  91035. /**
  91036. * An event triggered after calculating deterministic simulation step
  91037. */
  91038. onAfterStepObservable: Observable<Scene>;
  91039. /**
  91040. * An event triggered when the activeCamera property is updated
  91041. */
  91042. onActiveCameraChanged: Observable<Scene>;
  91043. /**
  91044. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  91045. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91046. * 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)
  91047. */
  91048. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91049. /**
  91050. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  91051. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91052. * 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)
  91053. */
  91054. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91055. /**
  91056. * This Observable will when a mesh has been imported into the scene.
  91057. */
  91058. onMeshImportedObservable: Observable<AbstractMesh>;
  91059. /**
  91060. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  91061. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  91062. */
  91063. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  91064. /** @hidden */
  91065. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  91066. /**
  91067. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  91068. */
  91069. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  91070. /**
  91071. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  91072. */
  91073. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  91074. /**
  91075. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  91076. */
  91077. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  91078. private _onPointerMove;
  91079. private _onPointerDown;
  91080. private _onPointerUp;
  91081. /** Callback called when a pointer move is detected */
  91082. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91083. /** Callback called when a pointer down is detected */
  91084. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91085. /** Callback called when a pointer up is detected */
  91086. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  91087. /** Callback called when a pointer pick is detected */
  91088. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  91089. /**
  91090. * 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).
  91091. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  91092. */
  91093. onPrePointerObservable: Observable<PointerInfoPre>;
  91094. /**
  91095. * Observable event triggered each time an input event is received from the rendering canvas
  91096. */
  91097. onPointerObservable: Observable<PointerInfo>;
  91098. /**
  91099. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  91100. */
  91101. readonly unTranslatedPointer: Vector2;
  91102. /** The distance in pixel that you have to move to prevent some events */
  91103. static DragMovementThreshold: number;
  91104. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91105. static LongPressDelay: number;
  91106. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91107. static DoubleClickDelay: number;
  91108. /** If you need to check double click without raising a single click at first click, enable this flag */
  91109. static ExclusiveDoubleClickMode: boolean;
  91110. private _initClickEvent;
  91111. private _initActionManager;
  91112. private _delayedSimpleClick;
  91113. private _delayedSimpleClickTimeout;
  91114. private _previousDelayedSimpleClickTimeout;
  91115. private _meshPickProceed;
  91116. private _previousButtonPressed;
  91117. private _currentPickResult;
  91118. private _previousPickResult;
  91119. private _totalPointersPressed;
  91120. private _doubleClickOccured;
  91121. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91122. cameraToUseForPointers: Nullable<Camera>;
  91123. private _pointerX;
  91124. private _pointerY;
  91125. private _unTranslatedPointerX;
  91126. private _unTranslatedPointerY;
  91127. private _startingPointerPosition;
  91128. private _previousStartingPointerPosition;
  91129. private _startingPointerTime;
  91130. private _previousStartingPointerTime;
  91131. private _pointerCaptures;
  91132. private _timeAccumulator;
  91133. private _currentStepId;
  91134. private _currentInternalStep;
  91135. /** @hidden */
  91136. _mirroredCameraPosition: Nullable<Vector3>;
  91137. /**
  91138. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  91139. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  91140. */
  91141. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  91142. /**
  91143. * Observable event triggered each time an keyboard event is received from the hosting window
  91144. */
  91145. onKeyboardObservable: Observable<KeyboardInfo>;
  91146. private _onKeyDown;
  91147. private _onKeyUp;
  91148. private _onCanvasFocusObserver;
  91149. private _onCanvasBlurObserver;
  91150. private _useRightHandedSystem;
  91151. /**
  91152. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  91153. */
  91154. useRightHandedSystem: boolean;
  91155. /**
  91156. * Sets the step Id used by deterministic lock step
  91157. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91158. * @param newStepId defines the step Id
  91159. */
  91160. setStepId(newStepId: number): void;
  91161. /**
  91162. * Gets the step Id used by deterministic lock step
  91163. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91164. * @returns the step Id
  91165. */
  91166. getStepId(): number;
  91167. /**
  91168. * Gets the internal step used by deterministic lock step
  91169. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91170. * @returns the internal step
  91171. */
  91172. getInternalStep(): number;
  91173. private _fogEnabled;
  91174. /**
  91175. * Gets or sets a boolean indicating if fog is enabled on this scene
  91176. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91177. * (Default is true)
  91178. */
  91179. fogEnabled: boolean;
  91180. private _fogMode;
  91181. /**
  91182. * Gets or sets the fog mode to use
  91183. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91184. * | mode | value |
  91185. * | --- | --- |
  91186. * | FOGMODE_NONE | 0 |
  91187. * | FOGMODE_EXP | 1 |
  91188. * | FOGMODE_EXP2 | 2 |
  91189. * | FOGMODE_LINEAR | 3 |
  91190. */
  91191. fogMode: number;
  91192. /**
  91193. * Gets or sets the fog color to use
  91194. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91195. * (Default is Color3(0.2, 0.2, 0.3))
  91196. */
  91197. fogColor: Color3;
  91198. /**
  91199. * Gets or sets the fog density to use
  91200. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91201. * (Default is 0.1)
  91202. */
  91203. fogDensity: number;
  91204. /**
  91205. * Gets or sets the fog start distance to use
  91206. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91207. * (Default is 0)
  91208. */
  91209. fogStart: number;
  91210. /**
  91211. * Gets or sets the fog end distance to use
  91212. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91213. * (Default is 1000)
  91214. */
  91215. fogEnd: number;
  91216. private _shadowsEnabled;
  91217. /**
  91218. * Gets or sets a boolean indicating if shadows are enabled on this scene
  91219. */
  91220. shadowsEnabled: boolean;
  91221. private _lightsEnabled;
  91222. /**
  91223. * Gets or sets a boolean indicating if lights are enabled on this scene
  91224. */
  91225. lightsEnabled: boolean;
  91226. /** All of the active cameras added to this scene. */
  91227. activeCameras: Camera[];
  91228. /** @hidden */
  91229. _activeCamera: Nullable<Camera>;
  91230. /** Gets or sets the current active camera */
  91231. activeCamera: Nullable<Camera>;
  91232. private _defaultMaterial;
  91233. /** The default material used on meshes when no material is affected */
  91234. /** The default material used on meshes when no material is affected */
  91235. defaultMaterial: Material;
  91236. private _texturesEnabled;
  91237. /**
  91238. * Gets or sets a boolean indicating if textures are enabled on this scene
  91239. */
  91240. texturesEnabled: boolean;
  91241. /**
  91242. * Gets or sets a boolean indicating if particles are enabled on this scene
  91243. */
  91244. particlesEnabled: boolean;
  91245. /**
  91246. * Gets or sets a boolean indicating if sprites are enabled on this scene
  91247. */
  91248. spritesEnabled: boolean;
  91249. private _skeletonsEnabled;
  91250. /**
  91251. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  91252. */
  91253. skeletonsEnabled: boolean;
  91254. /**
  91255. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  91256. */
  91257. lensFlaresEnabled: boolean;
  91258. /**
  91259. * Gets or sets a boolean indicating if collisions are enabled on this scene
  91260. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91261. */
  91262. collisionsEnabled: boolean;
  91263. private _collisionCoordinator;
  91264. /** @hidden */
  91265. readonly collisionCoordinator: ICollisionCoordinator;
  91266. /**
  91267. * Defines the gravity applied to this scene (used only for collisions)
  91268. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91269. */
  91270. gravity: Vector3;
  91271. /**
  91272. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  91273. */
  91274. postProcessesEnabled: boolean;
  91275. /**
  91276. * The list of postprocesses added to the scene
  91277. */
  91278. postProcesses: PostProcess[];
  91279. /**
  91280. * Gets the current postprocess manager
  91281. */
  91282. postProcessManager: PostProcessManager;
  91283. /**
  91284. * Gets or sets a boolean indicating if render targets are enabled on this scene
  91285. */
  91286. renderTargetsEnabled: boolean;
  91287. /**
  91288. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  91289. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  91290. */
  91291. dumpNextRenderTargets: boolean;
  91292. /**
  91293. * The list of user defined render targets added to the scene
  91294. */
  91295. customRenderTargets: RenderTargetTexture[];
  91296. /**
  91297. * Defines if texture loading must be delayed
  91298. * If true, textures will only be loaded when they need to be rendered
  91299. */
  91300. useDelayedTextureLoading: boolean;
  91301. /**
  91302. * Gets the list of meshes imported to the scene through SceneLoader
  91303. */
  91304. importedMeshesFiles: String[];
  91305. /**
  91306. * Gets or sets a boolean indicating if probes are enabled on this scene
  91307. */
  91308. probesEnabled: boolean;
  91309. /**
  91310. * Gets or sets the current offline provider to use to store scene data
  91311. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  91312. */
  91313. offlineProvider: IOfflineProvider;
  91314. /**
  91315. * Gets or sets the action manager associated with the scene
  91316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91317. */
  91318. actionManager: AbstractActionManager;
  91319. private _meshesForIntersections;
  91320. /**
  91321. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  91322. */
  91323. proceduralTexturesEnabled: boolean;
  91324. private _engine;
  91325. private _totalVertices;
  91326. /** @hidden */
  91327. _activeIndices: PerfCounter;
  91328. /** @hidden */
  91329. _activeParticles: PerfCounter;
  91330. /** @hidden */
  91331. _activeBones: PerfCounter;
  91332. private _animationRatio;
  91333. /** @hidden */
  91334. _animationTimeLast: number;
  91335. /** @hidden */
  91336. _animationTime: number;
  91337. /**
  91338. * Gets or sets a general scale for animation speed
  91339. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  91340. */
  91341. animationTimeScale: number;
  91342. /** @hidden */
  91343. _cachedMaterial: Nullable<Material>;
  91344. /** @hidden */
  91345. _cachedEffect: Nullable<Effect>;
  91346. /** @hidden */
  91347. _cachedVisibility: Nullable<number>;
  91348. private _renderId;
  91349. private _frameId;
  91350. private _executeWhenReadyTimeoutId;
  91351. private _intermediateRendering;
  91352. private _viewUpdateFlag;
  91353. private _projectionUpdateFlag;
  91354. /** @hidden */
  91355. _toBeDisposed: Nullable<IDisposable>[];
  91356. private _activeRequests;
  91357. /** @hidden */
  91358. _pendingData: any[];
  91359. private _isDisposed;
  91360. /**
  91361. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  91362. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  91363. */
  91364. dispatchAllSubMeshesOfActiveMeshes: boolean;
  91365. private _activeMeshes;
  91366. private _processedMaterials;
  91367. private _renderTargets;
  91368. /** @hidden */
  91369. _activeParticleSystems: SmartArray<IParticleSystem>;
  91370. private _activeSkeletons;
  91371. private _softwareSkinnedMeshes;
  91372. private _renderingManager;
  91373. /** @hidden */
  91374. _activeAnimatables: Animatable[];
  91375. private _transformMatrix;
  91376. private _sceneUbo;
  91377. /** @hidden */
  91378. _viewMatrix: Matrix;
  91379. private _projectionMatrix;
  91380. private _wheelEventName;
  91381. /** @hidden */
  91382. _forcedViewPosition: Nullable<Vector3>;
  91383. /** @hidden */
  91384. _frustumPlanes: Plane[];
  91385. /**
  91386. * Gets the list of frustum planes (built from the active camera)
  91387. */
  91388. readonly frustumPlanes: Plane[];
  91389. /**
  91390. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  91391. * This is useful if there are more lights that the maximum simulteanous authorized
  91392. */
  91393. requireLightSorting: boolean;
  91394. /** @hidden */
  91395. readonly useMaterialMeshMap: boolean;
  91396. /** @hidden */
  91397. readonly useClonedMeshhMap: boolean;
  91398. private _pointerOverMesh;
  91399. private _pickedDownMesh;
  91400. private _pickedUpMesh;
  91401. private _externalData;
  91402. private _uid;
  91403. /**
  91404. * @hidden
  91405. * Backing store of defined scene components.
  91406. */
  91407. _components: ISceneComponent[];
  91408. /**
  91409. * @hidden
  91410. * Backing store of defined scene components.
  91411. */
  91412. _serializableComponents: ISceneSerializableComponent[];
  91413. /**
  91414. * List of components to register on the next registration step.
  91415. */
  91416. private _transientComponents;
  91417. /**
  91418. * Registers the transient components if needed.
  91419. */
  91420. private _registerTransientComponents;
  91421. /**
  91422. * @hidden
  91423. * Add a component to the scene.
  91424. * Note that the ccomponent could be registered on th next frame if this is called after
  91425. * the register component stage.
  91426. * @param component Defines the component to add to the scene
  91427. */
  91428. _addComponent(component: ISceneComponent): void;
  91429. /**
  91430. * @hidden
  91431. * Gets a component from the scene.
  91432. * @param name defines the name of the component to retrieve
  91433. * @returns the component or null if not present
  91434. */
  91435. _getComponent(name: string): Nullable<ISceneComponent>;
  91436. /**
  91437. * @hidden
  91438. * Defines the actions happening before camera updates.
  91439. */
  91440. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  91441. /**
  91442. * @hidden
  91443. * Defines the actions happening before clear the canvas.
  91444. */
  91445. _beforeClearStage: Stage<SimpleStageAction>;
  91446. /**
  91447. * @hidden
  91448. * Defines the actions when collecting render targets for the frame.
  91449. */
  91450. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91451. /**
  91452. * @hidden
  91453. * Defines the actions happening for one camera in the frame.
  91454. */
  91455. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91456. /**
  91457. * @hidden
  91458. * Defines the actions happening during the per mesh ready checks.
  91459. */
  91460. _isReadyForMeshStage: Stage<MeshStageAction>;
  91461. /**
  91462. * @hidden
  91463. * Defines the actions happening before evaluate active mesh checks.
  91464. */
  91465. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  91466. /**
  91467. * @hidden
  91468. * Defines the actions happening during the evaluate sub mesh checks.
  91469. */
  91470. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  91471. /**
  91472. * @hidden
  91473. * Defines the actions happening during the active mesh stage.
  91474. */
  91475. _activeMeshStage: Stage<ActiveMeshStageAction>;
  91476. /**
  91477. * @hidden
  91478. * Defines the actions happening during the per camera render target step.
  91479. */
  91480. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  91481. /**
  91482. * @hidden
  91483. * Defines the actions happening just before the active camera is drawing.
  91484. */
  91485. _beforeCameraDrawStage: Stage<CameraStageAction>;
  91486. /**
  91487. * @hidden
  91488. * Defines the actions happening just before a render target is drawing.
  91489. */
  91490. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91491. /**
  91492. * @hidden
  91493. * Defines the actions happening just before a rendering group is drawing.
  91494. */
  91495. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91496. /**
  91497. * @hidden
  91498. * Defines the actions happening just before a mesh is drawing.
  91499. */
  91500. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91501. /**
  91502. * @hidden
  91503. * Defines the actions happening just after a mesh has been drawn.
  91504. */
  91505. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91506. /**
  91507. * @hidden
  91508. * Defines the actions happening just after a rendering group has been drawn.
  91509. */
  91510. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91511. /**
  91512. * @hidden
  91513. * Defines the actions happening just after the active camera has been drawn.
  91514. */
  91515. _afterCameraDrawStage: Stage<CameraStageAction>;
  91516. /**
  91517. * @hidden
  91518. * Defines the actions happening just after a render target has been drawn.
  91519. */
  91520. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91521. /**
  91522. * @hidden
  91523. * Defines the actions happening just after rendering all cameras and computing intersections.
  91524. */
  91525. _afterRenderStage: Stage<SimpleStageAction>;
  91526. /**
  91527. * @hidden
  91528. * Defines the actions happening when a pointer move event happens.
  91529. */
  91530. _pointerMoveStage: Stage<PointerMoveStageAction>;
  91531. /**
  91532. * @hidden
  91533. * Defines the actions happening when a pointer down event happens.
  91534. */
  91535. _pointerDownStage: Stage<PointerUpDownStageAction>;
  91536. /**
  91537. * @hidden
  91538. * Defines the actions happening when a pointer up event happens.
  91539. */
  91540. _pointerUpStage: Stage<PointerUpDownStageAction>;
  91541. /**
  91542. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  91543. */
  91544. private geometriesByUniqueId;
  91545. /**
  91546. * Creates a new Scene
  91547. * @param engine defines the engine to use to render this scene
  91548. * @param options defines the scene options
  91549. */
  91550. constructor(engine: Engine, options?: SceneOptions);
  91551. /**
  91552. * Gets a string idenfifying the name of the class
  91553. * @returns "Scene" string
  91554. */
  91555. getClassName(): string;
  91556. private _defaultMeshCandidates;
  91557. /**
  91558. * @hidden
  91559. */
  91560. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  91561. private _defaultSubMeshCandidates;
  91562. /**
  91563. * @hidden
  91564. */
  91565. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  91566. /**
  91567. * Sets the default candidate providers for the scene.
  91568. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  91569. * and getCollidingSubMeshCandidates to their default function
  91570. */
  91571. setDefaultCandidateProviders(): void;
  91572. /**
  91573. * Gets the mesh that is currently under the pointer
  91574. */
  91575. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91576. /**
  91577. * Gets or sets the current on-screen X position of the pointer
  91578. */
  91579. pointerX: number;
  91580. /**
  91581. * Gets or sets the current on-screen Y position of the pointer
  91582. */
  91583. pointerY: number;
  91584. /**
  91585. * Gets the cached material (ie. the latest rendered one)
  91586. * @returns the cached material
  91587. */
  91588. getCachedMaterial(): Nullable<Material>;
  91589. /**
  91590. * Gets the cached effect (ie. the latest rendered one)
  91591. * @returns the cached effect
  91592. */
  91593. getCachedEffect(): Nullable<Effect>;
  91594. /**
  91595. * Gets the cached visibility state (ie. the latest rendered one)
  91596. * @returns the cached visibility state
  91597. */
  91598. getCachedVisibility(): Nullable<number>;
  91599. /**
  91600. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  91601. * @param material defines the current material
  91602. * @param effect defines the current effect
  91603. * @param visibility defines the current visibility state
  91604. * @returns true if one parameter is not cached
  91605. */
  91606. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  91607. /**
  91608. * Gets the engine associated with the scene
  91609. * @returns an Engine
  91610. */
  91611. getEngine(): Engine;
  91612. /**
  91613. * Gets the total number of vertices rendered per frame
  91614. * @returns the total number of vertices rendered per frame
  91615. */
  91616. getTotalVertices(): number;
  91617. /**
  91618. * Gets the performance counter for total vertices
  91619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91620. */
  91621. readonly totalVerticesPerfCounter: PerfCounter;
  91622. /**
  91623. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  91624. * @returns the total number of active indices rendered per frame
  91625. */
  91626. getActiveIndices(): number;
  91627. /**
  91628. * Gets the performance counter for active indices
  91629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91630. */
  91631. readonly totalActiveIndicesPerfCounter: PerfCounter;
  91632. /**
  91633. * Gets the total number of active particles rendered per frame
  91634. * @returns the total number of active particles rendered per frame
  91635. */
  91636. getActiveParticles(): number;
  91637. /**
  91638. * Gets the performance counter for active particles
  91639. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91640. */
  91641. readonly activeParticlesPerfCounter: PerfCounter;
  91642. /**
  91643. * Gets the total number of active bones rendered per frame
  91644. * @returns the total number of active bones rendered per frame
  91645. */
  91646. getActiveBones(): number;
  91647. /**
  91648. * Gets the performance counter for active bones
  91649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91650. */
  91651. readonly activeBonesPerfCounter: PerfCounter;
  91652. /**
  91653. * Gets the array of active meshes
  91654. * @returns an array of AbstractMesh
  91655. */
  91656. getActiveMeshes(): SmartArray<AbstractMesh>;
  91657. /**
  91658. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  91659. * @returns a number
  91660. */
  91661. getAnimationRatio(): number;
  91662. /**
  91663. * Gets an unique Id for the current render phase
  91664. * @returns a number
  91665. */
  91666. getRenderId(): number;
  91667. /**
  91668. * Gets an unique Id for the current frame
  91669. * @returns a number
  91670. */
  91671. getFrameId(): number;
  91672. /** Call this function if you want to manually increment the render Id*/
  91673. incrementRenderId(): void;
  91674. private _updatePointerPosition;
  91675. private _createUbo;
  91676. private _setRayOnPointerInfo;
  91677. /**
  91678. * Use this method to simulate a pointer move on a mesh
  91679. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91680. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91681. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91682. * @returns the current scene
  91683. */
  91684. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91685. private _processPointerMove;
  91686. private _checkPrePointerObservable;
  91687. /**
  91688. * Use this method to simulate a pointer down on a mesh
  91689. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91690. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91691. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91692. * @returns the current scene
  91693. */
  91694. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91695. private _processPointerDown;
  91696. /**
  91697. * Use this method to simulate a pointer up on a mesh
  91698. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91699. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91700. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91701. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91702. * @returns the current scene
  91703. */
  91704. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  91705. private _processPointerUp;
  91706. /**
  91707. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91708. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91709. * @returns true if the pointer was captured
  91710. */
  91711. isPointerCaptured(pointerId?: number): boolean;
  91712. /** @hidden */
  91713. _isPointerSwiping(): boolean;
  91714. /**
  91715. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91716. * @param attachUp defines if you want to attach events to pointerup
  91717. * @param attachDown defines if you want to attach events to pointerdown
  91718. * @param attachMove defines if you want to attach events to pointermove
  91719. */
  91720. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91721. /** Detaches all event handlers*/
  91722. detachControl(): void;
  91723. /**
  91724. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  91725. * Delay loaded resources are not taking in account
  91726. * @return true if all required resources are ready
  91727. */
  91728. isReady(): boolean;
  91729. /** Resets all cached information relative to material (including effect and visibility) */
  91730. resetCachedMaterial(): void;
  91731. /**
  91732. * Registers a function to be called before every frame render
  91733. * @param func defines the function to register
  91734. */
  91735. registerBeforeRender(func: () => void): void;
  91736. /**
  91737. * Unregisters a function called before every frame render
  91738. * @param func defines the function to unregister
  91739. */
  91740. unregisterBeforeRender(func: () => void): void;
  91741. /**
  91742. * Registers a function to be called after every frame render
  91743. * @param func defines the function to register
  91744. */
  91745. registerAfterRender(func: () => void): void;
  91746. /**
  91747. * Unregisters a function called after every frame render
  91748. * @param func defines the function to unregister
  91749. */
  91750. unregisterAfterRender(func: () => void): void;
  91751. private _executeOnceBeforeRender;
  91752. /**
  91753. * The provided function will run before render once and will be disposed afterwards.
  91754. * A timeout delay can be provided so that the function will be executed in N ms.
  91755. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  91756. * @param func The function to be executed.
  91757. * @param timeout optional delay in ms
  91758. */
  91759. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  91760. /** @hidden */
  91761. _addPendingData(data: any): void;
  91762. /** @hidden */
  91763. _removePendingData(data: any): void;
  91764. /**
  91765. * Returns the number of items waiting to be loaded
  91766. * @returns the number of items waiting to be loaded
  91767. */
  91768. getWaitingItemsCount(): number;
  91769. /**
  91770. * Returns a boolean indicating if the scene is still loading data
  91771. */
  91772. readonly isLoading: boolean;
  91773. /**
  91774. * Registers a function to be executed when the scene is ready
  91775. * @param {Function} func - the function to be executed
  91776. */
  91777. executeWhenReady(func: () => void): void;
  91778. /**
  91779. * Returns a promise that resolves when the scene is ready
  91780. * @returns A promise that resolves when the scene is ready
  91781. */
  91782. whenReadyAsync(): Promise<void>;
  91783. /** @hidden */
  91784. _checkIsReady(): void;
  91785. /**
  91786. * Gets all animatable attached to the scene
  91787. */
  91788. readonly animatables: Animatable[];
  91789. /**
  91790. * Resets the last animation time frame.
  91791. * Useful to override when animations start running when loading a scene for the first time.
  91792. */
  91793. resetLastAnimationTimeFrame(): void;
  91794. /**
  91795. * Gets the current view matrix
  91796. * @returns a Matrix
  91797. */
  91798. getViewMatrix(): Matrix;
  91799. /**
  91800. * Gets the current projection matrix
  91801. * @returns a Matrix
  91802. */
  91803. getProjectionMatrix(): Matrix;
  91804. /**
  91805. * Gets the current transform matrix
  91806. * @returns a Matrix made of View * Projection
  91807. */
  91808. getTransformMatrix(): Matrix;
  91809. /**
  91810. * Sets the current transform matrix
  91811. * @param viewL defines the View matrix to use
  91812. * @param projectionL defines the Projection matrix to use
  91813. * @param viewR defines the right View matrix to use (if provided)
  91814. * @param projectionR defines the right Projection matrix to use (if provided)
  91815. */
  91816. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  91817. /**
  91818. * Gets the uniform buffer used to store scene data
  91819. * @returns a UniformBuffer
  91820. */
  91821. getSceneUniformBuffer(): UniformBuffer;
  91822. /**
  91823. * Gets an unique (relatively to the current scene) Id
  91824. * @returns an unique number for the scene
  91825. */
  91826. getUniqueId(): number;
  91827. /**
  91828. * Add a mesh to the list of scene's meshes
  91829. * @param newMesh defines the mesh to add
  91830. * @param recursive if all child meshes should also be added to the scene
  91831. */
  91832. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  91833. /**
  91834. * Remove a mesh for the list of scene's meshes
  91835. * @param toRemove defines the mesh to remove
  91836. * @param recursive if all child meshes should also be removed from the scene
  91837. * @returns the index where the mesh was in the mesh list
  91838. */
  91839. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  91840. /**
  91841. * Add a transform node to the list of scene's transform nodes
  91842. * @param newTransformNode defines the transform node to add
  91843. */
  91844. addTransformNode(newTransformNode: TransformNode): void;
  91845. /**
  91846. * Remove a transform node for the list of scene's transform nodes
  91847. * @param toRemove defines the transform node to remove
  91848. * @returns the index where the transform node was in the transform node list
  91849. */
  91850. removeTransformNode(toRemove: TransformNode): number;
  91851. /**
  91852. * Remove a skeleton for the list of scene's skeletons
  91853. * @param toRemove defines the skeleton to remove
  91854. * @returns the index where the skeleton was in the skeleton list
  91855. */
  91856. removeSkeleton(toRemove: Skeleton): number;
  91857. /**
  91858. * Remove a morph target for the list of scene's morph targets
  91859. * @param toRemove defines the morph target to remove
  91860. * @returns the index where the morph target was in the morph target list
  91861. */
  91862. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  91863. /**
  91864. * Remove a light for the list of scene's lights
  91865. * @param toRemove defines the light to remove
  91866. * @returns the index where the light was in the light list
  91867. */
  91868. removeLight(toRemove: Light): number;
  91869. /**
  91870. * Remove a camera for the list of scene's cameras
  91871. * @param toRemove defines the camera to remove
  91872. * @returns the index where the camera was in the camera list
  91873. */
  91874. removeCamera(toRemove: Camera): number;
  91875. /**
  91876. * Remove a particle system for the list of scene's particle systems
  91877. * @param toRemove defines the particle system to remove
  91878. * @returns the index where the particle system was in the particle system list
  91879. */
  91880. removeParticleSystem(toRemove: IParticleSystem): number;
  91881. /**
  91882. * Remove a animation for the list of scene's animations
  91883. * @param toRemove defines the animation to remove
  91884. * @returns the index where the animation was in the animation list
  91885. */
  91886. removeAnimation(toRemove: Animation): number;
  91887. /**
  91888. * Removes the given animation group from this scene.
  91889. * @param toRemove The animation group to remove
  91890. * @returns The index of the removed animation group
  91891. */
  91892. removeAnimationGroup(toRemove: AnimationGroup): number;
  91893. /**
  91894. * Removes the given multi-material from this scene.
  91895. * @param toRemove The multi-material to remove
  91896. * @returns The index of the removed multi-material
  91897. */
  91898. removeMultiMaterial(toRemove: MultiMaterial): number;
  91899. /**
  91900. * Removes the given material from this scene.
  91901. * @param toRemove The material to remove
  91902. * @returns The index of the removed material
  91903. */
  91904. removeMaterial(toRemove: Material): number;
  91905. /**
  91906. * Removes the given action manager from this scene.
  91907. * @param toRemove The action manager to remove
  91908. * @returns The index of the removed action manager
  91909. */
  91910. removeActionManager(toRemove: AbstractActionManager): number;
  91911. /**
  91912. * Removes the given texture from this scene.
  91913. * @param toRemove The texture to remove
  91914. * @returns The index of the removed texture
  91915. */
  91916. removeTexture(toRemove: BaseTexture): number;
  91917. /**
  91918. * Adds the given light to this scene
  91919. * @param newLight The light to add
  91920. */
  91921. addLight(newLight: Light): void;
  91922. /**
  91923. * Sorts the list list based on light priorities
  91924. */
  91925. sortLightsByPriority(): void;
  91926. /**
  91927. * Adds the given camera to this scene
  91928. * @param newCamera The camera to add
  91929. */
  91930. addCamera(newCamera: Camera): void;
  91931. /**
  91932. * Adds the given skeleton to this scene
  91933. * @param newSkeleton The skeleton to add
  91934. */
  91935. addSkeleton(newSkeleton: Skeleton): void;
  91936. /**
  91937. * Adds the given particle system to this scene
  91938. * @param newParticleSystem The particle system to add
  91939. */
  91940. addParticleSystem(newParticleSystem: IParticleSystem): void;
  91941. /**
  91942. * Adds the given animation to this scene
  91943. * @param newAnimation The animation to add
  91944. */
  91945. addAnimation(newAnimation: Animation): void;
  91946. /**
  91947. * Adds the given animation group to this scene.
  91948. * @param newAnimationGroup The animation group to add
  91949. */
  91950. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  91951. /**
  91952. * Adds the given multi-material to this scene
  91953. * @param newMultiMaterial The multi-material to add
  91954. */
  91955. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  91956. /**
  91957. * Adds the given material to this scene
  91958. * @param newMaterial The material to add
  91959. */
  91960. addMaterial(newMaterial: Material): void;
  91961. /**
  91962. * Adds the given morph target to this scene
  91963. * @param newMorphTargetManager The morph target to add
  91964. */
  91965. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  91966. /**
  91967. * Adds the given geometry to this scene
  91968. * @param newGeometry The geometry to add
  91969. */
  91970. addGeometry(newGeometry: Geometry): void;
  91971. /**
  91972. * Adds the given action manager to this scene
  91973. * @param newActionManager The action manager to add
  91974. */
  91975. addActionManager(newActionManager: AbstractActionManager): void;
  91976. /**
  91977. * Adds the given texture to this scene.
  91978. * @param newTexture The texture to add
  91979. */
  91980. addTexture(newTexture: BaseTexture): void;
  91981. /**
  91982. * Switch active camera
  91983. * @param newCamera defines the new active camera
  91984. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  91985. */
  91986. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  91987. /**
  91988. * sets the active camera of the scene using its ID
  91989. * @param id defines the camera's ID
  91990. * @return the new active camera or null if none found.
  91991. */
  91992. setActiveCameraByID(id: string): Nullable<Camera>;
  91993. /**
  91994. * sets the active camera of the scene using its name
  91995. * @param name defines the camera's name
  91996. * @returns the new active camera or null if none found.
  91997. */
  91998. setActiveCameraByName(name: string): Nullable<Camera>;
  91999. /**
  92000. * get an animation group using its name
  92001. * @param name defines the material's name
  92002. * @return the animation group or null if none found.
  92003. */
  92004. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  92005. /**
  92006. * Get a material using its unique id
  92007. * @param uniqueId defines the material's unique id
  92008. * @return the material or null if none found.
  92009. */
  92010. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  92011. /**
  92012. * get a material using its id
  92013. * @param id defines the material's ID
  92014. * @return the material or null if none found.
  92015. */
  92016. getMaterialByID(id: string): Nullable<Material>;
  92017. /**
  92018. * Gets a material using its name
  92019. * @param name defines the material's name
  92020. * @return the material or null if none found.
  92021. */
  92022. getMaterialByName(name: string): Nullable<Material>;
  92023. /**
  92024. * Gets a camera using its id
  92025. * @param id defines the id to look for
  92026. * @returns the camera or null if not found
  92027. */
  92028. getCameraByID(id: string): Nullable<Camera>;
  92029. /**
  92030. * Gets a camera using its unique id
  92031. * @param uniqueId defines the unique id to look for
  92032. * @returns the camera or null if not found
  92033. */
  92034. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  92035. /**
  92036. * Gets a camera using its name
  92037. * @param name defines the camera's name
  92038. * @return the camera or null if none found.
  92039. */
  92040. getCameraByName(name: string): Nullable<Camera>;
  92041. /**
  92042. * Gets a bone using its id
  92043. * @param id defines the bone's id
  92044. * @return the bone or null if not found
  92045. */
  92046. getBoneByID(id: string): Nullable<Bone>;
  92047. /**
  92048. * Gets a bone using its id
  92049. * @param name defines the bone's name
  92050. * @return the bone or null if not found
  92051. */
  92052. getBoneByName(name: string): Nullable<Bone>;
  92053. /**
  92054. * Gets a light node using its name
  92055. * @param name defines the the light's name
  92056. * @return the light or null if none found.
  92057. */
  92058. getLightByName(name: string): Nullable<Light>;
  92059. /**
  92060. * Gets a light node using its id
  92061. * @param id defines the light's id
  92062. * @return the light or null if none found.
  92063. */
  92064. getLightByID(id: string): Nullable<Light>;
  92065. /**
  92066. * Gets a light node using its scene-generated unique ID
  92067. * @param uniqueId defines the light's unique id
  92068. * @return the light or null if none found.
  92069. */
  92070. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  92071. /**
  92072. * Gets a particle system by id
  92073. * @param id defines the particle system id
  92074. * @return the corresponding system or null if none found
  92075. */
  92076. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  92077. /**
  92078. * Gets a geometry using its ID
  92079. * @param id defines the geometry's id
  92080. * @return the geometry or null if none found.
  92081. */
  92082. getGeometryByID(id: string): Nullable<Geometry>;
  92083. private _getGeometryByUniqueID;
  92084. /**
  92085. * Add a new geometry to this scene
  92086. * @param geometry defines the geometry to be added to the scene.
  92087. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  92088. * @return a boolean defining if the geometry was added or not
  92089. */
  92090. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  92091. /**
  92092. * Removes an existing geometry
  92093. * @param geometry defines the geometry to be removed from the scene
  92094. * @return a boolean defining if the geometry was removed or not
  92095. */
  92096. removeGeometry(geometry: Geometry): boolean;
  92097. /**
  92098. * Gets the list of geometries attached to the scene
  92099. * @returns an array of Geometry
  92100. */
  92101. getGeometries(): Geometry[];
  92102. /**
  92103. * Gets the first added mesh found of a given ID
  92104. * @param id defines the id to search for
  92105. * @return the mesh found or null if not found at all
  92106. */
  92107. getMeshByID(id: string): Nullable<AbstractMesh>;
  92108. /**
  92109. * Gets a list of meshes using their id
  92110. * @param id defines the id to search for
  92111. * @returns a list of meshes
  92112. */
  92113. getMeshesByID(id: string): Array<AbstractMesh>;
  92114. /**
  92115. * Gets the first added transform node found of a given ID
  92116. * @param id defines the id to search for
  92117. * @return the found transform node or null if not found at all.
  92118. */
  92119. getTransformNodeByID(id: string): Nullable<TransformNode>;
  92120. /**
  92121. * Gets a transform node with its auto-generated unique id
  92122. * @param uniqueId efines the unique id to search for
  92123. * @return the found transform node or null if not found at all.
  92124. */
  92125. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  92126. /**
  92127. * Gets a list of transform nodes using their id
  92128. * @param id defines the id to search for
  92129. * @returns a list of transform nodes
  92130. */
  92131. getTransformNodesByID(id: string): Array<TransformNode>;
  92132. /**
  92133. * Gets a mesh with its auto-generated unique id
  92134. * @param uniqueId defines the unique id to search for
  92135. * @return the found mesh or null if not found at all.
  92136. */
  92137. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  92138. /**
  92139. * Gets a the last added mesh using a given id
  92140. * @param id defines the id to search for
  92141. * @return the found mesh or null if not found at all.
  92142. */
  92143. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  92144. /**
  92145. * Gets a the last added node (Mesh, Camera, Light) using a given id
  92146. * @param id defines the id to search for
  92147. * @return the found node or null if not found at all
  92148. */
  92149. getLastEntryByID(id: string): Nullable<Node>;
  92150. /**
  92151. * Gets a node (Mesh, Camera, Light) using a given id
  92152. * @param id defines the id to search for
  92153. * @return the found node or null if not found at all
  92154. */
  92155. getNodeByID(id: string): Nullable<Node>;
  92156. /**
  92157. * Gets a node (Mesh, Camera, Light) using a given name
  92158. * @param name defines the name to search for
  92159. * @return the found node or null if not found at all.
  92160. */
  92161. getNodeByName(name: string): Nullable<Node>;
  92162. /**
  92163. * Gets a mesh using a given name
  92164. * @param name defines the name to search for
  92165. * @return the found mesh or null if not found at all.
  92166. */
  92167. getMeshByName(name: string): Nullable<AbstractMesh>;
  92168. /**
  92169. * Gets a transform node using a given name
  92170. * @param name defines the name to search for
  92171. * @return the found transform node or null if not found at all.
  92172. */
  92173. getTransformNodeByName(name: string): Nullable<TransformNode>;
  92174. /**
  92175. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  92176. * @param id defines the id to search for
  92177. * @return the found skeleton or null if not found at all.
  92178. */
  92179. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  92180. /**
  92181. * Gets a skeleton using a given auto generated unique id
  92182. * @param uniqueId defines the unique id to search for
  92183. * @return the found skeleton or null if not found at all.
  92184. */
  92185. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  92186. /**
  92187. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  92188. * @param id defines the id to search for
  92189. * @return the found skeleton or null if not found at all.
  92190. */
  92191. getSkeletonById(id: string): Nullable<Skeleton>;
  92192. /**
  92193. * Gets a skeleton using a given name
  92194. * @param name defines the name to search for
  92195. * @return the found skeleton or null if not found at all.
  92196. */
  92197. getSkeletonByName(name: string): Nullable<Skeleton>;
  92198. /**
  92199. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  92200. * @param id defines the id to search for
  92201. * @return the found morph target manager or null if not found at all.
  92202. */
  92203. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  92204. /**
  92205. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  92206. * @param id defines the id to search for
  92207. * @return the found morph target or null if not found at all.
  92208. */
  92209. getMorphTargetById(id: string): Nullable<MorphTarget>;
  92210. /**
  92211. * Gets a boolean indicating if the given mesh is active
  92212. * @param mesh defines the mesh to look for
  92213. * @returns true if the mesh is in the active list
  92214. */
  92215. isActiveMesh(mesh: AbstractMesh): boolean;
  92216. /**
  92217. * Return a unique id as a string which can serve as an identifier for the scene
  92218. */
  92219. readonly uid: string;
  92220. /**
  92221. * Add an externaly attached data from its key.
  92222. * This method call will fail and return false, if such key already exists.
  92223. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92224. * @param key the unique key that identifies the data
  92225. * @param data the data object to associate to the key for this Engine instance
  92226. * @return true if no such key were already present and the data was added successfully, false otherwise
  92227. */
  92228. addExternalData<T>(key: string, data: T): boolean;
  92229. /**
  92230. * Get an externaly attached data from its key
  92231. * @param key the unique key that identifies the data
  92232. * @return the associated data, if present (can be null), or undefined if not present
  92233. */
  92234. getExternalData<T>(key: string): Nullable<T>;
  92235. /**
  92236. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92237. * @param key the unique key that identifies the data
  92238. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92239. * @return the associated data, can be null if the factory returned null.
  92240. */
  92241. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92242. /**
  92243. * Remove an externaly attached data from the Engine instance
  92244. * @param key the unique key that identifies the data
  92245. * @return true if the data was successfully removed, false if it doesn't exist
  92246. */
  92247. removeExternalData(key: string): boolean;
  92248. private _evaluateSubMesh;
  92249. /**
  92250. * Clear the processed materials smart array preventing retention point in material dispose.
  92251. */
  92252. freeProcessedMaterials(): void;
  92253. private _preventFreeActiveMeshesAndRenderingGroups;
  92254. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  92255. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  92256. * when disposing several meshes in a row or a hierarchy of meshes.
  92257. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  92258. */
  92259. blockfreeActiveMeshesAndRenderingGroups: boolean;
  92260. /**
  92261. * Clear the active meshes smart array preventing retention point in mesh dispose.
  92262. */
  92263. freeActiveMeshes(): void;
  92264. /**
  92265. * Clear the info related to rendering groups preventing retention points during dispose.
  92266. */
  92267. freeRenderingGroups(): void;
  92268. /** @hidden */
  92269. _isInIntermediateRendering(): boolean;
  92270. /**
  92271. * Lambda returning the list of potentially active meshes.
  92272. */
  92273. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  92274. /**
  92275. * Lambda returning the list of potentially active sub meshes.
  92276. */
  92277. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  92278. /**
  92279. * Lambda returning the list of potentially intersecting sub meshes.
  92280. */
  92281. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  92282. /**
  92283. * Lambda returning the list of potentially colliding sub meshes.
  92284. */
  92285. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  92286. private _activeMeshesFrozen;
  92287. /**
  92288. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  92289. * @returns the current scene
  92290. */
  92291. freezeActiveMeshes(): Scene;
  92292. /**
  92293. * Use this function to restart evaluating active meshes on every frame
  92294. * @returns the current scene
  92295. */
  92296. unfreezeActiveMeshes(): Scene;
  92297. private _evaluateActiveMeshes;
  92298. private _activeMesh;
  92299. /**
  92300. * Update the transform matrix to update from the current active camera
  92301. * @param force defines a boolean used to force the update even if cache is up to date
  92302. */
  92303. updateTransformMatrix(force?: boolean): void;
  92304. private _bindFrameBuffer;
  92305. /** @hidden */
  92306. _allowPostProcessClearColor: boolean;
  92307. /** @hidden */
  92308. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  92309. private _processSubCameras;
  92310. private _checkIntersections;
  92311. /** @hidden */
  92312. _advancePhysicsEngineStep(step: number): void;
  92313. /**
  92314. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  92315. */
  92316. getDeterministicFrameTime: () => number;
  92317. /** @hidden */
  92318. _animate(): void;
  92319. /**
  92320. * Render the scene
  92321. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  92322. */
  92323. render(updateCameras?: boolean): void;
  92324. /**
  92325. * Freeze all materials
  92326. * A frozen material will not be updatable but should be faster to render
  92327. */
  92328. freezeMaterials(): void;
  92329. /**
  92330. * Unfreeze all materials
  92331. * A frozen material will not be updatable but should be faster to render
  92332. */
  92333. unfreezeMaterials(): void;
  92334. /**
  92335. * Releases all held ressources
  92336. */
  92337. dispose(): void;
  92338. /**
  92339. * Gets if the scene is already disposed
  92340. */
  92341. readonly isDisposed: boolean;
  92342. /**
  92343. * Call this function to reduce memory footprint of the scene.
  92344. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  92345. */
  92346. clearCachedVertexData(): void;
  92347. /**
  92348. * This function will remove the local cached buffer data from texture.
  92349. * It will save memory but will prevent the texture from being rebuilt
  92350. */
  92351. cleanCachedTextureBuffer(): void;
  92352. /**
  92353. * Get the world extend vectors with an optional filter
  92354. *
  92355. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  92356. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  92357. */
  92358. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  92359. min: Vector3;
  92360. max: Vector3;
  92361. };
  92362. /**
  92363. * Creates a ray that can be used to pick in the scene
  92364. * @param x defines the x coordinate of the origin (on-screen)
  92365. * @param y defines the y coordinate of the origin (on-screen)
  92366. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92367. * @param camera defines the camera to use for the picking
  92368. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92369. * @returns a Ray
  92370. */
  92371. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  92372. /**
  92373. * Creates a ray that can be used to pick in the scene
  92374. * @param x defines the x coordinate of the origin (on-screen)
  92375. * @param y defines the y coordinate of the origin (on-screen)
  92376. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92377. * @param result defines the ray where to store the picking ray
  92378. * @param camera defines the camera to use for the picking
  92379. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92380. * @returns the current scene
  92381. */
  92382. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  92383. /**
  92384. * Creates a ray that can be used to pick in the scene
  92385. * @param x defines the x coordinate of the origin (on-screen)
  92386. * @param y defines the y coordinate of the origin (on-screen)
  92387. * @param camera defines the camera to use for the picking
  92388. * @returns a Ray
  92389. */
  92390. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  92391. /**
  92392. * Creates a ray that can be used to pick in the scene
  92393. * @param x defines the x coordinate of the origin (on-screen)
  92394. * @param y defines the y coordinate of the origin (on-screen)
  92395. * @param result defines the ray where to store the picking ray
  92396. * @param camera defines the camera to use for the picking
  92397. * @returns the current scene
  92398. */
  92399. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  92400. /** Launch a ray to try to pick a mesh in the scene
  92401. * @param x position on screen
  92402. * @param y position on screen
  92403. * @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
  92404. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  92405. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92406. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92407. * @returns a PickingInfo
  92408. */
  92409. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  92410. /** Use the given ray to pick a mesh in the scene
  92411. * @param ray The ray to use to pick meshes
  92412. * @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
  92413. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  92414. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92415. * @returns a PickingInfo
  92416. */
  92417. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92418. /**
  92419. * Launch a ray to try to pick a mesh in the scene
  92420. * @param x X position on screen
  92421. * @param y Y position on screen
  92422. * @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
  92423. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92424. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92425. * @returns an array of PickingInfo
  92426. */
  92427. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92428. /**
  92429. * Launch a ray to try to pick a mesh in the scene
  92430. * @param ray Ray to use
  92431. * @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
  92432. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92433. * @returns an array of PickingInfo
  92434. */
  92435. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92436. /**
  92437. * Force the value of meshUnderPointer
  92438. * @param mesh defines the mesh to use
  92439. */
  92440. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  92441. /**
  92442. * Gets the mesh under the pointer
  92443. * @returns a Mesh or null if no mesh is under the pointer
  92444. */
  92445. getPointerOverMesh(): Nullable<AbstractMesh>;
  92446. /** @hidden */
  92447. _rebuildGeometries(): void;
  92448. /** @hidden */
  92449. _rebuildTextures(): void;
  92450. private _getByTags;
  92451. /**
  92452. * Get a list of meshes by tags
  92453. * @param tagsQuery defines the tags query to use
  92454. * @param forEach defines a predicate used to filter results
  92455. * @returns an array of Mesh
  92456. */
  92457. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  92458. /**
  92459. * Get a list of cameras by tags
  92460. * @param tagsQuery defines the tags query to use
  92461. * @param forEach defines a predicate used to filter results
  92462. * @returns an array of Camera
  92463. */
  92464. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  92465. /**
  92466. * Get a list of lights by tags
  92467. * @param tagsQuery defines the tags query to use
  92468. * @param forEach defines a predicate used to filter results
  92469. * @returns an array of Light
  92470. */
  92471. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  92472. /**
  92473. * Get a list of materials by tags
  92474. * @param tagsQuery defines the tags query to use
  92475. * @param forEach defines a predicate used to filter results
  92476. * @returns an array of Material
  92477. */
  92478. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  92479. /**
  92480. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92481. * This allowed control for front to back rendering or reversly depending of the special needs.
  92482. *
  92483. * @param renderingGroupId The rendering group id corresponding to its index
  92484. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92485. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92486. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92487. */
  92488. 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;
  92489. /**
  92490. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92491. *
  92492. * @param renderingGroupId The rendering group id corresponding to its index
  92493. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92494. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92495. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92496. */
  92497. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92498. /**
  92499. * Gets the current auto clear configuration for one rendering group of the rendering
  92500. * manager.
  92501. * @param index the rendering group index to get the information for
  92502. * @returns The auto clear setup for the requested rendering group
  92503. */
  92504. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92505. private _blockMaterialDirtyMechanism;
  92506. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  92507. blockMaterialDirtyMechanism: boolean;
  92508. /**
  92509. * Will flag all materials as dirty to trigger new shader compilation
  92510. * @param flag defines the flag used to specify which material part must be marked as dirty
  92511. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  92512. */
  92513. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  92514. /** @hidden */
  92515. _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;
  92516. /** @hidden */
  92517. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92518. }
  92519. }
  92520. declare module BABYLON {
  92521. /**
  92522. * Set of assets to keep when moving a scene into an asset container.
  92523. */
  92524. export class KeepAssets extends AbstractScene {
  92525. }
  92526. /**
  92527. * Container with a set of assets that can be added or removed from a scene.
  92528. */
  92529. export class AssetContainer extends AbstractScene {
  92530. /**
  92531. * The scene the AssetContainer belongs to.
  92532. */
  92533. scene: Scene;
  92534. /**
  92535. * Instantiates an AssetContainer.
  92536. * @param scene The scene the AssetContainer belongs to.
  92537. */
  92538. constructor(scene: Scene);
  92539. /**
  92540. * Adds all the assets from the container to the scene.
  92541. */
  92542. addAllToScene(): void;
  92543. /**
  92544. * Removes all the assets in the container from the scene
  92545. */
  92546. removeAllFromScene(): void;
  92547. /**
  92548. * Disposes all the assets in the container
  92549. */
  92550. dispose(): void;
  92551. private _moveAssets;
  92552. /**
  92553. * Removes all the assets contained in the scene and adds them to the container.
  92554. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  92555. */
  92556. moveAllFromScene(keepAssets?: KeepAssets): void;
  92557. /**
  92558. * 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.
  92559. * @returns the root mesh
  92560. */
  92561. createRootMesh(): Mesh;
  92562. }
  92563. }
  92564. declare module BABYLON {
  92565. /**
  92566. * Defines how the parser contract is defined.
  92567. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  92568. */
  92569. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  92570. /**
  92571. * Defines how the individual parser contract is defined.
  92572. * These parser can parse an individual asset
  92573. */
  92574. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  92575. /**
  92576. * Base class of the scene acting as a container for the different elements composing a scene.
  92577. * This class is dynamically extended by the different components of the scene increasing
  92578. * flexibility and reducing coupling
  92579. */
  92580. export abstract class AbstractScene {
  92581. /**
  92582. * Stores the list of available parsers in the application.
  92583. */
  92584. private static _BabylonFileParsers;
  92585. /**
  92586. * Stores the list of available individual parsers in the application.
  92587. */
  92588. private static _IndividualBabylonFileParsers;
  92589. /**
  92590. * Adds a parser in the list of available ones
  92591. * @param name Defines the name of the parser
  92592. * @param parser Defines the parser to add
  92593. */
  92594. static AddParser(name: string, parser: BabylonFileParser): void;
  92595. /**
  92596. * Gets a general parser from the list of avaialble ones
  92597. * @param name Defines the name of the parser
  92598. * @returns the requested parser or null
  92599. */
  92600. static GetParser(name: string): Nullable<BabylonFileParser>;
  92601. /**
  92602. * Adds n individual parser in the list of available ones
  92603. * @param name Defines the name of the parser
  92604. * @param parser Defines the parser to add
  92605. */
  92606. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  92607. /**
  92608. * Gets an individual parser from the list of avaialble ones
  92609. * @param name Defines the name of the parser
  92610. * @returns the requested parser or null
  92611. */
  92612. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  92613. /**
  92614. * Parser json data and populate both a scene and its associated container object
  92615. * @param jsonData Defines the data to parse
  92616. * @param scene Defines the scene to parse the data for
  92617. * @param container Defines the container attached to the parsing sequence
  92618. * @param rootUrl Defines the root url of the data
  92619. */
  92620. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  92621. /**
  92622. * Gets the list of root nodes (ie. nodes with no parent)
  92623. */
  92624. rootNodes: Node[];
  92625. /** All of the cameras added to this scene
  92626. * @see http://doc.babylonjs.com/babylon101/cameras
  92627. */
  92628. cameras: Camera[];
  92629. /**
  92630. * All of the lights added to this scene
  92631. * @see http://doc.babylonjs.com/babylon101/lights
  92632. */
  92633. lights: Light[];
  92634. /**
  92635. * All of the (abstract) meshes added to this scene
  92636. */
  92637. meshes: AbstractMesh[];
  92638. /**
  92639. * The list of skeletons added to the scene
  92640. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92641. */
  92642. skeletons: Skeleton[];
  92643. /**
  92644. * All of the particle systems added to this scene
  92645. * @see http://doc.babylonjs.com/babylon101/particles
  92646. */
  92647. particleSystems: IParticleSystem[];
  92648. /**
  92649. * Gets a list of Animations associated with the scene
  92650. */
  92651. animations: Animation[];
  92652. /**
  92653. * All of the animation groups added to this scene
  92654. * @see http://doc.babylonjs.com/how_to/group
  92655. */
  92656. animationGroups: AnimationGroup[];
  92657. /**
  92658. * All of the multi-materials added to this scene
  92659. * @see http://doc.babylonjs.com/how_to/multi_materials
  92660. */
  92661. multiMaterials: MultiMaterial[];
  92662. /**
  92663. * All of the materials added to this scene
  92664. * In the context of a Scene, it is not supposed to be modified manually.
  92665. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  92666. * Note also that the order of the Material wihin the array is not significant and might change.
  92667. * @see http://doc.babylonjs.com/babylon101/materials
  92668. */
  92669. materials: Material[];
  92670. /**
  92671. * The list of morph target managers added to the scene
  92672. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  92673. */
  92674. morphTargetManagers: MorphTargetManager[];
  92675. /**
  92676. * The list of geometries used in the scene.
  92677. */
  92678. geometries: Geometry[];
  92679. /**
  92680. * All of the tranform nodes added to this scene
  92681. * In the context of a Scene, it is not supposed to be modified manually.
  92682. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  92683. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  92684. * @see http://doc.babylonjs.com/how_to/transformnode
  92685. */
  92686. transformNodes: TransformNode[];
  92687. /**
  92688. * ActionManagers available on the scene.
  92689. */
  92690. actionManagers: AbstractActionManager[];
  92691. /**
  92692. * Textures to keep.
  92693. */
  92694. textures: BaseTexture[];
  92695. /**
  92696. * Environment texture for the scene
  92697. */
  92698. environmentTexture: Nullable<BaseTexture>;
  92699. }
  92700. }
  92701. declare module BABYLON {
  92702. /**
  92703. * Defines a sound that can be played in the application.
  92704. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  92705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92706. */
  92707. export class Sound {
  92708. /**
  92709. * The name of the sound in the scene.
  92710. */
  92711. name: string;
  92712. /**
  92713. * Does the sound autoplay once loaded.
  92714. */
  92715. autoplay: boolean;
  92716. /**
  92717. * Does the sound loop after it finishes playing once.
  92718. */
  92719. loop: boolean;
  92720. /**
  92721. * Does the sound use a custom attenuation curve to simulate the falloff
  92722. * happening when the source gets further away from the camera.
  92723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92724. */
  92725. useCustomAttenuation: boolean;
  92726. /**
  92727. * The sound track id this sound belongs to.
  92728. */
  92729. soundTrackId: number;
  92730. /**
  92731. * Is this sound currently played.
  92732. */
  92733. isPlaying: boolean;
  92734. /**
  92735. * Is this sound currently paused.
  92736. */
  92737. isPaused: boolean;
  92738. /**
  92739. * Does this sound enables spatial sound.
  92740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92741. */
  92742. spatialSound: boolean;
  92743. /**
  92744. * Define the reference distance the sound should be heard perfectly.
  92745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92746. */
  92747. refDistance: number;
  92748. /**
  92749. * Define the roll off factor of spatial sounds.
  92750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92751. */
  92752. rolloffFactor: number;
  92753. /**
  92754. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  92755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92756. */
  92757. maxDistance: number;
  92758. /**
  92759. * Define the distance attenuation model the sound will follow.
  92760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92761. */
  92762. distanceModel: string;
  92763. /**
  92764. * @hidden
  92765. * Back Compat
  92766. **/
  92767. onended: () => any;
  92768. /**
  92769. * Observable event when the current playing sound finishes.
  92770. */
  92771. onEndedObservable: Observable<Sound>;
  92772. private _panningModel;
  92773. private _playbackRate;
  92774. private _streaming;
  92775. private _startTime;
  92776. private _startOffset;
  92777. private _position;
  92778. /** @hidden */
  92779. _positionInEmitterSpace: boolean;
  92780. private _localDirection;
  92781. private _volume;
  92782. private _isReadyToPlay;
  92783. private _isDirectional;
  92784. private _readyToPlayCallback;
  92785. private _audioBuffer;
  92786. private _soundSource;
  92787. private _streamingSource;
  92788. private _soundPanner;
  92789. private _soundGain;
  92790. private _inputAudioNode;
  92791. private _outputAudioNode;
  92792. private _coneInnerAngle;
  92793. private _coneOuterAngle;
  92794. private _coneOuterGain;
  92795. private _scene;
  92796. private _connectedTransformNode;
  92797. private _customAttenuationFunction;
  92798. private _registerFunc;
  92799. private _isOutputConnected;
  92800. private _htmlAudioElement;
  92801. private _urlType;
  92802. /** @hidden */
  92803. static _SceneComponentInitialization: (scene: Scene) => void;
  92804. /**
  92805. * Create a sound and attach it to a scene
  92806. * @param name Name of your sound
  92807. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  92808. * @param scene defines the scene the sound belongs to
  92809. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  92810. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  92811. */
  92812. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  92813. /**
  92814. * Release the sound and its associated resources
  92815. */
  92816. dispose(): void;
  92817. /**
  92818. * Gets if the sounds is ready to be played or not.
  92819. * @returns true if ready, otherwise false
  92820. */
  92821. isReady(): boolean;
  92822. private _soundLoaded;
  92823. /**
  92824. * Sets the data of the sound from an audiobuffer
  92825. * @param audioBuffer The audioBuffer containing the data
  92826. */
  92827. setAudioBuffer(audioBuffer: AudioBuffer): void;
  92828. /**
  92829. * Updates the current sounds options such as maxdistance, loop...
  92830. * @param options A JSON object containing values named as the object properties
  92831. */
  92832. updateOptions(options: any): void;
  92833. private _createSpatialParameters;
  92834. private _updateSpatialParameters;
  92835. /**
  92836. * Switch the panning model to HRTF:
  92837. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92839. */
  92840. switchPanningModelToHRTF(): void;
  92841. /**
  92842. * Switch the panning model to Equal Power:
  92843. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92845. */
  92846. switchPanningModelToEqualPower(): void;
  92847. private _switchPanningModel;
  92848. /**
  92849. * Connect this sound to a sound track audio node like gain...
  92850. * @param soundTrackAudioNode the sound track audio node to connect to
  92851. */
  92852. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  92853. /**
  92854. * Transform this sound into a directional source
  92855. * @param coneInnerAngle Size of the inner cone in degree
  92856. * @param coneOuterAngle Size of the outer cone in degree
  92857. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  92858. */
  92859. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  92860. /**
  92861. * Gets or sets the inner angle for the directional cone.
  92862. */
  92863. /**
  92864. * Gets or sets the inner angle for the directional cone.
  92865. */
  92866. directionalConeInnerAngle: number;
  92867. /**
  92868. * Gets or sets the outer angle for the directional cone.
  92869. */
  92870. /**
  92871. * Gets or sets the outer angle for the directional cone.
  92872. */
  92873. directionalConeOuterAngle: number;
  92874. /**
  92875. * Sets the position of the emitter if spatial sound is enabled
  92876. * @param newPosition Defines the new posisiton
  92877. */
  92878. setPosition(newPosition: Vector3): void;
  92879. /**
  92880. * Sets the local direction of the emitter if spatial sound is enabled
  92881. * @param newLocalDirection Defines the new local direction
  92882. */
  92883. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  92884. private _updateDirection;
  92885. /** @hidden */
  92886. updateDistanceFromListener(): void;
  92887. /**
  92888. * Sets a new custom attenuation function for the sound.
  92889. * @param callback Defines the function used for the attenuation
  92890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92891. */
  92892. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  92893. /**
  92894. * Play the sound
  92895. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  92896. * @param offset (optional) Start the sound setting it at a specific time
  92897. */
  92898. play(time?: number, offset?: number): void;
  92899. private _onended;
  92900. /**
  92901. * Stop the sound
  92902. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  92903. */
  92904. stop(time?: number): void;
  92905. /**
  92906. * Put the sound in pause
  92907. */
  92908. pause(): void;
  92909. /**
  92910. * Sets a dedicated volume for this sounds
  92911. * @param newVolume Define the new volume of the sound
  92912. * @param time Define in how long the sound should be at this value
  92913. */
  92914. setVolume(newVolume: number, time?: number): void;
  92915. /**
  92916. * Set the sound play back rate
  92917. * @param newPlaybackRate Define the playback rate the sound should be played at
  92918. */
  92919. setPlaybackRate(newPlaybackRate: number): void;
  92920. /**
  92921. * Gets the volume of the sound.
  92922. * @returns the volume of the sound
  92923. */
  92924. getVolume(): number;
  92925. /**
  92926. * Attach the sound to a dedicated mesh
  92927. * @param transformNode The transform node to connect the sound with
  92928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92929. */
  92930. attachToMesh(transformNode: TransformNode): void;
  92931. /**
  92932. * Detach the sound from the previously attached mesh
  92933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92934. */
  92935. detachFromMesh(): void;
  92936. private _onRegisterAfterWorldMatrixUpdate;
  92937. /**
  92938. * Clone the current sound in the scene.
  92939. * @returns the new sound clone
  92940. */
  92941. clone(): Nullable<Sound>;
  92942. /**
  92943. * Gets the current underlying audio buffer containing the data
  92944. * @returns the audio buffer
  92945. */
  92946. getAudioBuffer(): Nullable<AudioBuffer>;
  92947. /**
  92948. * Serializes the Sound in a JSON representation
  92949. * @returns the JSON representation of the sound
  92950. */
  92951. serialize(): any;
  92952. /**
  92953. * Parse a JSON representation of a sound to innstantiate in a given scene
  92954. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  92955. * @param scene Define the scene the new parsed sound should be created in
  92956. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  92957. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  92958. * @returns the newly parsed sound
  92959. */
  92960. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  92961. }
  92962. }
  92963. declare module BABYLON {
  92964. /**
  92965. * This defines an action helpful to play a defined sound on a triggered action.
  92966. */
  92967. export class PlaySoundAction extends Action {
  92968. private _sound;
  92969. /**
  92970. * Instantiate the action
  92971. * @param triggerOptions defines the trigger options
  92972. * @param sound defines the sound to play
  92973. * @param condition defines the trigger related conditions
  92974. */
  92975. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92976. /** @hidden */
  92977. _prepare(): void;
  92978. /**
  92979. * Execute the action and play the sound.
  92980. */
  92981. execute(): void;
  92982. /**
  92983. * Serializes the actions and its related information.
  92984. * @param parent defines the object to serialize in
  92985. * @returns the serialized object
  92986. */
  92987. serialize(parent: any): any;
  92988. }
  92989. /**
  92990. * This defines an action helpful to stop a defined sound on a triggered action.
  92991. */
  92992. export class StopSoundAction extends Action {
  92993. private _sound;
  92994. /**
  92995. * Instantiate the action
  92996. * @param triggerOptions defines the trigger options
  92997. * @param sound defines the sound to stop
  92998. * @param condition defines the trigger related conditions
  92999. */
  93000. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93001. /** @hidden */
  93002. _prepare(): void;
  93003. /**
  93004. * Execute the action and stop the sound.
  93005. */
  93006. execute(): void;
  93007. /**
  93008. * Serializes the actions and its related information.
  93009. * @param parent defines the object to serialize in
  93010. * @returns the serialized object
  93011. */
  93012. serialize(parent: any): any;
  93013. }
  93014. }
  93015. declare module BABYLON {
  93016. /**
  93017. * This defines an action responsible to change the value of a property
  93018. * by interpolating between its current value and the newly set one once triggered.
  93019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93020. */
  93021. export class InterpolateValueAction extends Action {
  93022. /**
  93023. * Defines the path of the property where the value should be interpolated
  93024. */
  93025. propertyPath: string;
  93026. /**
  93027. * Defines the target value at the end of the interpolation.
  93028. */
  93029. value: any;
  93030. /**
  93031. * Defines the time it will take for the property to interpolate to the value.
  93032. */
  93033. duration: number;
  93034. /**
  93035. * Defines if the other scene animations should be stopped when the action has been triggered
  93036. */
  93037. stopOtherAnimations?: boolean;
  93038. /**
  93039. * Defines a callback raised once the interpolation animation has been done.
  93040. */
  93041. onInterpolationDone?: () => void;
  93042. /**
  93043. * Observable triggered once the interpolation animation has been done.
  93044. */
  93045. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  93046. private _target;
  93047. private _effectiveTarget;
  93048. private _property;
  93049. /**
  93050. * Instantiate the action
  93051. * @param triggerOptions defines the trigger options
  93052. * @param target defines the object containing the value to interpolate
  93053. * @param propertyPath defines the path to the property in the target object
  93054. * @param value defines the target value at the end of the interpolation
  93055. * @param duration deines the time it will take for the property to interpolate to the value.
  93056. * @param condition defines the trigger related conditions
  93057. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  93058. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  93059. */
  93060. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  93061. /** @hidden */
  93062. _prepare(): void;
  93063. /**
  93064. * Execute the action starts the value interpolation.
  93065. */
  93066. execute(): void;
  93067. /**
  93068. * Serializes the actions and its related information.
  93069. * @param parent defines the object to serialize in
  93070. * @returns the serialized object
  93071. */
  93072. serialize(parent: any): any;
  93073. }
  93074. }
  93075. declare module BABYLON {
  93076. /**
  93077. * Options allowed during the creation of a sound track.
  93078. */
  93079. export interface ISoundTrackOptions {
  93080. /**
  93081. * The volume the sound track should take during creation
  93082. */
  93083. volume?: number;
  93084. /**
  93085. * Define if the sound track is the main sound track of the scene
  93086. */
  93087. mainTrack?: boolean;
  93088. }
  93089. /**
  93090. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  93091. * It will be also used in a future release to apply effects on a specific track.
  93092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93093. */
  93094. export class SoundTrack {
  93095. /**
  93096. * The unique identifier of the sound track in the scene.
  93097. */
  93098. id: number;
  93099. /**
  93100. * The list of sounds included in the sound track.
  93101. */
  93102. soundCollection: Array<Sound>;
  93103. private _outputAudioNode;
  93104. private _scene;
  93105. private _isMainTrack;
  93106. private _connectedAnalyser;
  93107. private _options;
  93108. private _isInitialized;
  93109. /**
  93110. * Creates a new sound track.
  93111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93112. * @param scene Define the scene the sound track belongs to
  93113. * @param options
  93114. */
  93115. constructor(scene: Scene, options?: ISoundTrackOptions);
  93116. private _initializeSoundTrackAudioGraph;
  93117. /**
  93118. * Release the sound track and its associated resources
  93119. */
  93120. dispose(): void;
  93121. /**
  93122. * Adds a sound to this sound track
  93123. * @param sound define the cound to add
  93124. * @ignoreNaming
  93125. */
  93126. AddSound(sound: Sound): void;
  93127. /**
  93128. * Removes a sound to this sound track
  93129. * @param sound define the cound to remove
  93130. * @ignoreNaming
  93131. */
  93132. RemoveSound(sound: Sound): void;
  93133. /**
  93134. * Set a global volume for the full sound track.
  93135. * @param newVolume Define the new volume of the sound track
  93136. */
  93137. setVolume(newVolume: number): void;
  93138. /**
  93139. * Switch the panning model to HRTF:
  93140. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93142. */
  93143. switchPanningModelToHRTF(): void;
  93144. /**
  93145. * Switch the panning model to Equal Power:
  93146. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93148. */
  93149. switchPanningModelToEqualPower(): void;
  93150. /**
  93151. * Connect the sound track to an audio analyser allowing some amazing
  93152. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93154. * @param analyser The analyser to connect to the engine
  93155. */
  93156. connectToAnalyser(analyser: Analyser): void;
  93157. }
  93158. }
  93159. declare module BABYLON {
  93160. interface AbstractScene {
  93161. /**
  93162. * The list of sounds used in the scene.
  93163. */
  93164. sounds: Nullable<Array<Sound>>;
  93165. }
  93166. interface Scene {
  93167. /**
  93168. * @hidden
  93169. * Backing field
  93170. */
  93171. _mainSoundTrack: SoundTrack;
  93172. /**
  93173. * The main sound track played by the scene.
  93174. * It cotains your primary collection of sounds.
  93175. */
  93176. mainSoundTrack: SoundTrack;
  93177. /**
  93178. * The list of sound tracks added to the scene
  93179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93180. */
  93181. soundTracks: Nullable<Array<SoundTrack>>;
  93182. /**
  93183. * Gets a sound using a given name
  93184. * @param name defines the name to search for
  93185. * @return the found sound or null if not found at all.
  93186. */
  93187. getSoundByName(name: string): Nullable<Sound>;
  93188. /**
  93189. * Gets or sets if audio support is enabled
  93190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93191. */
  93192. audioEnabled: boolean;
  93193. /**
  93194. * Gets or sets if audio will be output to headphones
  93195. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93196. */
  93197. headphone: boolean;
  93198. }
  93199. /**
  93200. * Defines the sound scene component responsible to manage any sounds
  93201. * in a given scene.
  93202. */
  93203. export class AudioSceneComponent implements ISceneSerializableComponent {
  93204. /**
  93205. * The component name helpfull to identify the component in the list of scene components.
  93206. */
  93207. readonly name: string;
  93208. /**
  93209. * The scene the component belongs to.
  93210. */
  93211. scene: Scene;
  93212. private _audioEnabled;
  93213. /**
  93214. * Gets whether audio is enabled or not.
  93215. * Please use related enable/disable method to switch state.
  93216. */
  93217. readonly audioEnabled: boolean;
  93218. private _headphone;
  93219. /**
  93220. * Gets whether audio is outputing to headphone or not.
  93221. * Please use the according Switch methods to change output.
  93222. */
  93223. readonly headphone: boolean;
  93224. /**
  93225. * Creates a new instance of the component for the given scene
  93226. * @param scene Defines the scene to register the component in
  93227. */
  93228. constructor(scene: Scene);
  93229. /**
  93230. * Registers the component in a given scene
  93231. */
  93232. register(): void;
  93233. /**
  93234. * Rebuilds the elements related to this component in case of
  93235. * context lost for instance.
  93236. */
  93237. rebuild(): void;
  93238. /**
  93239. * Serializes the component data to the specified json object
  93240. * @param serializationObject The object to serialize to
  93241. */
  93242. serialize(serializationObject: any): void;
  93243. /**
  93244. * Adds all the element from the container to the scene
  93245. * @param container the container holding the elements
  93246. */
  93247. addFromContainer(container: AbstractScene): void;
  93248. /**
  93249. * Removes all the elements in the container from the scene
  93250. * @param container contains the elements to remove
  93251. * @param dispose if the removed element should be disposed (default: false)
  93252. */
  93253. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  93254. /**
  93255. * Disposes the component and the associated ressources.
  93256. */
  93257. dispose(): void;
  93258. /**
  93259. * Disables audio in the associated scene.
  93260. */
  93261. disableAudio(): void;
  93262. /**
  93263. * Enables audio in the associated scene.
  93264. */
  93265. enableAudio(): void;
  93266. /**
  93267. * Switch audio to headphone output.
  93268. */
  93269. switchAudioModeForHeadphones(): void;
  93270. /**
  93271. * Switch audio to normal speakers.
  93272. */
  93273. switchAudioModeForNormalSpeakers(): void;
  93274. private _afterRender;
  93275. }
  93276. }
  93277. declare module BABYLON {
  93278. /**
  93279. * Wraps one or more Sound objects and selects one with random weight for playback.
  93280. */
  93281. export class WeightedSound {
  93282. /** When true a Sound will be selected and played when the current playing Sound completes. */
  93283. loop: boolean;
  93284. private _coneInnerAngle;
  93285. private _coneOuterAngle;
  93286. private _volume;
  93287. /** A Sound is currently playing. */
  93288. isPlaying: boolean;
  93289. /** A Sound is currently paused. */
  93290. isPaused: boolean;
  93291. private _sounds;
  93292. private _weights;
  93293. private _currentIndex?;
  93294. /**
  93295. * Creates a new WeightedSound from the list of sounds given.
  93296. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  93297. * @param sounds Array of Sounds that will be selected from.
  93298. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  93299. */
  93300. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  93301. /**
  93302. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  93303. */
  93304. /**
  93305. * The size of cone in degress for a directional sound in which there will be no attenuation.
  93306. */
  93307. directionalConeInnerAngle: number;
  93308. /**
  93309. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93310. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93311. */
  93312. /**
  93313. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93314. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93315. */
  93316. directionalConeOuterAngle: number;
  93317. /**
  93318. * Playback volume.
  93319. */
  93320. /**
  93321. * Playback volume.
  93322. */
  93323. volume: number;
  93324. private _onended;
  93325. /**
  93326. * Suspend playback
  93327. */
  93328. pause(): void;
  93329. /**
  93330. * Stop playback
  93331. */
  93332. stop(): void;
  93333. /**
  93334. * Start playback.
  93335. * @param startOffset Position the clip head at a specific time in seconds.
  93336. */
  93337. play(startOffset?: number): void;
  93338. }
  93339. }
  93340. declare module BABYLON {
  93341. /**
  93342. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  93343. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93344. */
  93345. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  93346. /**
  93347. * Gets the name of the behavior.
  93348. */
  93349. readonly name: string;
  93350. /**
  93351. * The easing function used by animations
  93352. */
  93353. static EasingFunction: BackEase;
  93354. /**
  93355. * The easing mode used by animations
  93356. */
  93357. static EasingMode: number;
  93358. /**
  93359. * The duration of the animation, in milliseconds
  93360. */
  93361. transitionDuration: number;
  93362. /**
  93363. * Length of the distance animated by the transition when lower radius is reached
  93364. */
  93365. lowerRadiusTransitionRange: number;
  93366. /**
  93367. * Length of the distance animated by the transition when upper radius is reached
  93368. */
  93369. upperRadiusTransitionRange: number;
  93370. private _autoTransitionRange;
  93371. /**
  93372. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93373. */
  93374. /**
  93375. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93376. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  93377. */
  93378. autoTransitionRange: boolean;
  93379. private _attachedCamera;
  93380. private _onAfterCheckInputsObserver;
  93381. private _onMeshTargetChangedObserver;
  93382. /**
  93383. * Initializes the behavior.
  93384. */
  93385. init(): void;
  93386. /**
  93387. * Attaches the behavior to its arc rotate camera.
  93388. * @param camera Defines the camera to attach the behavior to
  93389. */
  93390. attach(camera: ArcRotateCamera): void;
  93391. /**
  93392. * Detaches the behavior from its current arc rotate camera.
  93393. */
  93394. detach(): void;
  93395. private _radiusIsAnimating;
  93396. private _radiusBounceTransition;
  93397. private _animatables;
  93398. private _cachedWheelPrecision;
  93399. /**
  93400. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  93401. * @param radiusLimit The limit to check against.
  93402. * @return Bool to indicate if at limit.
  93403. */
  93404. private _isRadiusAtLimit;
  93405. /**
  93406. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  93407. * @param radiusDelta The delta by which to animate to. Can be negative.
  93408. */
  93409. private _applyBoundRadiusAnimation;
  93410. /**
  93411. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  93412. */
  93413. protected _clearAnimationLocks(): void;
  93414. /**
  93415. * Stops and removes all animations that have been applied to the camera
  93416. */
  93417. stopAllAnimations(): void;
  93418. }
  93419. }
  93420. declare module BABYLON {
  93421. /**
  93422. * 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.
  93423. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93424. */
  93425. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  93426. /**
  93427. * Gets the name of the behavior.
  93428. */
  93429. readonly name: string;
  93430. private _mode;
  93431. private _radiusScale;
  93432. private _positionScale;
  93433. private _defaultElevation;
  93434. private _elevationReturnTime;
  93435. private _elevationReturnWaitTime;
  93436. private _zoomStopsAnimation;
  93437. private _framingTime;
  93438. /**
  93439. * The easing function used by animations
  93440. */
  93441. static EasingFunction: ExponentialEase;
  93442. /**
  93443. * The easing mode used by animations
  93444. */
  93445. static EasingMode: number;
  93446. /**
  93447. * Sets the current mode used by the behavior
  93448. */
  93449. /**
  93450. * Gets current mode used by the behavior.
  93451. */
  93452. mode: number;
  93453. /**
  93454. * Sets the scale applied to the radius (1 by default)
  93455. */
  93456. /**
  93457. * Gets the scale applied to the radius
  93458. */
  93459. radiusScale: number;
  93460. /**
  93461. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93462. */
  93463. /**
  93464. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93465. */
  93466. positionScale: number;
  93467. /**
  93468. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93469. * behaviour is triggered, in radians.
  93470. */
  93471. /**
  93472. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93473. * behaviour is triggered, in radians.
  93474. */
  93475. defaultElevation: number;
  93476. /**
  93477. * Sets the time (in milliseconds) taken to return to the default beta position.
  93478. * Negative value indicates camera should not return to default.
  93479. */
  93480. /**
  93481. * Gets the time (in milliseconds) taken to return to the default beta position.
  93482. * Negative value indicates camera should not return to default.
  93483. */
  93484. elevationReturnTime: number;
  93485. /**
  93486. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93487. */
  93488. /**
  93489. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93490. */
  93491. elevationReturnWaitTime: number;
  93492. /**
  93493. * Sets the flag that indicates if user zooming should stop animation.
  93494. */
  93495. /**
  93496. * Gets the flag that indicates if user zooming should stop animation.
  93497. */
  93498. zoomStopsAnimation: boolean;
  93499. /**
  93500. * Sets the transition time when framing the mesh, in milliseconds
  93501. */
  93502. /**
  93503. * Gets the transition time when framing the mesh, in milliseconds
  93504. */
  93505. framingTime: number;
  93506. /**
  93507. * Define if the behavior should automatically change the configured
  93508. * camera limits and sensibilities.
  93509. */
  93510. autoCorrectCameraLimitsAndSensibility: boolean;
  93511. private _onPrePointerObservableObserver;
  93512. private _onAfterCheckInputsObserver;
  93513. private _onMeshTargetChangedObserver;
  93514. private _attachedCamera;
  93515. private _isPointerDown;
  93516. private _lastInteractionTime;
  93517. /**
  93518. * Initializes the behavior.
  93519. */
  93520. init(): void;
  93521. /**
  93522. * Attaches the behavior to its arc rotate camera.
  93523. * @param camera Defines the camera to attach the behavior to
  93524. */
  93525. attach(camera: ArcRotateCamera): void;
  93526. /**
  93527. * Detaches the behavior from its current arc rotate camera.
  93528. */
  93529. detach(): void;
  93530. private _animatables;
  93531. private _betaIsAnimating;
  93532. private _betaTransition;
  93533. private _radiusTransition;
  93534. private _vectorTransition;
  93535. /**
  93536. * Targets the given mesh and updates zoom level accordingly.
  93537. * @param mesh The mesh to target.
  93538. * @param radius Optional. If a cached radius position already exists, overrides default.
  93539. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93540. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93541. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93542. */
  93543. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93544. /**
  93545. * Targets the given mesh with its children and updates zoom level accordingly.
  93546. * @param mesh The mesh to target.
  93547. * @param radius Optional. If a cached radius position already exists, overrides default.
  93548. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93549. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93550. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93551. */
  93552. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93553. /**
  93554. * Targets the given meshes with their children and updates zoom level accordingly.
  93555. * @param meshes The mesh to target.
  93556. * @param radius Optional. If a cached radius position already exists, overrides default.
  93557. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93558. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93559. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93560. */
  93561. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93562. /**
  93563. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  93564. * @param minimumWorld Determines the smaller position of the bounding box extend
  93565. * @param maximumWorld Determines the bigger position of the bounding box extend
  93566. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93567. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93568. */
  93569. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93570. /**
  93571. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  93572. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  93573. * frustum width.
  93574. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  93575. * to fully enclose the mesh in the viewing frustum.
  93576. */
  93577. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  93578. /**
  93579. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  93580. * is automatically returned to its default position (expected to be above ground plane).
  93581. */
  93582. private _maintainCameraAboveGround;
  93583. /**
  93584. * Returns the frustum slope based on the canvas ratio and camera FOV
  93585. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  93586. */
  93587. private _getFrustumSlope;
  93588. /**
  93589. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  93590. */
  93591. private _clearAnimationLocks;
  93592. /**
  93593. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93594. */
  93595. private _applyUserInteraction;
  93596. /**
  93597. * Stops and removes all animations that have been applied to the camera
  93598. */
  93599. stopAllAnimations(): void;
  93600. /**
  93601. * Gets a value indicating if the user is moving the camera
  93602. */
  93603. readonly isUserIsMoving: boolean;
  93604. /**
  93605. * The camera can move all the way towards the mesh.
  93606. */
  93607. static IgnoreBoundsSizeMode: number;
  93608. /**
  93609. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  93610. */
  93611. static FitFrustumSidesMode: number;
  93612. }
  93613. }
  93614. declare module BABYLON {
  93615. /**
  93616. * Base class for Camera Pointer Inputs.
  93617. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  93618. * for example usage.
  93619. */
  93620. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  93621. /**
  93622. * Defines the camera the input is attached to.
  93623. */
  93624. abstract camera: Camera;
  93625. /**
  93626. * Whether keyboard modifier keys are pressed at time of last mouse event.
  93627. */
  93628. protected _altKey: boolean;
  93629. protected _ctrlKey: boolean;
  93630. protected _metaKey: boolean;
  93631. protected _shiftKey: boolean;
  93632. /**
  93633. * Which mouse buttons were pressed at time of last mouse event.
  93634. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  93635. */
  93636. protected _buttonsPressed: number;
  93637. /**
  93638. * Defines the buttons associated with the input to handle camera move.
  93639. */
  93640. buttons: number[];
  93641. /**
  93642. * Attach the input controls to a specific dom element to get the input from.
  93643. * @param element Defines the element the controls should be listened from
  93644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93645. */
  93646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93647. /**
  93648. * Detach the current controls from the specified dom element.
  93649. * @param element Defines the element to stop listening the inputs from
  93650. */
  93651. detachControl(element: Nullable<HTMLElement>): void;
  93652. /**
  93653. * Gets the class name of the current input.
  93654. * @returns the class name
  93655. */
  93656. getClassName(): string;
  93657. /**
  93658. * Get the friendly name associated with the input class.
  93659. * @returns the input friendly name
  93660. */
  93661. getSimpleName(): string;
  93662. /**
  93663. * Called on pointer POINTERDOUBLETAP event.
  93664. * Override this method to provide functionality on POINTERDOUBLETAP event.
  93665. */
  93666. protected onDoubleTap(type: string): void;
  93667. /**
  93668. * Called on pointer POINTERMOVE event if only a single touch is active.
  93669. * Override this method to provide functionality.
  93670. */
  93671. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93672. /**
  93673. * Called on pointer POINTERMOVE event if multiple touches are active.
  93674. * Override this method to provide functionality.
  93675. */
  93676. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93677. /**
  93678. * Called on JS contextmenu event.
  93679. * Override this method to provide functionality.
  93680. */
  93681. protected onContextMenu(evt: PointerEvent): void;
  93682. /**
  93683. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93684. * press.
  93685. * Override this method to provide functionality.
  93686. */
  93687. protected onButtonDown(evt: PointerEvent): void;
  93688. /**
  93689. * Called each time a new POINTERUP event occurs. Ie, for each button
  93690. * release.
  93691. * Override this method to provide functionality.
  93692. */
  93693. protected onButtonUp(evt: PointerEvent): void;
  93694. /**
  93695. * Called when window becomes inactive.
  93696. * Override this method to provide functionality.
  93697. */
  93698. protected onLostFocus(): void;
  93699. private _pointerInput;
  93700. private _observer;
  93701. private _onLostFocus;
  93702. private pointA;
  93703. private pointB;
  93704. }
  93705. }
  93706. declare module BABYLON {
  93707. /**
  93708. * Manage the pointers inputs to control an arc rotate camera.
  93709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93710. */
  93711. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  93712. /**
  93713. * Defines the camera the input is attached to.
  93714. */
  93715. camera: ArcRotateCamera;
  93716. /**
  93717. * Gets the class name of the current input.
  93718. * @returns the class name
  93719. */
  93720. getClassName(): string;
  93721. /**
  93722. * Defines the buttons associated with the input to handle camera move.
  93723. */
  93724. buttons: number[];
  93725. /**
  93726. * Defines the pointer angular sensibility along the X axis or how fast is
  93727. * the camera rotating.
  93728. */
  93729. angularSensibilityX: number;
  93730. /**
  93731. * Defines the pointer angular sensibility along the Y axis or how fast is
  93732. * the camera rotating.
  93733. */
  93734. angularSensibilityY: number;
  93735. /**
  93736. * Defines the pointer pinch precision or how fast is the camera zooming.
  93737. */
  93738. pinchPrecision: number;
  93739. /**
  93740. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93741. * from 0.
  93742. * It defines the percentage of current camera.radius to use as delta when
  93743. * pinch zoom is used.
  93744. */
  93745. pinchDeltaPercentage: number;
  93746. /**
  93747. * Defines the pointer panning sensibility or how fast is the camera moving.
  93748. */
  93749. panningSensibility: number;
  93750. /**
  93751. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  93752. */
  93753. multiTouchPanning: boolean;
  93754. /**
  93755. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  93756. * zoom (pinch) through multitouch.
  93757. */
  93758. multiTouchPanAndZoom: boolean;
  93759. /**
  93760. * Revers pinch action direction.
  93761. */
  93762. pinchInwards: boolean;
  93763. private _isPanClick;
  93764. private _twoFingerActivityCount;
  93765. private _isPinching;
  93766. /**
  93767. * Called on pointer POINTERMOVE event if only a single touch is active.
  93768. */
  93769. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93770. /**
  93771. * Called on pointer POINTERDOUBLETAP event.
  93772. */
  93773. protected onDoubleTap(type: string): void;
  93774. /**
  93775. * Called on pointer POINTERMOVE event if multiple touches are active.
  93776. */
  93777. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93778. /**
  93779. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93780. * press.
  93781. */
  93782. protected onButtonDown(evt: PointerEvent): void;
  93783. /**
  93784. * Called each time a new POINTERUP event occurs. Ie, for each button
  93785. * release.
  93786. */
  93787. protected onButtonUp(evt: PointerEvent): void;
  93788. /**
  93789. * Called when window becomes inactive.
  93790. */
  93791. protected onLostFocus(): void;
  93792. }
  93793. }
  93794. declare module BABYLON {
  93795. /**
  93796. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  93797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93798. */
  93799. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  93800. /**
  93801. * Defines the camera the input is attached to.
  93802. */
  93803. camera: ArcRotateCamera;
  93804. /**
  93805. * Defines the list of key codes associated with the up action (increase alpha)
  93806. */
  93807. keysUp: number[];
  93808. /**
  93809. * Defines the list of key codes associated with the down action (decrease alpha)
  93810. */
  93811. keysDown: number[];
  93812. /**
  93813. * Defines the list of key codes associated with the left action (increase beta)
  93814. */
  93815. keysLeft: number[];
  93816. /**
  93817. * Defines the list of key codes associated with the right action (decrease beta)
  93818. */
  93819. keysRight: number[];
  93820. /**
  93821. * Defines the list of key codes associated with the reset action.
  93822. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  93823. */
  93824. keysReset: number[];
  93825. /**
  93826. * Defines the panning sensibility of the inputs.
  93827. * (How fast is the camera paning)
  93828. */
  93829. panningSensibility: number;
  93830. /**
  93831. * Defines the zooming sensibility of the inputs.
  93832. * (How fast is the camera zooming)
  93833. */
  93834. zoomingSensibility: number;
  93835. /**
  93836. * Defines wether maintaining the alt key down switch the movement mode from
  93837. * orientation to zoom.
  93838. */
  93839. useAltToZoom: boolean;
  93840. /**
  93841. * Rotation speed of the camera
  93842. */
  93843. angularSpeed: number;
  93844. private _keys;
  93845. private _ctrlPressed;
  93846. private _altPressed;
  93847. private _onCanvasBlurObserver;
  93848. private _onKeyboardObserver;
  93849. private _engine;
  93850. private _scene;
  93851. /**
  93852. * Attach the input controls to a specific dom element to get the input from.
  93853. * @param element Defines the element the controls should be listened from
  93854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93855. */
  93856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93857. /**
  93858. * Detach the current controls from the specified dom element.
  93859. * @param element Defines the element to stop listening the inputs from
  93860. */
  93861. detachControl(element: Nullable<HTMLElement>): void;
  93862. /**
  93863. * Update the current camera state depending on the inputs that have been used this frame.
  93864. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93865. */
  93866. checkInputs(): void;
  93867. /**
  93868. * Gets the class name of the current intput.
  93869. * @returns the class name
  93870. */
  93871. getClassName(): string;
  93872. /**
  93873. * Get the friendly name associated with the input class.
  93874. * @returns the input friendly name
  93875. */
  93876. getSimpleName(): string;
  93877. }
  93878. }
  93879. declare module BABYLON {
  93880. /**
  93881. * Manage the mouse wheel inputs to control an arc rotate camera.
  93882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93883. */
  93884. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  93885. /**
  93886. * Defines the camera the input is attached to.
  93887. */
  93888. camera: ArcRotateCamera;
  93889. /**
  93890. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93891. */
  93892. wheelPrecision: number;
  93893. /**
  93894. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93895. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93896. */
  93897. wheelDeltaPercentage: number;
  93898. private _wheel;
  93899. private _observer;
  93900. /**
  93901. * Attach the input controls to a specific dom element to get the input from.
  93902. * @param element Defines the element the controls should be listened from
  93903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93904. */
  93905. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93906. /**
  93907. * Detach the current controls from the specified dom element.
  93908. * @param element Defines the element to stop listening the inputs from
  93909. */
  93910. detachControl(element: Nullable<HTMLElement>): void;
  93911. /**
  93912. * Gets the class name of the current intput.
  93913. * @returns the class name
  93914. */
  93915. getClassName(): string;
  93916. /**
  93917. * Get the friendly name associated with the input class.
  93918. * @returns the input friendly name
  93919. */
  93920. getSimpleName(): string;
  93921. }
  93922. }
  93923. declare module BABYLON {
  93924. /**
  93925. * Default Inputs manager for the ArcRotateCamera.
  93926. * It groups all the default supported inputs for ease of use.
  93927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93928. */
  93929. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  93930. /**
  93931. * Instantiates a new ArcRotateCameraInputsManager.
  93932. * @param camera Defines the camera the inputs belong to
  93933. */
  93934. constructor(camera: ArcRotateCamera);
  93935. /**
  93936. * Add mouse wheel input support to the input manager.
  93937. * @returns the current input manager
  93938. */
  93939. addMouseWheel(): ArcRotateCameraInputsManager;
  93940. /**
  93941. * Add pointers input support to the input manager.
  93942. * @returns the current input manager
  93943. */
  93944. addPointers(): ArcRotateCameraInputsManager;
  93945. /**
  93946. * Add keyboard input support to the input manager.
  93947. * @returns the current input manager
  93948. */
  93949. addKeyboard(): ArcRotateCameraInputsManager;
  93950. }
  93951. }
  93952. declare module BABYLON {
  93953. /**
  93954. * This represents an orbital type of camera.
  93955. *
  93956. * 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.
  93957. * 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.
  93958. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  93959. */
  93960. export class ArcRotateCamera extends TargetCamera {
  93961. /**
  93962. * Defines the rotation angle of the camera along the longitudinal axis.
  93963. */
  93964. alpha: number;
  93965. /**
  93966. * Defines the rotation angle of the camera along the latitudinal axis.
  93967. */
  93968. beta: number;
  93969. /**
  93970. * Defines the radius of the camera from it s target point.
  93971. */
  93972. radius: number;
  93973. protected _target: Vector3;
  93974. protected _targetHost: Nullable<AbstractMesh>;
  93975. /**
  93976. * Defines the target point of the camera.
  93977. * The camera looks towards it form the radius distance.
  93978. */
  93979. target: Vector3;
  93980. /**
  93981. * Define the current local position of the camera in the scene
  93982. */
  93983. position: Vector3;
  93984. /**
  93985. * Current inertia value on the longitudinal axis.
  93986. * The bigger this number the longer it will take for the camera to stop.
  93987. */
  93988. inertialAlphaOffset: number;
  93989. /**
  93990. * Current inertia value on the latitudinal axis.
  93991. * The bigger this number the longer it will take for the camera to stop.
  93992. */
  93993. inertialBetaOffset: number;
  93994. /**
  93995. * Current inertia value on the radius axis.
  93996. * The bigger this number the longer it will take for the camera to stop.
  93997. */
  93998. inertialRadiusOffset: number;
  93999. /**
  94000. * Minimum allowed angle on the longitudinal axis.
  94001. * This can help limiting how the Camera is able to move in the scene.
  94002. */
  94003. lowerAlphaLimit: Nullable<number>;
  94004. /**
  94005. * Maximum allowed angle on the longitudinal axis.
  94006. * This can help limiting how the Camera is able to move in the scene.
  94007. */
  94008. upperAlphaLimit: Nullable<number>;
  94009. /**
  94010. * Minimum allowed angle on the latitudinal axis.
  94011. * This can help limiting how the Camera is able to move in the scene.
  94012. */
  94013. lowerBetaLimit: number;
  94014. /**
  94015. * Maximum allowed angle on the latitudinal axis.
  94016. * This can help limiting how the Camera is able to move in the scene.
  94017. */
  94018. upperBetaLimit: number;
  94019. /**
  94020. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  94021. * This can help limiting how the Camera is able to move in the scene.
  94022. */
  94023. lowerRadiusLimit: Nullable<number>;
  94024. /**
  94025. * Maximum allowed distance of the camera to the target (The camera can not get further).
  94026. * This can help limiting how the Camera is able to move in the scene.
  94027. */
  94028. upperRadiusLimit: Nullable<number>;
  94029. /**
  94030. * Defines the current inertia value used during panning of the camera along the X axis.
  94031. */
  94032. inertialPanningX: number;
  94033. /**
  94034. * Defines the current inertia value used during panning of the camera along the Y axis.
  94035. */
  94036. inertialPanningY: number;
  94037. /**
  94038. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  94039. * Basically if your fingers moves away from more than this distance you will be considered
  94040. * in pinch mode.
  94041. */
  94042. pinchToPanMaxDistance: number;
  94043. /**
  94044. * Defines the maximum distance the camera can pan.
  94045. * This could help keeping the cammera always in your scene.
  94046. */
  94047. panningDistanceLimit: Nullable<number>;
  94048. /**
  94049. * Defines the target of the camera before paning.
  94050. */
  94051. panningOriginTarget: Vector3;
  94052. /**
  94053. * Defines the value of the inertia used during panning.
  94054. * 0 would mean stop inertia and one would mean no decelleration at all.
  94055. */
  94056. panningInertia: number;
  94057. /**
  94058. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  94059. */
  94060. angularSensibilityX: number;
  94061. /**
  94062. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  94063. */
  94064. angularSensibilityY: number;
  94065. /**
  94066. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  94067. */
  94068. pinchPrecision: number;
  94069. /**
  94070. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  94071. * It will be used instead of pinchDeltaPrecision if different from 0.
  94072. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94073. */
  94074. pinchDeltaPercentage: number;
  94075. /**
  94076. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  94077. */
  94078. panningSensibility: number;
  94079. /**
  94080. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  94081. */
  94082. keysUp: number[];
  94083. /**
  94084. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  94085. */
  94086. keysDown: number[];
  94087. /**
  94088. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  94089. */
  94090. keysLeft: number[];
  94091. /**
  94092. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  94093. */
  94094. keysRight: number[];
  94095. /**
  94096. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94097. */
  94098. wheelPrecision: number;
  94099. /**
  94100. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  94101. * It will be used instead of pinchDeltaPrecision if different from 0.
  94102. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94103. */
  94104. wheelDeltaPercentage: number;
  94105. /**
  94106. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  94107. */
  94108. zoomOnFactor: number;
  94109. /**
  94110. * Defines a screen offset for the camera position.
  94111. */
  94112. targetScreenOffset: Vector2;
  94113. /**
  94114. * Allows the camera to be completely reversed.
  94115. * If false the camera can not arrive upside down.
  94116. */
  94117. allowUpsideDown: boolean;
  94118. /**
  94119. * Define if double tap/click is used to restore the previously saved state of the camera.
  94120. */
  94121. useInputToRestoreState: boolean;
  94122. /** @hidden */
  94123. _viewMatrix: Matrix;
  94124. /** @hidden */
  94125. _useCtrlForPanning: boolean;
  94126. /** @hidden */
  94127. _panningMouseButton: number;
  94128. /**
  94129. * Defines the input associated to the camera.
  94130. */
  94131. inputs: ArcRotateCameraInputsManager;
  94132. /** @hidden */
  94133. _reset: () => void;
  94134. /**
  94135. * Defines the allowed panning axis.
  94136. */
  94137. panningAxis: Vector3;
  94138. protected _localDirection: Vector3;
  94139. protected _transformedDirection: Vector3;
  94140. private _bouncingBehavior;
  94141. /**
  94142. * Gets the bouncing behavior of the camera if it has been enabled.
  94143. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94144. */
  94145. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  94146. /**
  94147. * Defines if the bouncing behavior of the camera is enabled on the camera.
  94148. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94149. */
  94150. useBouncingBehavior: boolean;
  94151. private _framingBehavior;
  94152. /**
  94153. * Gets the framing behavior of the camera if it has been enabled.
  94154. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94155. */
  94156. readonly framingBehavior: Nullable<FramingBehavior>;
  94157. /**
  94158. * Defines if the framing behavior of the camera is enabled on the camera.
  94159. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94160. */
  94161. useFramingBehavior: boolean;
  94162. private _autoRotationBehavior;
  94163. /**
  94164. * Gets the auto rotation behavior of the camera if it has been enabled.
  94165. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94166. */
  94167. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  94168. /**
  94169. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  94170. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94171. */
  94172. useAutoRotationBehavior: boolean;
  94173. /**
  94174. * Observable triggered when the mesh target has been changed on the camera.
  94175. */
  94176. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  94177. /**
  94178. * Event raised when the camera is colliding with a mesh.
  94179. */
  94180. onCollide: (collidedMesh: AbstractMesh) => void;
  94181. /**
  94182. * Defines whether the camera should check collision with the objects oh the scene.
  94183. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  94184. */
  94185. checkCollisions: boolean;
  94186. /**
  94187. * Defines the collision radius of the camera.
  94188. * This simulates a sphere around the camera.
  94189. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94190. */
  94191. collisionRadius: Vector3;
  94192. protected _collider: Collider;
  94193. protected _previousPosition: Vector3;
  94194. protected _collisionVelocity: Vector3;
  94195. protected _newPosition: Vector3;
  94196. protected _previousAlpha: number;
  94197. protected _previousBeta: number;
  94198. protected _previousRadius: number;
  94199. protected _collisionTriggered: boolean;
  94200. protected _targetBoundingCenter: Nullable<Vector3>;
  94201. private _computationVector;
  94202. private _tempAxisVector;
  94203. private _tempAxisRotationMatrix;
  94204. /**
  94205. * Instantiates a new ArcRotateCamera in a given scene
  94206. * @param name Defines the name of the camera
  94207. * @param alpha Defines the camera rotation along the logitudinal axis
  94208. * @param beta Defines the camera rotation along the latitudinal axis
  94209. * @param radius Defines the camera distance from its target
  94210. * @param target Defines the camera target
  94211. * @param scene Defines the scene the camera belongs to
  94212. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94213. */
  94214. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94215. /** @hidden */
  94216. _initCache(): void;
  94217. /** @hidden */
  94218. _updateCache(ignoreParentClass?: boolean): void;
  94219. protected _getTargetPosition(): Vector3;
  94220. private _storedAlpha;
  94221. private _storedBeta;
  94222. private _storedRadius;
  94223. private _storedTarget;
  94224. /**
  94225. * Stores the current state of the camera (alpha, beta, radius and target)
  94226. * @returns the camera itself
  94227. */
  94228. storeState(): Camera;
  94229. /**
  94230. * @hidden
  94231. * Restored camera state. You must call storeState() first
  94232. */
  94233. _restoreStateValues(): boolean;
  94234. /** @hidden */
  94235. _isSynchronizedViewMatrix(): boolean;
  94236. /**
  94237. * Attached controls to the current camera.
  94238. * @param element Defines the element the controls should be listened from
  94239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94240. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  94241. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  94242. */
  94243. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  94244. /**
  94245. * Detach the current controls from the camera.
  94246. * The camera will stop reacting to inputs.
  94247. * @param element Defines the element to stop listening the inputs from
  94248. */
  94249. detachControl(element: HTMLElement): void;
  94250. /** @hidden */
  94251. _checkInputs(): void;
  94252. protected _checkLimits(): void;
  94253. /**
  94254. * Rebuilds angles (alpha, beta) and radius from the give position and target
  94255. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  94256. */
  94257. rebuildAnglesAndRadius(updateView?: boolean): void;
  94258. /**
  94259. * Use a position to define the current camera related information like aplha, beta and radius
  94260. * @param position Defines the position to set the camera at
  94261. */
  94262. setPosition(position: Vector3): void;
  94263. /**
  94264. * Defines the target the camera should look at.
  94265. * This will automatically adapt alpha beta and radius to fit within the new target.
  94266. * @param target Defines the new target as a Vector or a mesh
  94267. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  94268. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  94269. */
  94270. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  94271. /** @hidden */
  94272. _getViewMatrix(): Matrix;
  94273. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  94274. /**
  94275. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  94276. * @param meshes Defines the mesh to zoom on
  94277. * @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)
  94278. */
  94279. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  94280. /**
  94281. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  94282. * The target will be changed but the radius
  94283. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  94284. * @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)
  94285. */
  94286. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  94287. min: Vector3;
  94288. max: Vector3;
  94289. distance: number;
  94290. }, doNotUpdateMaxZ?: boolean): void;
  94291. /**
  94292. * @override
  94293. * Override Camera.createRigCamera
  94294. */
  94295. createRigCamera(name: string, cameraIndex: number): Camera;
  94296. /**
  94297. * @hidden
  94298. * @override
  94299. * Override Camera._updateRigCameras
  94300. */
  94301. _updateRigCameras(): void;
  94302. /**
  94303. * Destroy the camera and release the current resources hold by it.
  94304. */
  94305. dispose(): void;
  94306. /**
  94307. * Gets the current object class name.
  94308. * @return the class name
  94309. */
  94310. getClassName(): string;
  94311. }
  94312. }
  94313. declare module BABYLON {
  94314. /**
  94315. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  94316. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94317. */
  94318. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  94319. /**
  94320. * Gets the name of the behavior.
  94321. */
  94322. readonly name: string;
  94323. private _zoomStopsAnimation;
  94324. private _idleRotationSpeed;
  94325. private _idleRotationWaitTime;
  94326. private _idleRotationSpinupTime;
  94327. /**
  94328. * Sets the flag that indicates if user zooming should stop animation.
  94329. */
  94330. /**
  94331. * Gets the flag that indicates if user zooming should stop animation.
  94332. */
  94333. zoomStopsAnimation: boolean;
  94334. /**
  94335. * Sets the default speed at which the camera rotates around the model.
  94336. */
  94337. /**
  94338. * Gets the default speed at which the camera rotates around the model.
  94339. */
  94340. idleRotationSpeed: number;
  94341. /**
  94342. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  94343. */
  94344. /**
  94345. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  94346. */
  94347. idleRotationWaitTime: number;
  94348. /**
  94349. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94350. */
  94351. /**
  94352. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94353. */
  94354. idleRotationSpinupTime: number;
  94355. /**
  94356. * Gets a value indicating if the camera is currently rotating because of this behavior
  94357. */
  94358. readonly rotationInProgress: boolean;
  94359. private _onPrePointerObservableObserver;
  94360. private _onAfterCheckInputsObserver;
  94361. private _attachedCamera;
  94362. private _isPointerDown;
  94363. private _lastFrameTime;
  94364. private _lastInteractionTime;
  94365. private _cameraRotationSpeed;
  94366. /**
  94367. * Initializes the behavior.
  94368. */
  94369. init(): void;
  94370. /**
  94371. * Attaches the behavior to its arc rotate camera.
  94372. * @param camera Defines the camera to attach the behavior to
  94373. */
  94374. attach(camera: ArcRotateCamera): void;
  94375. /**
  94376. * Detaches the behavior from its current arc rotate camera.
  94377. */
  94378. detach(): void;
  94379. /**
  94380. * Returns true if user is scrolling.
  94381. * @return true if user is scrolling.
  94382. */
  94383. private _userIsZooming;
  94384. private _lastFrameRadius;
  94385. private _shouldAnimationStopForInteraction;
  94386. /**
  94387. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94388. */
  94389. private _applyUserInteraction;
  94390. private _userIsMoving;
  94391. }
  94392. }
  94393. declare module BABYLON {
  94394. /**
  94395. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  94396. */
  94397. export class AttachToBoxBehavior implements Behavior<Mesh> {
  94398. private ui;
  94399. /**
  94400. * The name of the behavior
  94401. */
  94402. name: string;
  94403. /**
  94404. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  94405. */
  94406. distanceAwayFromFace: number;
  94407. /**
  94408. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  94409. */
  94410. distanceAwayFromBottomOfFace: number;
  94411. private _faceVectors;
  94412. private _target;
  94413. private _scene;
  94414. private _onRenderObserver;
  94415. private _tmpMatrix;
  94416. private _tmpVector;
  94417. /**
  94418. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  94419. * @param ui The transform node that should be attched to the mesh
  94420. */
  94421. constructor(ui: TransformNode);
  94422. /**
  94423. * Initializes the behavior
  94424. */
  94425. init(): void;
  94426. private _closestFace;
  94427. private _zeroVector;
  94428. private _lookAtTmpMatrix;
  94429. private _lookAtToRef;
  94430. /**
  94431. * Attaches the AttachToBoxBehavior to the passed in mesh
  94432. * @param target The mesh that the specified node will be attached to
  94433. */
  94434. attach(target: Mesh): void;
  94435. /**
  94436. * Detaches the behavior from the mesh
  94437. */
  94438. detach(): void;
  94439. }
  94440. }
  94441. declare module BABYLON {
  94442. /**
  94443. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  94444. */
  94445. export class FadeInOutBehavior implements Behavior<Mesh> {
  94446. /**
  94447. * Time in milliseconds to delay before fading in (Default: 0)
  94448. */
  94449. delay: number;
  94450. /**
  94451. * Time in milliseconds for the mesh to fade in (Default: 300)
  94452. */
  94453. fadeInTime: number;
  94454. private _millisecondsPerFrame;
  94455. private _hovered;
  94456. private _hoverValue;
  94457. private _ownerNode;
  94458. /**
  94459. * Instatiates the FadeInOutBehavior
  94460. */
  94461. constructor();
  94462. /**
  94463. * The name of the behavior
  94464. */
  94465. readonly name: string;
  94466. /**
  94467. * Initializes the behavior
  94468. */
  94469. init(): void;
  94470. /**
  94471. * Attaches the fade behavior on the passed in mesh
  94472. * @param ownerNode The mesh that will be faded in/out once attached
  94473. */
  94474. attach(ownerNode: Mesh): void;
  94475. /**
  94476. * Detaches the behavior from the mesh
  94477. */
  94478. detach(): void;
  94479. /**
  94480. * Triggers the mesh to begin fading in or out
  94481. * @param value if the object should fade in or out (true to fade in)
  94482. */
  94483. fadeIn(value: boolean): void;
  94484. private _update;
  94485. private _setAllVisibility;
  94486. }
  94487. }
  94488. declare module BABYLON {
  94489. /**
  94490. * Class containing a set of static utilities functions for managing Pivots
  94491. * @hidden
  94492. */
  94493. export class PivotTools {
  94494. private static _PivotCached;
  94495. private static _OldPivotPoint;
  94496. private static _PivotTranslation;
  94497. private static _PivotTmpVector;
  94498. /** @hidden */
  94499. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  94500. /** @hidden */
  94501. static _RestorePivotPoint(mesh: AbstractMesh): void;
  94502. }
  94503. }
  94504. declare module BABYLON {
  94505. /**
  94506. * Class containing static functions to help procedurally build meshes
  94507. */
  94508. export class PlaneBuilder {
  94509. /**
  94510. * Creates a plane mesh
  94511. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  94512. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  94513. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  94514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94517. * @param name defines the name of the mesh
  94518. * @param options defines the options used to create the mesh
  94519. * @param scene defines the hosting scene
  94520. * @returns the plane mesh
  94521. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  94522. */
  94523. static CreatePlane(name: string, options: {
  94524. size?: number;
  94525. width?: number;
  94526. height?: number;
  94527. sideOrientation?: number;
  94528. frontUVs?: Vector4;
  94529. backUVs?: Vector4;
  94530. updatable?: boolean;
  94531. sourcePlane?: Plane;
  94532. }, scene: Scene): Mesh;
  94533. }
  94534. }
  94535. declare module BABYLON {
  94536. /**
  94537. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  94538. */
  94539. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  94540. private static _AnyMouseID;
  94541. private _attachedNode;
  94542. private _dragPlane;
  94543. private _scene;
  94544. private _pointerObserver;
  94545. private _beforeRenderObserver;
  94546. private static _planeScene;
  94547. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  94548. /**
  94549. * 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)
  94550. */
  94551. maxDragAngle: number;
  94552. /**
  94553. * @hidden
  94554. */
  94555. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  94556. /**
  94557. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94558. */
  94559. currentDraggingPointerID: number;
  94560. /**
  94561. * The last position where the pointer hit the drag plane in world space
  94562. */
  94563. lastDragPosition: Vector3;
  94564. /**
  94565. * If the behavior is currently in a dragging state
  94566. */
  94567. dragging: boolean;
  94568. /**
  94569. * 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)
  94570. */
  94571. dragDeltaRatio: number;
  94572. /**
  94573. * If the drag plane orientation should be updated during the dragging (Default: true)
  94574. */
  94575. updateDragPlane: boolean;
  94576. private _debugMode;
  94577. private _moving;
  94578. /**
  94579. * Fires each time the attached mesh is dragged with the pointer
  94580. * * delta between last drag position and current drag position in world space
  94581. * * dragDistance along the drag axis
  94582. * * dragPlaneNormal normal of the current drag plane used during the drag
  94583. * * dragPlanePoint in world space where the drag intersects the drag plane
  94584. */
  94585. onDragObservable: Observable<{
  94586. delta: Vector3;
  94587. dragPlanePoint: Vector3;
  94588. dragPlaneNormal: Vector3;
  94589. dragDistance: number;
  94590. pointerId: number;
  94591. }>;
  94592. /**
  94593. * Fires each time a drag begins (eg. mouse down on mesh)
  94594. */
  94595. onDragStartObservable: Observable<{
  94596. dragPlanePoint: Vector3;
  94597. pointerId: number;
  94598. }>;
  94599. /**
  94600. * Fires each time a drag ends (eg. mouse release after drag)
  94601. */
  94602. onDragEndObservable: Observable<{
  94603. dragPlanePoint: Vector3;
  94604. pointerId: number;
  94605. }>;
  94606. /**
  94607. * If the attached mesh should be moved when dragged
  94608. */
  94609. moveAttached: boolean;
  94610. /**
  94611. * If the drag behavior will react to drag events (Default: true)
  94612. */
  94613. enabled: boolean;
  94614. /**
  94615. * If camera controls should be detached during the drag
  94616. */
  94617. detachCameraControls: boolean;
  94618. /**
  94619. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  94620. */
  94621. useObjectOrienationForDragging: boolean;
  94622. private _options;
  94623. /**
  94624. * Creates a pointer drag behavior that can be attached to a mesh
  94625. * @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)
  94626. */
  94627. constructor(options?: {
  94628. dragAxis?: Vector3;
  94629. dragPlaneNormal?: Vector3;
  94630. });
  94631. /**
  94632. * Predicate to determine if it is valid to move the object to a new position when it is moved
  94633. */
  94634. validateDrag: (targetPosition: Vector3) => boolean;
  94635. /**
  94636. * The name of the behavior
  94637. */
  94638. readonly name: string;
  94639. /**
  94640. * Initializes the behavior
  94641. */
  94642. init(): void;
  94643. private _tmpVector;
  94644. private _alternatePickedPoint;
  94645. private _worldDragAxis;
  94646. private _targetPosition;
  94647. private _attachedElement;
  94648. /**
  94649. * Attaches the drag behavior the passed in mesh
  94650. * @param ownerNode The mesh that will be dragged around once attached
  94651. */
  94652. attach(ownerNode: AbstractMesh): void;
  94653. /**
  94654. * Force relase the drag action by code.
  94655. */
  94656. releaseDrag(): void;
  94657. private _startDragRay;
  94658. private _lastPointerRay;
  94659. /**
  94660. * Simulates the start of a pointer drag event on the behavior
  94661. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  94662. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  94663. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  94664. */
  94665. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  94666. private _startDrag;
  94667. private _dragDelta;
  94668. private _moveDrag;
  94669. private _pickWithRayOnDragPlane;
  94670. private _pointA;
  94671. private _pointB;
  94672. private _pointC;
  94673. private _lineA;
  94674. private _lineB;
  94675. private _localAxis;
  94676. private _lookAt;
  94677. private _updateDragPlanePosition;
  94678. /**
  94679. * Detaches the behavior from the mesh
  94680. */
  94681. detach(): void;
  94682. }
  94683. }
  94684. declare module BABYLON {
  94685. /**
  94686. * A behavior that when attached to a mesh will allow the mesh to be scaled
  94687. */
  94688. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  94689. private _dragBehaviorA;
  94690. private _dragBehaviorB;
  94691. private _startDistance;
  94692. private _initialScale;
  94693. private _targetScale;
  94694. private _ownerNode;
  94695. private _sceneRenderObserver;
  94696. /**
  94697. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  94698. */
  94699. constructor();
  94700. /**
  94701. * The name of the behavior
  94702. */
  94703. readonly name: string;
  94704. /**
  94705. * Initializes the behavior
  94706. */
  94707. init(): void;
  94708. private _getCurrentDistance;
  94709. /**
  94710. * Attaches the scale behavior the passed in mesh
  94711. * @param ownerNode The mesh that will be scaled around once attached
  94712. */
  94713. attach(ownerNode: Mesh): void;
  94714. /**
  94715. * Detaches the behavior from the mesh
  94716. */
  94717. detach(): void;
  94718. }
  94719. }
  94720. declare module BABYLON {
  94721. /**
  94722. * 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
  94723. */
  94724. export class SixDofDragBehavior implements Behavior<Mesh> {
  94725. private static _virtualScene;
  94726. private _ownerNode;
  94727. private _sceneRenderObserver;
  94728. private _scene;
  94729. private _targetPosition;
  94730. private _virtualOriginMesh;
  94731. private _virtualDragMesh;
  94732. private _pointerObserver;
  94733. private _moving;
  94734. private _startingOrientation;
  94735. /**
  94736. * 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)
  94737. */
  94738. private zDragFactor;
  94739. /**
  94740. * If the object should rotate to face the drag origin
  94741. */
  94742. rotateDraggedObject: boolean;
  94743. /**
  94744. * If the behavior is currently in a dragging state
  94745. */
  94746. dragging: boolean;
  94747. /**
  94748. * 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)
  94749. */
  94750. dragDeltaRatio: number;
  94751. /**
  94752. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94753. */
  94754. currentDraggingPointerID: number;
  94755. /**
  94756. * If camera controls should be detached during the drag
  94757. */
  94758. detachCameraControls: boolean;
  94759. /**
  94760. * Fires each time a drag starts
  94761. */
  94762. onDragStartObservable: Observable<{}>;
  94763. /**
  94764. * Fires each time a drag ends (eg. mouse release after drag)
  94765. */
  94766. onDragEndObservable: Observable<{}>;
  94767. /**
  94768. * 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
  94769. */
  94770. constructor();
  94771. /**
  94772. * The name of the behavior
  94773. */
  94774. readonly name: string;
  94775. /**
  94776. * Initializes the behavior
  94777. */
  94778. init(): void;
  94779. /**
  94780. * Attaches the scale behavior the passed in mesh
  94781. * @param ownerNode The mesh that will be scaled around once attached
  94782. */
  94783. attach(ownerNode: Mesh): void;
  94784. /**
  94785. * Detaches the behavior from the mesh
  94786. */
  94787. detach(): void;
  94788. }
  94789. }
  94790. declare module BABYLON {
  94791. /**
  94792. * Class used to apply inverse kinematics to bones
  94793. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  94794. */
  94795. export class BoneIKController {
  94796. private static _tmpVecs;
  94797. private static _tmpQuat;
  94798. private static _tmpMats;
  94799. /**
  94800. * Gets or sets the target mesh
  94801. */
  94802. targetMesh: AbstractMesh;
  94803. /** Gets or sets the mesh used as pole */
  94804. poleTargetMesh: AbstractMesh;
  94805. /**
  94806. * Gets or sets the bone used as pole
  94807. */
  94808. poleTargetBone: Nullable<Bone>;
  94809. /**
  94810. * Gets or sets the target position
  94811. */
  94812. targetPosition: Vector3;
  94813. /**
  94814. * Gets or sets the pole target position
  94815. */
  94816. poleTargetPosition: Vector3;
  94817. /**
  94818. * Gets or sets the pole target local offset
  94819. */
  94820. poleTargetLocalOffset: Vector3;
  94821. /**
  94822. * Gets or sets the pole angle
  94823. */
  94824. poleAngle: number;
  94825. /**
  94826. * Gets or sets the mesh associated with the controller
  94827. */
  94828. mesh: AbstractMesh;
  94829. /**
  94830. * 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)
  94831. */
  94832. slerpAmount: number;
  94833. private _bone1Quat;
  94834. private _bone1Mat;
  94835. private _bone2Ang;
  94836. private _bone1;
  94837. private _bone2;
  94838. private _bone1Length;
  94839. private _bone2Length;
  94840. private _maxAngle;
  94841. private _maxReach;
  94842. private _rightHandedSystem;
  94843. private _bendAxis;
  94844. private _slerping;
  94845. private _adjustRoll;
  94846. /**
  94847. * Gets or sets maximum allowed angle
  94848. */
  94849. maxAngle: number;
  94850. /**
  94851. * Creates a new BoneIKController
  94852. * @param mesh defines the mesh to control
  94853. * @param bone defines the bone to control
  94854. * @param options defines options to set up the controller
  94855. */
  94856. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  94857. targetMesh?: AbstractMesh;
  94858. poleTargetMesh?: AbstractMesh;
  94859. poleTargetBone?: Bone;
  94860. poleTargetLocalOffset?: Vector3;
  94861. poleAngle?: number;
  94862. bendAxis?: Vector3;
  94863. maxAngle?: number;
  94864. slerpAmount?: number;
  94865. });
  94866. private _setMaxAngle;
  94867. /**
  94868. * Force the controller to update the bones
  94869. */
  94870. update(): void;
  94871. }
  94872. }
  94873. declare module BABYLON {
  94874. /**
  94875. * Class used to make a bone look toward a point in space
  94876. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  94877. */
  94878. export class BoneLookController {
  94879. private static _tmpVecs;
  94880. private static _tmpQuat;
  94881. private static _tmpMats;
  94882. /**
  94883. * The target Vector3 that the bone will look at
  94884. */
  94885. target: Vector3;
  94886. /**
  94887. * The mesh that the bone is attached to
  94888. */
  94889. mesh: AbstractMesh;
  94890. /**
  94891. * The bone that will be looking to the target
  94892. */
  94893. bone: Bone;
  94894. /**
  94895. * The up axis of the coordinate system that is used when the bone is rotated
  94896. */
  94897. upAxis: Vector3;
  94898. /**
  94899. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  94900. */
  94901. upAxisSpace: Space;
  94902. /**
  94903. * Used to make an adjustment to the yaw of the bone
  94904. */
  94905. adjustYaw: number;
  94906. /**
  94907. * Used to make an adjustment to the pitch of the bone
  94908. */
  94909. adjustPitch: number;
  94910. /**
  94911. * Used to make an adjustment to the roll of the bone
  94912. */
  94913. adjustRoll: number;
  94914. /**
  94915. * 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)
  94916. */
  94917. slerpAmount: number;
  94918. private _minYaw;
  94919. private _maxYaw;
  94920. private _minPitch;
  94921. private _maxPitch;
  94922. private _minYawSin;
  94923. private _minYawCos;
  94924. private _maxYawSin;
  94925. private _maxYawCos;
  94926. private _midYawConstraint;
  94927. private _minPitchTan;
  94928. private _maxPitchTan;
  94929. private _boneQuat;
  94930. private _slerping;
  94931. private _transformYawPitch;
  94932. private _transformYawPitchInv;
  94933. private _firstFrameSkipped;
  94934. private _yawRange;
  94935. private _fowardAxis;
  94936. /**
  94937. * Gets or sets the minimum yaw angle that the bone can look to
  94938. */
  94939. minYaw: number;
  94940. /**
  94941. * Gets or sets the maximum yaw angle that the bone can look to
  94942. */
  94943. maxYaw: number;
  94944. /**
  94945. * Gets or sets the minimum pitch angle that the bone can look to
  94946. */
  94947. minPitch: number;
  94948. /**
  94949. * Gets or sets the maximum pitch angle that the bone can look to
  94950. */
  94951. maxPitch: number;
  94952. /**
  94953. * Create a BoneLookController
  94954. * @param mesh the mesh that the bone belongs to
  94955. * @param bone the bone that will be looking to the target
  94956. * @param target the target Vector3 to look at
  94957. * @param options optional settings:
  94958. * * maxYaw: the maximum angle the bone will yaw to
  94959. * * minYaw: the minimum angle the bone will yaw to
  94960. * * maxPitch: the maximum angle the bone will pitch to
  94961. * * minPitch: the minimum angle the bone will yaw to
  94962. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  94963. * * upAxis: the up axis of the coordinate system
  94964. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  94965. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  94966. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  94967. * * adjustYaw: used to make an adjustment to the yaw of the bone
  94968. * * adjustPitch: used to make an adjustment to the pitch of the bone
  94969. * * adjustRoll: used to make an adjustment to the roll of the bone
  94970. **/
  94971. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  94972. maxYaw?: number;
  94973. minYaw?: number;
  94974. maxPitch?: number;
  94975. minPitch?: number;
  94976. slerpAmount?: number;
  94977. upAxis?: Vector3;
  94978. upAxisSpace?: Space;
  94979. yawAxis?: Vector3;
  94980. pitchAxis?: Vector3;
  94981. adjustYaw?: number;
  94982. adjustPitch?: number;
  94983. adjustRoll?: number;
  94984. });
  94985. /**
  94986. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  94987. */
  94988. update(): void;
  94989. private _getAngleDiff;
  94990. private _getAngleBetween;
  94991. private _isAngleBetween;
  94992. }
  94993. }
  94994. declare module BABYLON {
  94995. /**
  94996. * Manage the gamepad inputs to control an arc rotate camera.
  94997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94998. */
  94999. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  95000. /**
  95001. * Defines the camera the input is attached to.
  95002. */
  95003. camera: ArcRotateCamera;
  95004. /**
  95005. * Defines the gamepad the input is gathering event from.
  95006. */
  95007. gamepad: Nullable<Gamepad>;
  95008. /**
  95009. * Defines the gamepad rotation sensiblity.
  95010. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95011. */
  95012. gamepadRotationSensibility: number;
  95013. /**
  95014. * Defines the gamepad move sensiblity.
  95015. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95016. */
  95017. gamepadMoveSensibility: number;
  95018. private _onGamepadConnectedObserver;
  95019. private _onGamepadDisconnectedObserver;
  95020. /**
  95021. * Attach the input controls to a specific dom element to get the input from.
  95022. * @param element Defines the element the controls should be listened from
  95023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95024. */
  95025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95026. /**
  95027. * Detach the current controls from the specified dom element.
  95028. * @param element Defines the element to stop listening the inputs from
  95029. */
  95030. detachControl(element: Nullable<HTMLElement>): void;
  95031. /**
  95032. * Update the current camera state depending on the inputs that have been used this frame.
  95033. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95034. */
  95035. checkInputs(): void;
  95036. /**
  95037. * Gets the class name of the current intput.
  95038. * @returns the class name
  95039. */
  95040. getClassName(): string;
  95041. /**
  95042. * Get the friendly name associated with the input class.
  95043. * @returns the input friendly name
  95044. */
  95045. getSimpleName(): string;
  95046. }
  95047. }
  95048. declare module BABYLON {
  95049. interface ArcRotateCameraInputsManager {
  95050. /**
  95051. * Add orientation input support to the input manager.
  95052. * @returns the current input manager
  95053. */
  95054. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  95055. }
  95056. /**
  95057. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  95058. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95059. */
  95060. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  95061. /**
  95062. * Defines the camera the input is attached to.
  95063. */
  95064. camera: ArcRotateCamera;
  95065. /**
  95066. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  95067. */
  95068. alphaCorrection: number;
  95069. /**
  95070. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  95071. */
  95072. gammaCorrection: number;
  95073. private _alpha;
  95074. private _gamma;
  95075. private _dirty;
  95076. private _deviceOrientationHandler;
  95077. /**
  95078. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  95079. */
  95080. constructor();
  95081. /**
  95082. * Attach the input controls to a specific dom element to get the input from.
  95083. * @param element Defines the element the controls should be listened from
  95084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95085. */
  95086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95087. /** @hidden */
  95088. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  95089. /**
  95090. * Update the current camera state depending on the inputs that have been used this frame.
  95091. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95092. */
  95093. checkInputs(): void;
  95094. /**
  95095. * Detach the current controls from the specified dom element.
  95096. * @param element Defines the element to stop listening the inputs from
  95097. */
  95098. detachControl(element: Nullable<HTMLElement>): void;
  95099. /**
  95100. * Gets the class name of the current intput.
  95101. * @returns the class name
  95102. */
  95103. getClassName(): string;
  95104. /**
  95105. * Get the friendly name associated with the input class.
  95106. * @returns the input friendly name
  95107. */
  95108. getSimpleName(): string;
  95109. }
  95110. }
  95111. declare module BABYLON {
  95112. /**
  95113. * Listen to mouse events to control the camera.
  95114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95115. */
  95116. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  95117. /**
  95118. * Defines the camera the input is attached to.
  95119. */
  95120. camera: FlyCamera;
  95121. /**
  95122. * Defines if touch is enabled. (Default is true.)
  95123. */
  95124. touchEnabled: boolean;
  95125. /**
  95126. * Defines the buttons associated with the input to handle camera rotation.
  95127. */
  95128. buttons: number[];
  95129. /**
  95130. * Assign buttons for Yaw control.
  95131. */
  95132. buttonsYaw: number[];
  95133. /**
  95134. * Assign buttons for Pitch control.
  95135. */
  95136. buttonsPitch: number[];
  95137. /**
  95138. * Assign buttons for Roll control.
  95139. */
  95140. buttonsRoll: number[];
  95141. /**
  95142. * Detect if any button is being pressed while mouse is moved.
  95143. * -1 = Mouse locked.
  95144. * 0 = Left button.
  95145. * 1 = Middle Button.
  95146. * 2 = Right Button.
  95147. */
  95148. activeButton: number;
  95149. /**
  95150. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  95151. * Higher values reduce its sensitivity.
  95152. */
  95153. angularSensibility: number;
  95154. private _mousemoveCallback;
  95155. private _observer;
  95156. private _rollObserver;
  95157. private previousPosition;
  95158. private noPreventDefault;
  95159. private element;
  95160. /**
  95161. * Listen to mouse events to control the camera.
  95162. * @param touchEnabled Define if touch is enabled. (Default is true.)
  95163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95164. */
  95165. constructor(touchEnabled?: boolean);
  95166. /**
  95167. * Attach the mouse control to the HTML DOM element.
  95168. * @param element Defines the element that listens to the input events.
  95169. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  95170. */
  95171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95172. /**
  95173. * Detach the current controls from the specified dom element.
  95174. * @param element Defines the element to stop listening the inputs from
  95175. */
  95176. detachControl(element: Nullable<HTMLElement>): void;
  95177. /**
  95178. * Gets the class name of the current input.
  95179. * @returns the class name.
  95180. */
  95181. getClassName(): string;
  95182. /**
  95183. * Get the friendly name associated with the input class.
  95184. * @returns the input's friendly name.
  95185. */
  95186. getSimpleName(): string;
  95187. private _pointerInput;
  95188. private _onMouseMove;
  95189. /**
  95190. * Rotate camera by mouse offset.
  95191. */
  95192. private rotateCamera;
  95193. }
  95194. }
  95195. declare module BABYLON {
  95196. /**
  95197. * Default Inputs manager for the FlyCamera.
  95198. * It groups all the default supported inputs for ease of use.
  95199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95200. */
  95201. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  95202. /**
  95203. * Instantiates a new FlyCameraInputsManager.
  95204. * @param camera Defines the camera the inputs belong to.
  95205. */
  95206. constructor(camera: FlyCamera);
  95207. /**
  95208. * Add keyboard input support to the input manager.
  95209. * @returns the new FlyCameraKeyboardMoveInput().
  95210. */
  95211. addKeyboard(): FlyCameraInputsManager;
  95212. /**
  95213. * Add mouse input support to the input manager.
  95214. * @param touchEnabled Enable touch screen support.
  95215. * @returns the new FlyCameraMouseInput().
  95216. */
  95217. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  95218. }
  95219. }
  95220. declare module BABYLON {
  95221. /**
  95222. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95223. * such as in a 3D Space Shooter or a Flight Simulator.
  95224. */
  95225. export class FlyCamera extends TargetCamera {
  95226. /**
  95227. * Define the collision ellipsoid of the camera.
  95228. * This is helpful for simulating a camera body, like a player's body.
  95229. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95230. */
  95231. ellipsoid: Vector3;
  95232. /**
  95233. * Define an offset for the position of the ellipsoid around the camera.
  95234. * This can be helpful if the camera is attached away from the player's body center,
  95235. * such as at its head.
  95236. */
  95237. ellipsoidOffset: Vector3;
  95238. /**
  95239. * Enable or disable collisions of the camera with the rest of the scene objects.
  95240. */
  95241. checkCollisions: boolean;
  95242. /**
  95243. * Enable or disable gravity on the camera.
  95244. */
  95245. applyGravity: boolean;
  95246. /**
  95247. * Define the current direction the camera is moving to.
  95248. */
  95249. cameraDirection: Vector3;
  95250. /**
  95251. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  95252. * This overrides and empties cameraRotation.
  95253. */
  95254. rotationQuaternion: Quaternion;
  95255. /**
  95256. * Track Roll to maintain the wanted Rolling when looking around.
  95257. */
  95258. _trackRoll: number;
  95259. /**
  95260. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  95261. */
  95262. rollCorrect: number;
  95263. /**
  95264. * Mimic a banked turn, Rolling the camera when Yawing.
  95265. * It's recommended to use rollCorrect = 10 for faster banking correction.
  95266. */
  95267. bankedTurn: boolean;
  95268. /**
  95269. * Limit in radians for how much Roll banking will add. (Default: 90°)
  95270. */
  95271. bankedTurnLimit: number;
  95272. /**
  95273. * Value of 0 disables the banked Roll.
  95274. * Value of 1 is equal to the Yaw angle in radians.
  95275. */
  95276. bankedTurnMultiplier: number;
  95277. /**
  95278. * The inputs manager loads all the input sources, such as keyboard and mouse.
  95279. */
  95280. inputs: FlyCameraInputsManager;
  95281. /**
  95282. * Gets the input sensibility for mouse input.
  95283. * Higher values reduce sensitivity.
  95284. */
  95285. /**
  95286. * Sets the input sensibility for a mouse input.
  95287. * Higher values reduce sensitivity.
  95288. */
  95289. angularSensibility: number;
  95290. /**
  95291. * Get the keys for camera movement forward.
  95292. */
  95293. /**
  95294. * Set the keys for camera movement forward.
  95295. */
  95296. keysForward: number[];
  95297. /**
  95298. * Get the keys for camera movement backward.
  95299. */
  95300. keysBackward: number[];
  95301. /**
  95302. * Get the keys for camera movement up.
  95303. */
  95304. /**
  95305. * Set the keys for camera movement up.
  95306. */
  95307. keysUp: number[];
  95308. /**
  95309. * Get the keys for camera movement down.
  95310. */
  95311. /**
  95312. * Set the keys for camera movement down.
  95313. */
  95314. keysDown: number[];
  95315. /**
  95316. * Get the keys for camera movement left.
  95317. */
  95318. /**
  95319. * Set the keys for camera movement left.
  95320. */
  95321. keysLeft: number[];
  95322. /**
  95323. * Set the keys for camera movement right.
  95324. */
  95325. /**
  95326. * Set the keys for camera movement right.
  95327. */
  95328. keysRight: number[];
  95329. /**
  95330. * Event raised when the camera collides with a mesh in the scene.
  95331. */
  95332. onCollide: (collidedMesh: AbstractMesh) => void;
  95333. private _collider;
  95334. private _needMoveForGravity;
  95335. private _oldPosition;
  95336. private _diffPosition;
  95337. private _newPosition;
  95338. /** @hidden */
  95339. _localDirection: Vector3;
  95340. /** @hidden */
  95341. _transformedDirection: Vector3;
  95342. /**
  95343. * Instantiates a FlyCamera.
  95344. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95345. * such as in a 3D Space Shooter or a Flight Simulator.
  95346. * @param name Define the name of the camera in the scene.
  95347. * @param position Define the starting position of the camera in the scene.
  95348. * @param scene Define the scene the camera belongs to.
  95349. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  95350. */
  95351. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95352. /**
  95353. * Attach a control to the HTML DOM element.
  95354. * @param element Defines the element that listens to the input events.
  95355. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  95356. */
  95357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95358. /**
  95359. * Detach a control from the HTML DOM element.
  95360. * The camera will stop reacting to that input.
  95361. * @param element Defines the element that listens to the input events.
  95362. */
  95363. detachControl(element: HTMLElement): void;
  95364. private _collisionMask;
  95365. /**
  95366. * Get the mask that the camera ignores in collision events.
  95367. */
  95368. /**
  95369. * Set the mask that the camera ignores in collision events.
  95370. */
  95371. collisionMask: number;
  95372. /** @hidden */
  95373. _collideWithWorld(displacement: Vector3): void;
  95374. /** @hidden */
  95375. private _onCollisionPositionChange;
  95376. /** @hidden */
  95377. _checkInputs(): void;
  95378. /** @hidden */
  95379. _decideIfNeedsToMove(): boolean;
  95380. /** @hidden */
  95381. _updatePosition(): void;
  95382. /**
  95383. * Restore the Roll to its target value at the rate specified.
  95384. * @param rate - Higher means slower restoring.
  95385. * @hidden
  95386. */
  95387. restoreRoll(rate: number): void;
  95388. /**
  95389. * Destroy the camera and release the current resources held by it.
  95390. */
  95391. dispose(): void;
  95392. /**
  95393. * Get the current object class name.
  95394. * @returns the class name.
  95395. */
  95396. getClassName(): string;
  95397. }
  95398. }
  95399. declare module BABYLON {
  95400. /**
  95401. * Listen to keyboard events to control the camera.
  95402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95403. */
  95404. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  95405. /**
  95406. * Defines the camera the input is attached to.
  95407. */
  95408. camera: FlyCamera;
  95409. /**
  95410. * The list of keyboard keys used to control the forward move of the camera.
  95411. */
  95412. keysForward: number[];
  95413. /**
  95414. * The list of keyboard keys used to control the backward move of the camera.
  95415. */
  95416. keysBackward: number[];
  95417. /**
  95418. * The list of keyboard keys used to control the forward move of the camera.
  95419. */
  95420. keysUp: number[];
  95421. /**
  95422. * The list of keyboard keys used to control the backward move of the camera.
  95423. */
  95424. keysDown: number[];
  95425. /**
  95426. * The list of keyboard keys used to control the right strafe move of the camera.
  95427. */
  95428. keysRight: number[];
  95429. /**
  95430. * The list of keyboard keys used to control the left strafe move of the camera.
  95431. */
  95432. keysLeft: number[];
  95433. private _keys;
  95434. private _onCanvasBlurObserver;
  95435. private _onKeyboardObserver;
  95436. private _engine;
  95437. private _scene;
  95438. /**
  95439. * Attach the input controls to a specific dom element to get the input from.
  95440. * @param element Defines the element the controls should be listened from
  95441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95442. */
  95443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95444. /**
  95445. * Detach the current controls from the specified dom element.
  95446. * @param element Defines the element to stop listening the inputs from
  95447. */
  95448. detachControl(element: Nullable<HTMLElement>): void;
  95449. /**
  95450. * Gets the class name of the current intput.
  95451. * @returns the class name
  95452. */
  95453. getClassName(): string;
  95454. /** @hidden */
  95455. _onLostFocus(e: FocusEvent): void;
  95456. /**
  95457. * Get the friendly name associated with the input class.
  95458. * @returns the input friendly name
  95459. */
  95460. getSimpleName(): string;
  95461. /**
  95462. * Update the current camera state depending on the inputs that have been used this frame.
  95463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95464. */
  95465. checkInputs(): void;
  95466. }
  95467. }
  95468. declare module BABYLON {
  95469. /**
  95470. * Manage the mouse wheel inputs to control a follow camera.
  95471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95472. */
  95473. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  95474. /**
  95475. * Defines the camera the input is attached to.
  95476. */
  95477. camera: FollowCamera;
  95478. /**
  95479. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  95480. */
  95481. axisControlRadius: boolean;
  95482. /**
  95483. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  95484. */
  95485. axisControlHeight: boolean;
  95486. /**
  95487. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  95488. */
  95489. axisControlRotation: boolean;
  95490. /**
  95491. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  95492. * relation to mouseWheel events.
  95493. */
  95494. wheelPrecision: number;
  95495. /**
  95496. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95497. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95498. */
  95499. wheelDeltaPercentage: number;
  95500. private _wheel;
  95501. private _observer;
  95502. /**
  95503. * Attach the input controls to a specific dom element to get the input from.
  95504. * @param element Defines the element the controls should be listened from
  95505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95506. */
  95507. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95508. /**
  95509. * Detach the current controls from the specified dom element.
  95510. * @param element Defines the element to stop listening the inputs from
  95511. */
  95512. detachControl(element: Nullable<HTMLElement>): void;
  95513. /**
  95514. * Gets the class name of the current intput.
  95515. * @returns the class name
  95516. */
  95517. getClassName(): string;
  95518. /**
  95519. * Get the friendly name associated with the input class.
  95520. * @returns the input friendly name
  95521. */
  95522. getSimpleName(): string;
  95523. }
  95524. }
  95525. declare module BABYLON {
  95526. /**
  95527. * Manage the pointers inputs to control an follow camera.
  95528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95529. */
  95530. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  95531. /**
  95532. * Defines the camera the input is attached to.
  95533. */
  95534. camera: FollowCamera;
  95535. /**
  95536. * Gets the class name of the current input.
  95537. * @returns the class name
  95538. */
  95539. getClassName(): string;
  95540. /**
  95541. * Defines the pointer angular sensibility along the X axis or how fast is
  95542. * the camera rotating.
  95543. * A negative number will reverse the axis direction.
  95544. */
  95545. angularSensibilityX: number;
  95546. /**
  95547. * Defines the pointer angular sensibility along the Y axis or how fast is
  95548. * the camera rotating.
  95549. * A negative number will reverse the axis direction.
  95550. */
  95551. angularSensibilityY: number;
  95552. /**
  95553. * Defines the pointer pinch precision or how fast is the camera zooming.
  95554. * A negative number will reverse the axis direction.
  95555. */
  95556. pinchPrecision: number;
  95557. /**
  95558. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  95559. * from 0.
  95560. * It defines the percentage of current camera.radius to use as delta when
  95561. * pinch zoom is used.
  95562. */
  95563. pinchDeltaPercentage: number;
  95564. /**
  95565. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  95566. */
  95567. axisXControlRadius: boolean;
  95568. /**
  95569. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  95570. */
  95571. axisXControlHeight: boolean;
  95572. /**
  95573. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  95574. */
  95575. axisXControlRotation: boolean;
  95576. /**
  95577. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  95578. */
  95579. axisYControlRadius: boolean;
  95580. /**
  95581. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  95582. */
  95583. axisYControlHeight: boolean;
  95584. /**
  95585. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  95586. */
  95587. axisYControlRotation: boolean;
  95588. /**
  95589. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  95590. */
  95591. axisPinchControlRadius: boolean;
  95592. /**
  95593. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  95594. */
  95595. axisPinchControlHeight: boolean;
  95596. /**
  95597. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  95598. */
  95599. axisPinchControlRotation: boolean;
  95600. /**
  95601. * Log error messages if basic misconfiguration has occurred.
  95602. */
  95603. warningEnable: boolean;
  95604. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95605. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95606. private _warningCounter;
  95607. private _warning;
  95608. }
  95609. }
  95610. declare module BABYLON {
  95611. /**
  95612. * Default Inputs manager for the FollowCamera.
  95613. * It groups all the default supported inputs for ease of use.
  95614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95615. */
  95616. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  95617. /**
  95618. * Instantiates a new FollowCameraInputsManager.
  95619. * @param camera Defines the camera the inputs belong to
  95620. */
  95621. constructor(camera: FollowCamera);
  95622. /**
  95623. * Add keyboard input support to the input manager.
  95624. * @returns the current input manager
  95625. */
  95626. addKeyboard(): FollowCameraInputsManager;
  95627. /**
  95628. * Add mouse wheel input support to the input manager.
  95629. * @returns the current input manager
  95630. */
  95631. addMouseWheel(): FollowCameraInputsManager;
  95632. /**
  95633. * Add pointers input support to the input manager.
  95634. * @returns the current input manager
  95635. */
  95636. addPointers(): FollowCameraInputsManager;
  95637. /**
  95638. * Add orientation input support to the input manager.
  95639. * @returns the current input manager
  95640. */
  95641. addVRDeviceOrientation(): FollowCameraInputsManager;
  95642. }
  95643. }
  95644. declare module BABYLON {
  95645. /**
  95646. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  95647. * an arc rotate version arcFollowCamera are available.
  95648. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95649. */
  95650. export class FollowCamera extends TargetCamera {
  95651. /**
  95652. * Distance the follow camera should follow an object at
  95653. */
  95654. radius: number;
  95655. /**
  95656. * Minimum allowed distance of the camera to the axis of rotation
  95657. * (The camera can not get closer).
  95658. * This can help limiting how the Camera is able to move in the scene.
  95659. */
  95660. lowerRadiusLimit: Nullable<number>;
  95661. /**
  95662. * Maximum allowed distance of the camera to the axis of rotation
  95663. * (The camera can not get further).
  95664. * This can help limiting how the Camera is able to move in the scene.
  95665. */
  95666. upperRadiusLimit: Nullable<number>;
  95667. /**
  95668. * Define a rotation offset between the camera and the object it follows
  95669. */
  95670. rotationOffset: number;
  95671. /**
  95672. * Minimum allowed angle to camera position relative to target object.
  95673. * This can help limiting how the Camera is able to move in the scene.
  95674. */
  95675. lowerRotationOffsetLimit: Nullable<number>;
  95676. /**
  95677. * Maximum allowed angle to camera position relative to target object.
  95678. * This can help limiting how the Camera is able to move in the scene.
  95679. */
  95680. upperRotationOffsetLimit: Nullable<number>;
  95681. /**
  95682. * Define a height offset between the camera and the object it follows.
  95683. * It can help following an object from the top (like a car chaing a plane)
  95684. */
  95685. heightOffset: number;
  95686. /**
  95687. * Minimum allowed height of camera position relative to target object.
  95688. * This can help limiting how the Camera is able to move in the scene.
  95689. */
  95690. lowerHeightOffsetLimit: Nullable<number>;
  95691. /**
  95692. * Maximum allowed height of camera position relative to target object.
  95693. * This can help limiting how the Camera is able to move in the scene.
  95694. */
  95695. upperHeightOffsetLimit: Nullable<number>;
  95696. /**
  95697. * Define how fast the camera can accelerate to follow it s target.
  95698. */
  95699. cameraAcceleration: number;
  95700. /**
  95701. * Define the speed limit of the camera following an object.
  95702. */
  95703. maxCameraSpeed: number;
  95704. /**
  95705. * Define the target of the camera.
  95706. */
  95707. lockedTarget: Nullable<AbstractMesh>;
  95708. /**
  95709. * Defines the input associated with the camera.
  95710. */
  95711. inputs: FollowCameraInputsManager;
  95712. /**
  95713. * Instantiates the follow camera.
  95714. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95715. * @param name Define the name of the camera in the scene
  95716. * @param position Define the position of the camera
  95717. * @param scene Define the scene the camera belong to
  95718. * @param lockedTarget Define the target of the camera
  95719. */
  95720. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  95721. private _follow;
  95722. /**
  95723. * Attached controls to the current camera.
  95724. * @param element Defines the element the controls should be listened from
  95725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95726. */
  95727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95728. /**
  95729. * Detach the current controls from the camera.
  95730. * The camera will stop reacting to inputs.
  95731. * @param element Defines the element to stop listening the inputs from
  95732. */
  95733. detachControl(element: HTMLElement): void;
  95734. /** @hidden */
  95735. _checkInputs(): void;
  95736. private _checkLimits;
  95737. /**
  95738. * Gets the camera class name.
  95739. * @returns the class name
  95740. */
  95741. getClassName(): string;
  95742. }
  95743. /**
  95744. * Arc Rotate version of the follow camera.
  95745. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  95746. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95747. */
  95748. export class ArcFollowCamera extends TargetCamera {
  95749. /** The longitudinal angle of the camera */
  95750. alpha: number;
  95751. /** The latitudinal angle of the camera */
  95752. beta: number;
  95753. /** The radius of the camera from its target */
  95754. radius: number;
  95755. /** Define the camera target (the messh it should follow) */
  95756. target: Nullable<AbstractMesh>;
  95757. private _cartesianCoordinates;
  95758. /**
  95759. * Instantiates a new ArcFollowCamera
  95760. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95761. * @param name Define the name of the camera
  95762. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  95763. * @param beta Define the rotation angle of the camera around the elevation axis
  95764. * @param radius Define the radius of the camera from its target point
  95765. * @param target Define the target of the camera
  95766. * @param scene Define the scene the camera belongs to
  95767. */
  95768. constructor(name: string,
  95769. /** The longitudinal angle of the camera */
  95770. alpha: number,
  95771. /** The latitudinal angle of the camera */
  95772. beta: number,
  95773. /** The radius of the camera from its target */
  95774. radius: number,
  95775. /** Define the camera target (the messh it should follow) */
  95776. target: Nullable<AbstractMesh>, scene: Scene);
  95777. private _follow;
  95778. /** @hidden */
  95779. _checkInputs(): void;
  95780. /**
  95781. * Returns the class name of the object.
  95782. * It is mostly used internally for serialization purposes.
  95783. */
  95784. getClassName(): string;
  95785. }
  95786. }
  95787. declare module BABYLON {
  95788. /**
  95789. * Manage the keyboard inputs to control the movement of a follow camera.
  95790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95791. */
  95792. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  95793. /**
  95794. * Defines the camera the input is attached to.
  95795. */
  95796. camera: FollowCamera;
  95797. /**
  95798. * Defines the list of key codes associated with the up action (increase heightOffset)
  95799. */
  95800. keysHeightOffsetIncr: number[];
  95801. /**
  95802. * Defines the list of key codes associated with the down action (decrease heightOffset)
  95803. */
  95804. keysHeightOffsetDecr: number[];
  95805. /**
  95806. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  95807. */
  95808. keysHeightOffsetModifierAlt: boolean;
  95809. /**
  95810. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  95811. */
  95812. keysHeightOffsetModifierCtrl: boolean;
  95813. /**
  95814. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  95815. */
  95816. keysHeightOffsetModifierShift: boolean;
  95817. /**
  95818. * Defines the list of key codes associated with the left action (increase rotationOffset)
  95819. */
  95820. keysRotationOffsetIncr: number[];
  95821. /**
  95822. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  95823. */
  95824. keysRotationOffsetDecr: number[];
  95825. /**
  95826. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  95827. */
  95828. keysRotationOffsetModifierAlt: boolean;
  95829. /**
  95830. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  95831. */
  95832. keysRotationOffsetModifierCtrl: boolean;
  95833. /**
  95834. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  95835. */
  95836. keysRotationOffsetModifierShift: boolean;
  95837. /**
  95838. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  95839. */
  95840. keysRadiusIncr: number[];
  95841. /**
  95842. * Defines the list of key codes associated with the zoom-out action (increase radius)
  95843. */
  95844. keysRadiusDecr: number[];
  95845. /**
  95846. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  95847. */
  95848. keysRadiusModifierAlt: boolean;
  95849. /**
  95850. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  95851. */
  95852. keysRadiusModifierCtrl: boolean;
  95853. /**
  95854. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  95855. */
  95856. keysRadiusModifierShift: boolean;
  95857. /**
  95858. * Defines the rate of change of heightOffset.
  95859. */
  95860. heightSensibility: number;
  95861. /**
  95862. * Defines the rate of change of rotationOffset.
  95863. */
  95864. rotationSensibility: number;
  95865. /**
  95866. * Defines the rate of change of radius.
  95867. */
  95868. radiusSensibility: number;
  95869. private _keys;
  95870. private _ctrlPressed;
  95871. private _altPressed;
  95872. private _shiftPressed;
  95873. private _onCanvasBlurObserver;
  95874. private _onKeyboardObserver;
  95875. private _engine;
  95876. private _scene;
  95877. /**
  95878. * Attach the input controls to a specific dom element to get the input from.
  95879. * @param element Defines the element the controls should be listened from
  95880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95881. */
  95882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95883. /**
  95884. * Detach the current controls from the specified dom element.
  95885. * @param element Defines the element to stop listening the inputs from
  95886. */
  95887. detachControl(element: Nullable<HTMLElement>): void;
  95888. /**
  95889. * Update the current camera state depending on the inputs that have been used this frame.
  95890. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95891. */
  95892. checkInputs(): void;
  95893. /**
  95894. * Gets the class name of the current input.
  95895. * @returns the class name
  95896. */
  95897. getClassName(): string;
  95898. /**
  95899. * Get the friendly name associated with the input class.
  95900. * @returns the input friendly name
  95901. */
  95902. getSimpleName(): string;
  95903. /**
  95904. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95905. * allow modification of the heightOffset value.
  95906. */
  95907. private _modifierHeightOffset;
  95908. /**
  95909. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95910. * allow modification of the rotationOffset value.
  95911. */
  95912. private _modifierRotationOffset;
  95913. /**
  95914. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95915. * allow modification of the radius value.
  95916. */
  95917. private _modifierRadius;
  95918. }
  95919. }
  95920. declare module BABYLON {
  95921. interface FreeCameraInputsManager {
  95922. /**
  95923. * @hidden
  95924. */
  95925. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  95926. /**
  95927. * Add orientation input support to the input manager.
  95928. * @returns the current input manager
  95929. */
  95930. addDeviceOrientation(): FreeCameraInputsManager;
  95931. }
  95932. /**
  95933. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  95934. * Screen rotation is taken into account.
  95935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95936. */
  95937. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  95938. private _camera;
  95939. private _screenOrientationAngle;
  95940. private _constantTranform;
  95941. private _screenQuaternion;
  95942. private _alpha;
  95943. private _beta;
  95944. private _gamma;
  95945. /**
  95946. * @hidden
  95947. */
  95948. _onDeviceOrientationChangedObservable: Observable<void>;
  95949. /**
  95950. * Instantiates a new input
  95951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95952. */
  95953. constructor();
  95954. /**
  95955. * Define the camera controlled by the input.
  95956. */
  95957. camera: FreeCamera;
  95958. /**
  95959. * Attach the input controls to a specific dom element to get the input from.
  95960. * @param element Defines the element the controls should be listened from
  95961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95962. */
  95963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95964. private _orientationChanged;
  95965. private _deviceOrientation;
  95966. /**
  95967. * Detach the current controls from the specified dom element.
  95968. * @param element Defines the element to stop listening the inputs from
  95969. */
  95970. detachControl(element: Nullable<HTMLElement>): void;
  95971. /**
  95972. * Update the current camera state depending on the inputs that have been used this frame.
  95973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95974. */
  95975. checkInputs(): void;
  95976. /**
  95977. * Gets the class name of the current intput.
  95978. * @returns the class name
  95979. */
  95980. getClassName(): string;
  95981. /**
  95982. * Get the friendly name associated with the input class.
  95983. * @returns the input friendly name
  95984. */
  95985. getSimpleName(): string;
  95986. }
  95987. }
  95988. declare module BABYLON {
  95989. /**
  95990. * Manage the gamepad inputs to control a free camera.
  95991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95992. */
  95993. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  95994. /**
  95995. * Define the camera the input is attached to.
  95996. */
  95997. camera: FreeCamera;
  95998. /**
  95999. * Define the Gamepad controlling the input
  96000. */
  96001. gamepad: Nullable<Gamepad>;
  96002. /**
  96003. * Defines the gamepad rotation sensiblity.
  96004. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96005. */
  96006. gamepadAngularSensibility: number;
  96007. /**
  96008. * Defines the gamepad move sensiblity.
  96009. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96010. */
  96011. gamepadMoveSensibility: number;
  96012. private _onGamepadConnectedObserver;
  96013. private _onGamepadDisconnectedObserver;
  96014. private _cameraTransform;
  96015. private _deltaTransform;
  96016. private _vector3;
  96017. private _vector2;
  96018. /**
  96019. * Attach the input controls to a specific dom element to get the input from.
  96020. * @param element Defines the element the controls should be listened from
  96021. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96022. */
  96023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96024. /**
  96025. * Detach the current controls from the specified dom element.
  96026. * @param element Defines the element to stop listening the inputs from
  96027. */
  96028. detachControl(element: Nullable<HTMLElement>): void;
  96029. /**
  96030. * Update the current camera state depending on the inputs that have been used this frame.
  96031. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96032. */
  96033. checkInputs(): void;
  96034. /**
  96035. * Gets the class name of the current intput.
  96036. * @returns the class name
  96037. */
  96038. getClassName(): string;
  96039. /**
  96040. * Get the friendly name associated with the input class.
  96041. * @returns the input friendly name
  96042. */
  96043. getSimpleName(): string;
  96044. }
  96045. }
  96046. declare module BABYLON {
  96047. /**
  96048. * Defines the potential axis of a Joystick
  96049. */
  96050. export enum JoystickAxis {
  96051. /** X axis */
  96052. X = 0,
  96053. /** Y axis */
  96054. Y = 1,
  96055. /** Z axis */
  96056. Z = 2
  96057. }
  96058. /**
  96059. * Class used to define virtual joystick (used in touch mode)
  96060. */
  96061. export class VirtualJoystick {
  96062. /**
  96063. * Gets or sets a boolean indicating that left and right values must be inverted
  96064. */
  96065. reverseLeftRight: boolean;
  96066. /**
  96067. * Gets or sets a boolean indicating that up and down values must be inverted
  96068. */
  96069. reverseUpDown: boolean;
  96070. /**
  96071. * Gets the offset value for the position (ie. the change of the position value)
  96072. */
  96073. deltaPosition: Vector3;
  96074. /**
  96075. * Gets a boolean indicating if the virtual joystick was pressed
  96076. */
  96077. pressed: boolean;
  96078. /**
  96079. * Canvas the virtual joystick will render onto, default z-index of this is 5
  96080. */
  96081. static Canvas: Nullable<HTMLCanvasElement>;
  96082. private static _globalJoystickIndex;
  96083. private static vjCanvasContext;
  96084. private static vjCanvasWidth;
  96085. private static vjCanvasHeight;
  96086. private static halfWidth;
  96087. private _action;
  96088. private _axisTargetedByLeftAndRight;
  96089. private _axisTargetedByUpAndDown;
  96090. private _joystickSensibility;
  96091. private _inversedSensibility;
  96092. private _joystickPointerID;
  96093. private _joystickColor;
  96094. private _joystickPointerPos;
  96095. private _joystickPreviousPointerPos;
  96096. private _joystickPointerStartPos;
  96097. private _deltaJoystickVector;
  96098. private _leftJoystick;
  96099. private _touches;
  96100. private _onPointerDownHandlerRef;
  96101. private _onPointerMoveHandlerRef;
  96102. private _onPointerUpHandlerRef;
  96103. private _onResize;
  96104. /**
  96105. * Creates a new virtual joystick
  96106. * @param leftJoystick defines that the joystick is for left hand (false by default)
  96107. */
  96108. constructor(leftJoystick?: boolean);
  96109. /**
  96110. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  96111. * @param newJoystickSensibility defines the new sensibility
  96112. */
  96113. setJoystickSensibility(newJoystickSensibility: number): void;
  96114. private _onPointerDown;
  96115. private _onPointerMove;
  96116. private _onPointerUp;
  96117. /**
  96118. * Change the color of the virtual joystick
  96119. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  96120. */
  96121. setJoystickColor(newColor: string): void;
  96122. /**
  96123. * Defines a callback to call when the joystick is touched
  96124. * @param action defines the callback
  96125. */
  96126. setActionOnTouch(action: () => any): void;
  96127. /**
  96128. * Defines which axis you'd like to control for left & right
  96129. * @param axis defines the axis to use
  96130. */
  96131. setAxisForLeftRight(axis: JoystickAxis): void;
  96132. /**
  96133. * Defines which axis you'd like to control for up & down
  96134. * @param axis defines the axis to use
  96135. */
  96136. setAxisForUpDown(axis: JoystickAxis): void;
  96137. private _drawVirtualJoystick;
  96138. /**
  96139. * Release internal HTML canvas
  96140. */
  96141. releaseCanvas(): void;
  96142. }
  96143. }
  96144. declare module BABYLON {
  96145. interface FreeCameraInputsManager {
  96146. /**
  96147. * Add virtual joystick input support to the input manager.
  96148. * @returns the current input manager
  96149. */
  96150. addVirtualJoystick(): FreeCameraInputsManager;
  96151. }
  96152. /**
  96153. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  96154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96155. */
  96156. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  96157. /**
  96158. * Defines the camera the input is attached to.
  96159. */
  96160. camera: FreeCamera;
  96161. private _leftjoystick;
  96162. private _rightjoystick;
  96163. /**
  96164. * Gets the left stick of the virtual joystick.
  96165. * @returns The virtual Joystick
  96166. */
  96167. getLeftJoystick(): VirtualJoystick;
  96168. /**
  96169. * Gets the right stick of the virtual joystick.
  96170. * @returns The virtual Joystick
  96171. */
  96172. getRightJoystick(): VirtualJoystick;
  96173. /**
  96174. * Update the current camera state depending on the inputs that have been used this frame.
  96175. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96176. */
  96177. checkInputs(): void;
  96178. /**
  96179. * Attach the input controls to a specific dom element to get the input from.
  96180. * @param element Defines the element the controls should be listened from
  96181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96182. */
  96183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96184. /**
  96185. * Detach the current controls from the specified dom element.
  96186. * @param element Defines the element to stop listening the inputs from
  96187. */
  96188. detachControl(element: Nullable<HTMLElement>): void;
  96189. /**
  96190. * Gets the class name of the current intput.
  96191. * @returns the class name
  96192. */
  96193. getClassName(): string;
  96194. /**
  96195. * Get the friendly name associated with the input class.
  96196. * @returns the input friendly name
  96197. */
  96198. getSimpleName(): string;
  96199. }
  96200. }
  96201. declare module BABYLON {
  96202. /**
  96203. * This represents a FPS type of camera controlled by touch.
  96204. * This is like a universal camera minus the Gamepad controls.
  96205. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96206. */
  96207. export class TouchCamera extends FreeCamera {
  96208. /**
  96209. * Defines the touch sensibility for rotation.
  96210. * The higher the faster.
  96211. */
  96212. touchAngularSensibility: number;
  96213. /**
  96214. * Defines the touch sensibility for move.
  96215. * The higher the faster.
  96216. */
  96217. touchMoveSensibility: number;
  96218. /**
  96219. * Instantiates a new touch camera.
  96220. * This represents a FPS type of camera controlled by touch.
  96221. * This is like a universal camera minus the Gamepad controls.
  96222. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96223. * @param name Define the name of the camera in the scene
  96224. * @param position Define the start position of the camera in the scene
  96225. * @param scene Define the scene the camera belongs to
  96226. */
  96227. constructor(name: string, position: Vector3, scene: Scene);
  96228. /**
  96229. * Gets the current object class name.
  96230. * @return the class name
  96231. */
  96232. getClassName(): string;
  96233. /** @hidden */
  96234. _setupInputs(): void;
  96235. }
  96236. }
  96237. declare module BABYLON {
  96238. /**
  96239. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  96240. * being tilted forward or back and left or right.
  96241. */
  96242. export class DeviceOrientationCamera extends FreeCamera {
  96243. private _initialQuaternion;
  96244. private _quaternionCache;
  96245. private _tmpDragQuaternion;
  96246. /**
  96247. * Creates a new device orientation camera
  96248. * @param name The name of the camera
  96249. * @param position The start position camera
  96250. * @param scene The scene the camera belongs to
  96251. */
  96252. constructor(name: string, position: Vector3, scene: Scene);
  96253. /**
  96254. * Disabled pointer input on first orientation sensor update (Default: true)
  96255. */
  96256. disablePointerInputWhenUsingDeviceOrientation: boolean;
  96257. private _dragFactor;
  96258. /**
  96259. * Enabled turning on the y axis when the orientation sensor is active
  96260. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  96261. */
  96262. enableHorizontalDragging(dragFactor?: number): void;
  96263. /**
  96264. * Gets the current instance class name ("DeviceOrientationCamera").
  96265. * This helps avoiding instanceof at run time.
  96266. * @returns the class name
  96267. */
  96268. getClassName(): string;
  96269. /**
  96270. * @hidden
  96271. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  96272. */
  96273. _checkInputs(): void;
  96274. /**
  96275. * Reset the camera to its default orientation on the specified axis only.
  96276. * @param axis The axis to reset
  96277. */
  96278. resetToCurrentRotation(axis?: Axis): void;
  96279. }
  96280. }
  96281. declare module BABYLON {
  96282. /**
  96283. * 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,
  96284. * which still works and will still be found in many Playgrounds.
  96285. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96286. */
  96287. export class UniversalCamera extends TouchCamera {
  96288. /**
  96289. * Defines the gamepad rotation sensiblity.
  96290. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96291. */
  96292. gamepadAngularSensibility: number;
  96293. /**
  96294. * Defines the gamepad move sensiblity.
  96295. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96296. */
  96297. gamepadMoveSensibility: number;
  96298. /**
  96299. * 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,
  96300. * which still works and will still be found in many Playgrounds.
  96301. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96302. * @param name Define the name of the camera in the scene
  96303. * @param position Define the start position of the camera in the scene
  96304. * @param scene Define the scene the camera belongs to
  96305. */
  96306. constructor(name: string, position: Vector3, scene: Scene);
  96307. /**
  96308. * Gets the current object class name.
  96309. * @return the class name
  96310. */
  96311. getClassName(): string;
  96312. }
  96313. }
  96314. declare module BABYLON {
  96315. /**
  96316. * This represents a FPS type of camera. This is only here for back compat purpose.
  96317. * Please use the UniversalCamera instead as both are identical.
  96318. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96319. */
  96320. export class GamepadCamera extends UniversalCamera {
  96321. /**
  96322. * Instantiates a new Gamepad Camera
  96323. * This represents a FPS type of camera. This is only here for back compat purpose.
  96324. * Please use the UniversalCamera instead as both are identical.
  96325. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96326. * @param name Define the name of the camera in the scene
  96327. * @param position Define the start position of the camera in the scene
  96328. * @param scene Define the scene the camera belongs to
  96329. */
  96330. constructor(name: string, position: Vector3, scene: Scene);
  96331. /**
  96332. * Gets the current object class name.
  96333. * @return the class name
  96334. */
  96335. getClassName(): string;
  96336. }
  96337. }
  96338. declare module BABYLON {
  96339. /** @hidden */
  96340. export var passPixelShader: {
  96341. name: string;
  96342. shader: string;
  96343. };
  96344. }
  96345. declare module BABYLON {
  96346. /** @hidden */
  96347. export var passCubePixelShader: {
  96348. name: string;
  96349. shader: string;
  96350. };
  96351. }
  96352. declare module BABYLON {
  96353. /**
  96354. * PassPostProcess which produces an output the same as it's input
  96355. */
  96356. export class PassPostProcess extends PostProcess {
  96357. /**
  96358. * Creates the PassPostProcess
  96359. * @param name The name of the effect.
  96360. * @param options The required width/height ratio to downsize to before computing the render pass.
  96361. * @param camera The camera to apply the render pass to.
  96362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96363. * @param engine The engine which the post process will be applied. (default: current engine)
  96364. * @param reusable If the post process can be reused on the same frame. (default: false)
  96365. * @param textureType The type of texture to be used when performing the post processing.
  96366. * @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)
  96367. */
  96368. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96369. }
  96370. /**
  96371. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  96372. */
  96373. export class PassCubePostProcess extends PostProcess {
  96374. private _face;
  96375. /**
  96376. * Gets or sets the cube face to display.
  96377. * * 0 is +X
  96378. * * 1 is -X
  96379. * * 2 is +Y
  96380. * * 3 is -Y
  96381. * * 4 is +Z
  96382. * * 5 is -Z
  96383. */
  96384. face: number;
  96385. /**
  96386. * Creates the PassCubePostProcess
  96387. * @param name The name of the effect.
  96388. * @param options The required width/height ratio to downsize to before computing the render pass.
  96389. * @param camera The camera to apply the render pass to.
  96390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96391. * @param engine The engine which the post process will be applied. (default: current engine)
  96392. * @param reusable If the post process can be reused on the same frame. (default: false)
  96393. * @param textureType The type of texture to be used when performing the post processing.
  96394. * @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)
  96395. */
  96396. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96397. }
  96398. }
  96399. declare module BABYLON {
  96400. /** @hidden */
  96401. export var anaglyphPixelShader: {
  96402. name: string;
  96403. shader: string;
  96404. };
  96405. }
  96406. declare module BABYLON {
  96407. /**
  96408. * Postprocess used to generate anaglyphic rendering
  96409. */
  96410. export class AnaglyphPostProcess extends PostProcess {
  96411. private _passedProcess;
  96412. /**
  96413. * Creates a new AnaglyphPostProcess
  96414. * @param name defines postprocess name
  96415. * @param options defines creation options or target ratio scale
  96416. * @param rigCameras defines cameras using this postprocess
  96417. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  96418. * @param engine defines hosting engine
  96419. * @param reusable defines if the postprocess will be reused multiple times per frame
  96420. */
  96421. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  96422. }
  96423. }
  96424. declare module BABYLON {
  96425. /**
  96426. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  96427. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96428. */
  96429. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  96430. /**
  96431. * Creates a new AnaglyphArcRotateCamera
  96432. * @param name defines camera name
  96433. * @param alpha defines alpha angle (in radians)
  96434. * @param beta defines beta angle (in radians)
  96435. * @param radius defines radius
  96436. * @param target defines camera target
  96437. * @param interaxialDistance defines distance between each color axis
  96438. * @param scene defines the hosting scene
  96439. */
  96440. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  96441. /**
  96442. * Gets camera class name
  96443. * @returns AnaglyphArcRotateCamera
  96444. */
  96445. getClassName(): string;
  96446. }
  96447. }
  96448. declare module BABYLON {
  96449. /**
  96450. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  96451. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96452. */
  96453. export class AnaglyphFreeCamera extends FreeCamera {
  96454. /**
  96455. * Creates a new AnaglyphFreeCamera
  96456. * @param name defines camera name
  96457. * @param position defines initial position
  96458. * @param interaxialDistance defines distance between each color axis
  96459. * @param scene defines the hosting scene
  96460. */
  96461. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96462. /**
  96463. * Gets camera class name
  96464. * @returns AnaglyphFreeCamera
  96465. */
  96466. getClassName(): string;
  96467. }
  96468. }
  96469. declare module BABYLON {
  96470. /**
  96471. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  96472. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96473. */
  96474. export class AnaglyphGamepadCamera extends GamepadCamera {
  96475. /**
  96476. * Creates a new AnaglyphGamepadCamera
  96477. * @param name defines camera name
  96478. * @param position defines initial position
  96479. * @param interaxialDistance defines distance between each color axis
  96480. * @param scene defines the hosting scene
  96481. */
  96482. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96483. /**
  96484. * Gets camera class name
  96485. * @returns AnaglyphGamepadCamera
  96486. */
  96487. getClassName(): string;
  96488. }
  96489. }
  96490. declare module BABYLON {
  96491. /**
  96492. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  96493. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96494. */
  96495. export class AnaglyphUniversalCamera extends UniversalCamera {
  96496. /**
  96497. * Creates a new AnaglyphUniversalCamera
  96498. * @param name defines camera name
  96499. * @param position defines initial position
  96500. * @param interaxialDistance defines distance between each color axis
  96501. * @param scene defines the hosting scene
  96502. */
  96503. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96504. /**
  96505. * Gets camera class name
  96506. * @returns AnaglyphUniversalCamera
  96507. */
  96508. getClassName(): string;
  96509. }
  96510. }
  96511. declare module BABYLON {
  96512. /** @hidden */
  96513. export var stereoscopicInterlacePixelShader: {
  96514. name: string;
  96515. shader: string;
  96516. };
  96517. }
  96518. declare module BABYLON {
  96519. /**
  96520. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  96521. */
  96522. export class StereoscopicInterlacePostProcess extends PostProcess {
  96523. private _stepSize;
  96524. private _passedProcess;
  96525. /**
  96526. * Initializes a StereoscopicInterlacePostProcess
  96527. * @param name The name of the effect.
  96528. * @param rigCameras The rig cameras to be appled to the post process
  96529. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  96530. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96531. * @param engine The engine which the post process will be applied. (default: current engine)
  96532. * @param reusable If the post process can be reused on the same frame. (default: false)
  96533. */
  96534. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  96535. }
  96536. }
  96537. declare module BABYLON {
  96538. /**
  96539. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  96540. * @see http://doc.babylonjs.com/features/cameras
  96541. */
  96542. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  96543. /**
  96544. * Creates a new StereoscopicArcRotateCamera
  96545. * @param name defines camera name
  96546. * @param alpha defines alpha angle (in radians)
  96547. * @param beta defines beta angle (in radians)
  96548. * @param radius defines radius
  96549. * @param target defines camera target
  96550. * @param interaxialDistance defines distance between each color axis
  96551. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96552. * @param scene defines the hosting scene
  96553. */
  96554. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96555. /**
  96556. * Gets camera class name
  96557. * @returns StereoscopicArcRotateCamera
  96558. */
  96559. getClassName(): string;
  96560. }
  96561. }
  96562. declare module BABYLON {
  96563. /**
  96564. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  96565. * @see http://doc.babylonjs.com/features/cameras
  96566. */
  96567. export class StereoscopicFreeCamera extends FreeCamera {
  96568. /**
  96569. * Creates a new StereoscopicFreeCamera
  96570. * @param name defines camera name
  96571. * @param position defines initial position
  96572. * @param interaxialDistance defines distance between each color axis
  96573. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96574. * @param scene defines the hosting scene
  96575. */
  96576. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96577. /**
  96578. * Gets camera class name
  96579. * @returns StereoscopicFreeCamera
  96580. */
  96581. getClassName(): string;
  96582. }
  96583. }
  96584. declare module BABYLON {
  96585. /**
  96586. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  96587. * @see http://doc.babylonjs.com/features/cameras
  96588. */
  96589. export class StereoscopicGamepadCamera extends GamepadCamera {
  96590. /**
  96591. * Creates a new StereoscopicGamepadCamera
  96592. * @param name defines camera name
  96593. * @param position defines initial position
  96594. * @param interaxialDistance defines distance between each color axis
  96595. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96596. * @param scene defines the hosting scene
  96597. */
  96598. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96599. /**
  96600. * Gets camera class name
  96601. * @returns StereoscopicGamepadCamera
  96602. */
  96603. getClassName(): string;
  96604. }
  96605. }
  96606. declare module BABYLON {
  96607. /**
  96608. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  96609. * @see http://doc.babylonjs.com/features/cameras
  96610. */
  96611. export class StereoscopicUniversalCamera extends UniversalCamera {
  96612. /**
  96613. * Creates a new StereoscopicUniversalCamera
  96614. * @param name defines camera name
  96615. * @param position defines initial position
  96616. * @param interaxialDistance defines distance between each color axis
  96617. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96618. * @param scene defines the hosting scene
  96619. */
  96620. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96621. /**
  96622. * Gets camera class name
  96623. * @returns StereoscopicUniversalCamera
  96624. */
  96625. getClassName(): string;
  96626. }
  96627. }
  96628. declare module BABYLON {
  96629. /**
  96630. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96631. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96632. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96633. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96634. */
  96635. export class VirtualJoysticksCamera extends FreeCamera {
  96636. /**
  96637. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  96638. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96639. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96640. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96641. * @param name Define the name of the camera in the scene
  96642. * @param position Define the start position of the camera in the scene
  96643. * @param scene Define the scene the camera belongs to
  96644. */
  96645. constructor(name: string, position: Vector3, scene: Scene);
  96646. /**
  96647. * Gets the current object class name.
  96648. * @return the class name
  96649. */
  96650. getClassName(): string;
  96651. }
  96652. }
  96653. declare module BABYLON {
  96654. /**
  96655. * This represents all the required metrics to create a VR camera.
  96656. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  96657. */
  96658. export class VRCameraMetrics {
  96659. /**
  96660. * Define the horizontal resolution off the screen.
  96661. */
  96662. hResolution: number;
  96663. /**
  96664. * Define the vertical resolution off the screen.
  96665. */
  96666. vResolution: number;
  96667. /**
  96668. * Define the horizontal screen size.
  96669. */
  96670. hScreenSize: number;
  96671. /**
  96672. * Define the vertical screen size.
  96673. */
  96674. vScreenSize: number;
  96675. /**
  96676. * Define the vertical screen center position.
  96677. */
  96678. vScreenCenter: number;
  96679. /**
  96680. * Define the distance of the eyes to the screen.
  96681. */
  96682. eyeToScreenDistance: number;
  96683. /**
  96684. * Define the distance between both lenses
  96685. */
  96686. lensSeparationDistance: number;
  96687. /**
  96688. * Define the distance between both viewer's eyes.
  96689. */
  96690. interpupillaryDistance: number;
  96691. /**
  96692. * Define the distortion factor of the VR postprocess.
  96693. * Please, touch with care.
  96694. */
  96695. distortionK: number[];
  96696. /**
  96697. * Define the chromatic aberration correction factors for the VR post process.
  96698. */
  96699. chromaAbCorrection: number[];
  96700. /**
  96701. * Define the scale factor of the post process.
  96702. * The smaller the better but the slower.
  96703. */
  96704. postProcessScaleFactor: number;
  96705. /**
  96706. * Define an offset for the lens center.
  96707. */
  96708. lensCenterOffset: number;
  96709. /**
  96710. * Define if the current vr camera should compensate the distortion of the lense or not.
  96711. */
  96712. compensateDistortion: boolean;
  96713. /**
  96714. * Defines if multiview should be enabled when rendering (Default: false)
  96715. */
  96716. multiviewEnabled: boolean;
  96717. /**
  96718. * Gets the rendering aspect ratio based on the provided resolutions.
  96719. */
  96720. readonly aspectRatio: number;
  96721. /**
  96722. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  96723. */
  96724. readonly aspectRatioFov: number;
  96725. /**
  96726. * @hidden
  96727. */
  96728. readonly leftHMatrix: Matrix;
  96729. /**
  96730. * @hidden
  96731. */
  96732. readonly rightHMatrix: Matrix;
  96733. /**
  96734. * @hidden
  96735. */
  96736. readonly leftPreViewMatrix: Matrix;
  96737. /**
  96738. * @hidden
  96739. */
  96740. readonly rightPreViewMatrix: Matrix;
  96741. /**
  96742. * Get the default VRMetrics based on the most generic setup.
  96743. * @returns the default vr metrics
  96744. */
  96745. static GetDefault(): VRCameraMetrics;
  96746. }
  96747. }
  96748. declare module BABYLON {
  96749. /** @hidden */
  96750. export var vrDistortionCorrectionPixelShader: {
  96751. name: string;
  96752. shader: string;
  96753. };
  96754. }
  96755. declare module BABYLON {
  96756. /**
  96757. * VRDistortionCorrectionPostProcess used for mobile VR
  96758. */
  96759. export class VRDistortionCorrectionPostProcess extends PostProcess {
  96760. private _isRightEye;
  96761. private _distortionFactors;
  96762. private _postProcessScaleFactor;
  96763. private _lensCenterOffset;
  96764. private _scaleIn;
  96765. private _scaleFactor;
  96766. private _lensCenter;
  96767. /**
  96768. * Initializes the VRDistortionCorrectionPostProcess
  96769. * @param name The name of the effect.
  96770. * @param camera The camera to apply the render pass to.
  96771. * @param isRightEye If this is for the right eye distortion
  96772. * @param vrMetrics All the required metrics for the VR camera
  96773. */
  96774. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  96775. }
  96776. }
  96777. declare module BABYLON {
  96778. /**
  96779. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  96780. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96781. */
  96782. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  96783. /**
  96784. * Creates a new VRDeviceOrientationArcRotateCamera
  96785. * @param name defines camera name
  96786. * @param alpha defines the camera rotation along the logitudinal axis
  96787. * @param beta defines the camera rotation along the latitudinal axis
  96788. * @param radius defines the camera distance from its target
  96789. * @param target defines the camera target
  96790. * @param scene defines the scene the camera belongs to
  96791. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96792. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96793. */
  96794. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96795. /**
  96796. * Gets camera class name
  96797. * @returns VRDeviceOrientationArcRotateCamera
  96798. */
  96799. getClassName(): string;
  96800. }
  96801. }
  96802. declare module BABYLON {
  96803. /**
  96804. * Camera used to simulate VR rendering (based on FreeCamera)
  96805. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96806. */
  96807. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  96808. /**
  96809. * Creates a new VRDeviceOrientationFreeCamera
  96810. * @param name defines camera name
  96811. * @param position defines the start position of the camera
  96812. * @param scene defines the scene the camera belongs to
  96813. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96814. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96815. */
  96816. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96817. /**
  96818. * Gets camera class name
  96819. * @returns VRDeviceOrientationFreeCamera
  96820. */
  96821. getClassName(): string;
  96822. }
  96823. }
  96824. declare module BABYLON {
  96825. /**
  96826. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  96827. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96828. */
  96829. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  96830. /**
  96831. * Creates a new VRDeviceOrientationGamepadCamera
  96832. * @param name defines camera name
  96833. * @param position defines the start position of the camera
  96834. * @param scene defines the scene the camera belongs to
  96835. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96836. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96837. */
  96838. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96839. /**
  96840. * Gets camera class name
  96841. * @returns VRDeviceOrientationGamepadCamera
  96842. */
  96843. getClassName(): string;
  96844. }
  96845. }
  96846. declare module BABYLON {
  96847. /**
  96848. * Defines supported buttons for XBox360 compatible gamepads
  96849. */
  96850. export enum Xbox360Button {
  96851. /** A */
  96852. A = 0,
  96853. /** B */
  96854. B = 1,
  96855. /** X */
  96856. X = 2,
  96857. /** Y */
  96858. Y = 3,
  96859. /** Start */
  96860. Start = 4,
  96861. /** Back */
  96862. Back = 5,
  96863. /** Left button */
  96864. LB = 6,
  96865. /** Right button */
  96866. RB = 7,
  96867. /** Left stick */
  96868. LeftStick = 8,
  96869. /** Right stick */
  96870. RightStick = 9
  96871. }
  96872. /** Defines values for XBox360 DPad */
  96873. export enum Xbox360Dpad {
  96874. /** Up */
  96875. Up = 0,
  96876. /** Down */
  96877. Down = 1,
  96878. /** Left */
  96879. Left = 2,
  96880. /** Right */
  96881. Right = 3
  96882. }
  96883. /**
  96884. * Defines a XBox360 gamepad
  96885. */
  96886. export class Xbox360Pad extends Gamepad {
  96887. private _leftTrigger;
  96888. private _rightTrigger;
  96889. private _onlefttriggerchanged;
  96890. private _onrighttriggerchanged;
  96891. private _onbuttondown;
  96892. private _onbuttonup;
  96893. private _ondpaddown;
  96894. private _ondpadup;
  96895. /** Observable raised when a button is pressed */
  96896. onButtonDownObservable: Observable<Xbox360Button>;
  96897. /** Observable raised when a button is released */
  96898. onButtonUpObservable: Observable<Xbox360Button>;
  96899. /** Observable raised when a pad is pressed */
  96900. onPadDownObservable: Observable<Xbox360Dpad>;
  96901. /** Observable raised when a pad is released */
  96902. onPadUpObservable: Observable<Xbox360Dpad>;
  96903. private _buttonA;
  96904. private _buttonB;
  96905. private _buttonX;
  96906. private _buttonY;
  96907. private _buttonBack;
  96908. private _buttonStart;
  96909. private _buttonLB;
  96910. private _buttonRB;
  96911. private _buttonLeftStick;
  96912. private _buttonRightStick;
  96913. private _dPadUp;
  96914. private _dPadDown;
  96915. private _dPadLeft;
  96916. private _dPadRight;
  96917. private _isXboxOnePad;
  96918. /**
  96919. * Creates a new XBox360 gamepad object
  96920. * @param id defines the id of this gamepad
  96921. * @param index defines its index
  96922. * @param gamepad defines the internal HTML gamepad object
  96923. * @param xboxOne defines if it is a XBox One gamepad
  96924. */
  96925. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  96926. /**
  96927. * Defines the callback to call when left trigger is pressed
  96928. * @param callback defines the callback to use
  96929. */
  96930. onlefttriggerchanged(callback: (value: number) => void): void;
  96931. /**
  96932. * Defines the callback to call when right trigger is pressed
  96933. * @param callback defines the callback to use
  96934. */
  96935. onrighttriggerchanged(callback: (value: number) => void): void;
  96936. /**
  96937. * Gets the left trigger value
  96938. */
  96939. /**
  96940. * Sets the left trigger value
  96941. */
  96942. leftTrigger: number;
  96943. /**
  96944. * Gets the right trigger value
  96945. */
  96946. /**
  96947. * Sets the right trigger value
  96948. */
  96949. rightTrigger: number;
  96950. /**
  96951. * Defines the callback to call when a button is pressed
  96952. * @param callback defines the callback to use
  96953. */
  96954. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  96955. /**
  96956. * Defines the callback to call when a button is released
  96957. * @param callback defines the callback to use
  96958. */
  96959. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  96960. /**
  96961. * Defines the callback to call when a pad is pressed
  96962. * @param callback defines the callback to use
  96963. */
  96964. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  96965. /**
  96966. * Defines the callback to call when a pad is released
  96967. * @param callback defines the callback to use
  96968. */
  96969. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  96970. private _setButtonValue;
  96971. private _setDPadValue;
  96972. /**
  96973. * Gets the value of the `A` button
  96974. */
  96975. /**
  96976. * Sets the value of the `A` button
  96977. */
  96978. buttonA: number;
  96979. /**
  96980. * Gets the value of the `B` button
  96981. */
  96982. /**
  96983. * Sets the value of the `B` button
  96984. */
  96985. buttonB: number;
  96986. /**
  96987. * Gets the value of the `X` button
  96988. */
  96989. /**
  96990. * Sets the value of the `X` button
  96991. */
  96992. buttonX: number;
  96993. /**
  96994. * Gets the value of the `Y` button
  96995. */
  96996. /**
  96997. * Sets the value of the `Y` button
  96998. */
  96999. buttonY: number;
  97000. /**
  97001. * Gets the value of the `Start` button
  97002. */
  97003. /**
  97004. * Sets the value of the `Start` button
  97005. */
  97006. buttonStart: number;
  97007. /**
  97008. * Gets the value of the `Back` button
  97009. */
  97010. /**
  97011. * Sets the value of the `Back` button
  97012. */
  97013. buttonBack: number;
  97014. /**
  97015. * Gets the value of the `Left` button
  97016. */
  97017. /**
  97018. * Sets the value of the `Left` button
  97019. */
  97020. buttonLB: number;
  97021. /**
  97022. * Gets the value of the `Right` button
  97023. */
  97024. /**
  97025. * Sets the value of the `Right` button
  97026. */
  97027. buttonRB: number;
  97028. /**
  97029. * Gets the value of the Left joystick
  97030. */
  97031. /**
  97032. * Sets the value of the Left joystick
  97033. */
  97034. buttonLeftStick: number;
  97035. /**
  97036. * Gets the value of the Right joystick
  97037. */
  97038. /**
  97039. * Sets the value of the Right joystick
  97040. */
  97041. buttonRightStick: number;
  97042. /**
  97043. * Gets the value of D-pad up
  97044. */
  97045. /**
  97046. * Sets the value of D-pad up
  97047. */
  97048. dPadUp: number;
  97049. /**
  97050. * Gets the value of D-pad down
  97051. */
  97052. /**
  97053. * Sets the value of D-pad down
  97054. */
  97055. dPadDown: number;
  97056. /**
  97057. * Gets the value of D-pad left
  97058. */
  97059. /**
  97060. * Sets the value of D-pad left
  97061. */
  97062. dPadLeft: number;
  97063. /**
  97064. * Gets the value of D-pad right
  97065. */
  97066. /**
  97067. * Sets the value of D-pad right
  97068. */
  97069. dPadRight: number;
  97070. /**
  97071. * Force the gamepad to synchronize with device values
  97072. */
  97073. update(): void;
  97074. /**
  97075. * Disposes the gamepad
  97076. */
  97077. dispose(): void;
  97078. }
  97079. }
  97080. declare module BABYLON {
  97081. /**
  97082. * Base class of materials working in push mode in babylon JS
  97083. * @hidden
  97084. */
  97085. export class PushMaterial extends Material {
  97086. protected _activeEffect: Effect;
  97087. protected _normalMatrix: Matrix;
  97088. /**
  97089. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97090. * This means that the material can keep using a previous shader while a new one is being compiled.
  97091. * This is mostly used when shader parallel compilation is supported (true by default)
  97092. */
  97093. allowShaderHotSwapping: boolean;
  97094. constructor(name: string, scene: Scene);
  97095. getEffect(): Effect;
  97096. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97097. /**
  97098. * Binds the given world matrix to the active effect
  97099. *
  97100. * @param world the matrix to bind
  97101. */
  97102. bindOnlyWorldMatrix(world: Matrix): void;
  97103. /**
  97104. * Binds the given normal matrix to the active effect
  97105. *
  97106. * @param normalMatrix the matrix to bind
  97107. */
  97108. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97109. bind(world: Matrix, mesh?: Mesh): void;
  97110. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97111. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97112. }
  97113. }
  97114. declare module BABYLON {
  97115. /**
  97116. * This groups all the flags used to control the materials channel.
  97117. */
  97118. export class MaterialFlags {
  97119. private static _DiffuseTextureEnabled;
  97120. /**
  97121. * Are diffuse textures enabled in the application.
  97122. */
  97123. static DiffuseTextureEnabled: boolean;
  97124. private static _AmbientTextureEnabled;
  97125. /**
  97126. * Are ambient textures enabled in the application.
  97127. */
  97128. static AmbientTextureEnabled: boolean;
  97129. private static _OpacityTextureEnabled;
  97130. /**
  97131. * Are opacity textures enabled in the application.
  97132. */
  97133. static OpacityTextureEnabled: boolean;
  97134. private static _ReflectionTextureEnabled;
  97135. /**
  97136. * Are reflection textures enabled in the application.
  97137. */
  97138. static ReflectionTextureEnabled: boolean;
  97139. private static _EmissiveTextureEnabled;
  97140. /**
  97141. * Are emissive textures enabled in the application.
  97142. */
  97143. static EmissiveTextureEnabled: boolean;
  97144. private static _SpecularTextureEnabled;
  97145. /**
  97146. * Are specular textures enabled in the application.
  97147. */
  97148. static SpecularTextureEnabled: boolean;
  97149. private static _BumpTextureEnabled;
  97150. /**
  97151. * Are bump textures enabled in the application.
  97152. */
  97153. static BumpTextureEnabled: boolean;
  97154. private static _LightmapTextureEnabled;
  97155. /**
  97156. * Are lightmap textures enabled in the application.
  97157. */
  97158. static LightmapTextureEnabled: boolean;
  97159. private static _RefractionTextureEnabled;
  97160. /**
  97161. * Are refraction textures enabled in the application.
  97162. */
  97163. static RefractionTextureEnabled: boolean;
  97164. private static _ColorGradingTextureEnabled;
  97165. /**
  97166. * Are color grading textures enabled in the application.
  97167. */
  97168. static ColorGradingTextureEnabled: boolean;
  97169. private static _FresnelEnabled;
  97170. /**
  97171. * Are fresnels enabled in the application.
  97172. */
  97173. static FresnelEnabled: boolean;
  97174. private static _ClearCoatTextureEnabled;
  97175. /**
  97176. * Are clear coat textures enabled in the application.
  97177. */
  97178. static ClearCoatTextureEnabled: boolean;
  97179. private static _ClearCoatBumpTextureEnabled;
  97180. /**
  97181. * Are clear coat bump textures enabled in the application.
  97182. */
  97183. static ClearCoatBumpTextureEnabled: boolean;
  97184. private static _ClearCoatTintTextureEnabled;
  97185. /**
  97186. * Are clear coat tint textures enabled in the application.
  97187. */
  97188. static ClearCoatTintTextureEnabled: boolean;
  97189. private static _SheenTextureEnabled;
  97190. /**
  97191. * Are sheen textures enabled in the application.
  97192. */
  97193. static SheenTextureEnabled: boolean;
  97194. private static _AnisotropicTextureEnabled;
  97195. /**
  97196. * Are anisotropic textures enabled in the application.
  97197. */
  97198. static AnisotropicTextureEnabled: boolean;
  97199. }
  97200. }
  97201. declare module BABYLON {
  97202. /** @hidden */
  97203. export var defaultFragmentDeclaration: {
  97204. name: string;
  97205. shader: string;
  97206. };
  97207. }
  97208. declare module BABYLON {
  97209. /** @hidden */
  97210. export var defaultUboDeclaration: {
  97211. name: string;
  97212. shader: string;
  97213. };
  97214. }
  97215. declare module BABYLON {
  97216. /** @hidden */
  97217. export var lightFragmentDeclaration: {
  97218. name: string;
  97219. shader: string;
  97220. };
  97221. }
  97222. declare module BABYLON {
  97223. /** @hidden */
  97224. export var lightUboDeclaration: {
  97225. name: string;
  97226. shader: string;
  97227. };
  97228. }
  97229. declare module BABYLON {
  97230. /** @hidden */
  97231. export var lightsFragmentFunctions: {
  97232. name: string;
  97233. shader: string;
  97234. };
  97235. }
  97236. declare module BABYLON {
  97237. /** @hidden */
  97238. export var shadowsFragmentFunctions: {
  97239. name: string;
  97240. shader: string;
  97241. };
  97242. }
  97243. declare module BABYLON {
  97244. /** @hidden */
  97245. export var fresnelFunction: {
  97246. name: string;
  97247. shader: string;
  97248. };
  97249. }
  97250. declare module BABYLON {
  97251. /** @hidden */
  97252. export var reflectionFunction: {
  97253. name: string;
  97254. shader: string;
  97255. };
  97256. }
  97257. declare module BABYLON {
  97258. /** @hidden */
  97259. export var bumpFragmentFunctions: {
  97260. name: string;
  97261. shader: string;
  97262. };
  97263. }
  97264. declare module BABYLON {
  97265. /** @hidden */
  97266. export var logDepthDeclaration: {
  97267. name: string;
  97268. shader: string;
  97269. };
  97270. }
  97271. declare module BABYLON {
  97272. /** @hidden */
  97273. export var bumpFragment: {
  97274. name: string;
  97275. shader: string;
  97276. };
  97277. }
  97278. declare module BABYLON {
  97279. /** @hidden */
  97280. export var depthPrePass: {
  97281. name: string;
  97282. shader: string;
  97283. };
  97284. }
  97285. declare module BABYLON {
  97286. /** @hidden */
  97287. export var lightFragment: {
  97288. name: string;
  97289. shader: string;
  97290. };
  97291. }
  97292. declare module BABYLON {
  97293. /** @hidden */
  97294. export var logDepthFragment: {
  97295. name: string;
  97296. shader: string;
  97297. };
  97298. }
  97299. declare module BABYLON {
  97300. /** @hidden */
  97301. export var defaultPixelShader: {
  97302. name: string;
  97303. shader: string;
  97304. };
  97305. }
  97306. declare module BABYLON {
  97307. /** @hidden */
  97308. export var defaultVertexDeclaration: {
  97309. name: string;
  97310. shader: string;
  97311. };
  97312. }
  97313. declare module BABYLON {
  97314. /** @hidden */
  97315. export var bumpVertexDeclaration: {
  97316. name: string;
  97317. shader: string;
  97318. };
  97319. }
  97320. declare module BABYLON {
  97321. /** @hidden */
  97322. export var bumpVertex: {
  97323. name: string;
  97324. shader: string;
  97325. };
  97326. }
  97327. declare module BABYLON {
  97328. /** @hidden */
  97329. export var fogVertex: {
  97330. name: string;
  97331. shader: string;
  97332. };
  97333. }
  97334. declare module BABYLON {
  97335. /** @hidden */
  97336. export var shadowsVertex: {
  97337. name: string;
  97338. shader: string;
  97339. };
  97340. }
  97341. declare module BABYLON {
  97342. /** @hidden */
  97343. export var pointCloudVertex: {
  97344. name: string;
  97345. shader: string;
  97346. };
  97347. }
  97348. declare module BABYLON {
  97349. /** @hidden */
  97350. export var logDepthVertex: {
  97351. name: string;
  97352. shader: string;
  97353. };
  97354. }
  97355. declare module BABYLON {
  97356. /** @hidden */
  97357. export var defaultVertexShader: {
  97358. name: string;
  97359. shader: string;
  97360. };
  97361. }
  97362. declare module BABYLON {
  97363. /** @hidden */
  97364. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97365. MAINUV1: boolean;
  97366. MAINUV2: boolean;
  97367. DIFFUSE: boolean;
  97368. DIFFUSEDIRECTUV: number;
  97369. AMBIENT: boolean;
  97370. AMBIENTDIRECTUV: number;
  97371. OPACITY: boolean;
  97372. OPACITYDIRECTUV: number;
  97373. OPACITYRGB: boolean;
  97374. REFLECTION: boolean;
  97375. EMISSIVE: boolean;
  97376. EMISSIVEDIRECTUV: number;
  97377. SPECULAR: boolean;
  97378. SPECULARDIRECTUV: number;
  97379. BUMP: boolean;
  97380. BUMPDIRECTUV: number;
  97381. PARALLAX: boolean;
  97382. PARALLAXOCCLUSION: boolean;
  97383. SPECULAROVERALPHA: boolean;
  97384. CLIPPLANE: boolean;
  97385. CLIPPLANE2: boolean;
  97386. CLIPPLANE3: boolean;
  97387. CLIPPLANE4: boolean;
  97388. ALPHATEST: boolean;
  97389. DEPTHPREPASS: boolean;
  97390. ALPHAFROMDIFFUSE: boolean;
  97391. POINTSIZE: boolean;
  97392. FOG: boolean;
  97393. SPECULARTERM: boolean;
  97394. DIFFUSEFRESNEL: boolean;
  97395. OPACITYFRESNEL: boolean;
  97396. REFLECTIONFRESNEL: boolean;
  97397. REFRACTIONFRESNEL: boolean;
  97398. EMISSIVEFRESNEL: boolean;
  97399. FRESNEL: boolean;
  97400. NORMAL: boolean;
  97401. UV1: boolean;
  97402. UV2: boolean;
  97403. VERTEXCOLOR: boolean;
  97404. VERTEXALPHA: boolean;
  97405. NUM_BONE_INFLUENCERS: number;
  97406. BonesPerMesh: number;
  97407. BONETEXTURE: boolean;
  97408. INSTANCES: boolean;
  97409. GLOSSINESS: boolean;
  97410. ROUGHNESS: boolean;
  97411. EMISSIVEASILLUMINATION: boolean;
  97412. LINKEMISSIVEWITHDIFFUSE: boolean;
  97413. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97414. LIGHTMAP: boolean;
  97415. LIGHTMAPDIRECTUV: number;
  97416. OBJECTSPACE_NORMALMAP: boolean;
  97417. USELIGHTMAPASSHADOWMAP: boolean;
  97418. REFLECTIONMAP_3D: boolean;
  97419. REFLECTIONMAP_SPHERICAL: boolean;
  97420. REFLECTIONMAP_PLANAR: boolean;
  97421. REFLECTIONMAP_CUBIC: boolean;
  97422. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  97423. REFLECTIONMAP_PROJECTION: boolean;
  97424. REFLECTIONMAP_SKYBOX: boolean;
  97425. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  97426. REFLECTIONMAP_EXPLICIT: boolean;
  97427. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  97428. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  97429. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  97430. INVERTCUBICMAP: boolean;
  97431. LOGARITHMICDEPTH: boolean;
  97432. REFRACTION: boolean;
  97433. REFRACTIONMAP_3D: boolean;
  97434. REFLECTIONOVERALPHA: boolean;
  97435. TWOSIDEDLIGHTING: boolean;
  97436. SHADOWFLOAT: boolean;
  97437. MORPHTARGETS: boolean;
  97438. MORPHTARGETS_NORMAL: boolean;
  97439. MORPHTARGETS_TANGENT: boolean;
  97440. NUM_MORPH_INFLUENCERS: number;
  97441. NONUNIFORMSCALING: boolean;
  97442. PREMULTIPLYALPHA: boolean;
  97443. IMAGEPROCESSING: boolean;
  97444. VIGNETTE: boolean;
  97445. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97446. VIGNETTEBLENDMODEOPAQUE: boolean;
  97447. TONEMAPPING: boolean;
  97448. TONEMAPPING_ACES: boolean;
  97449. CONTRAST: boolean;
  97450. COLORCURVES: boolean;
  97451. COLORGRADING: boolean;
  97452. COLORGRADING3D: boolean;
  97453. SAMPLER3DGREENDEPTH: boolean;
  97454. SAMPLER3DBGRMAP: boolean;
  97455. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97456. MULTIVIEW: boolean;
  97457. /**
  97458. * If the reflection texture on this material is in linear color space
  97459. * @hidden
  97460. */
  97461. IS_REFLECTION_LINEAR: boolean;
  97462. /**
  97463. * If the refraction texture on this material is in linear color space
  97464. * @hidden
  97465. */
  97466. IS_REFRACTION_LINEAR: boolean;
  97467. EXPOSURE: boolean;
  97468. constructor();
  97469. setReflectionMode(modeToEnable: string): void;
  97470. }
  97471. /**
  97472. * This is the default material used in Babylon. It is the best trade off between quality
  97473. * and performances.
  97474. * @see http://doc.babylonjs.com/babylon101/materials
  97475. */
  97476. export class StandardMaterial extends PushMaterial {
  97477. private _diffuseTexture;
  97478. /**
  97479. * The basic texture of the material as viewed under a light.
  97480. */
  97481. diffuseTexture: Nullable<BaseTexture>;
  97482. private _ambientTexture;
  97483. /**
  97484. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  97485. */
  97486. ambientTexture: Nullable<BaseTexture>;
  97487. private _opacityTexture;
  97488. /**
  97489. * Define the transparency of the material from a texture.
  97490. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  97491. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  97492. */
  97493. opacityTexture: Nullable<BaseTexture>;
  97494. private _reflectionTexture;
  97495. /**
  97496. * Define the texture used to display the reflection.
  97497. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97498. */
  97499. reflectionTexture: Nullable<BaseTexture>;
  97500. private _emissiveTexture;
  97501. /**
  97502. * Define texture of the material as if self lit.
  97503. * This will be mixed in the final result even in the absence of light.
  97504. */
  97505. emissiveTexture: Nullable<BaseTexture>;
  97506. private _specularTexture;
  97507. /**
  97508. * Define how the color and intensity of the highlight given by the light in the material.
  97509. */
  97510. specularTexture: Nullable<BaseTexture>;
  97511. private _bumpTexture;
  97512. /**
  97513. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  97514. * 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.
  97515. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  97516. */
  97517. bumpTexture: Nullable<BaseTexture>;
  97518. private _lightmapTexture;
  97519. /**
  97520. * Complex lighting can be computationally expensive to compute at runtime.
  97521. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  97522. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  97523. */
  97524. lightmapTexture: Nullable<BaseTexture>;
  97525. private _refractionTexture;
  97526. /**
  97527. * Define the texture used to display the refraction.
  97528. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97529. */
  97530. refractionTexture: Nullable<BaseTexture>;
  97531. /**
  97532. * The color of the material lit by the environmental background lighting.
  97533. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  97534. */
  97535. ambientColor: Color3;
  97536. /**
  97537. * The basic color of the material as viewed under a light.
  97538. */
  97539. diffuseColor: Color3;
  97540. /**
  97541. * Define how the color and intensity of the highlight given by the light in the material.
  97542. */
  97543. specularColor: Color3;
  97544. /**
  97545. * Define the color of the material as if self lit.
  97546. * This will be mixed in the final result even in the absence of light.
  97547. */
  97548. emissiveColor: Color3;
  97549. /**
  97550. * Defines how sharp are the highlights in the material.
  97551. * The bigger the value the sharper giving a more glossy feeling to the result.
  97552. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  97553. */
  97554. specularPower: number;
  97555. private _useAlphaFromDiffuseTexture;
  97556. /**
  97557. * Does the transparency come from the diffuse texture alpha channel.
  97558. */
  97559. useAlphaFromDiffuseTexture: boolean;
  97560. private _useEmissiveAsIllumination;
  97561. /**
  97562. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97563. */
  97564. useEmissiveAsIllumination: boolean;
  97565. private _linkEmissiveWithDiffuse;
  97566. /**
  97567. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97568. * the emissive level when the final color is close to one.
  97569. */
  97570. linkEmissiveWithDiffuse: boolean;
  97571. private _useSpecularOverAlpha;
  97572. /**
  97573. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97574. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97575. */
  97576. useSpecularOverAlpha: boolean;
  97577. private _useReflectionOverAlpha;
  97578. /**
  97579. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97580. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97581. */
  97582. useReflectionOverAlpha: boolean;
  97583. private _disableLighting;
  97584. /**
  97585. * Does lights from the scene impacts this material.
  97586. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97587. */
  97588. disableLighting: boolean;
  97589. private _useObjectSpaceNormalMap;
  97590. /**
  97591. * Allows using an object space normal map (instead of tangent space).
  97592. */
  97593. useObjectSpaceNormalMap: boolean;
  97594. private _useParallax;
  97595. /**
  97596. * Is parallax enabled or not.
  97597. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97598. */
  97599. useParallax: boolean;
  97600. private _useParallaxOcclusion;
  97601. /**
  97602. * Is parallax occlusion enabled or not.
  97603. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97604. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97605. */
  97606. useParallaxOcclusion: boolean;
  97607. /**
  97608. * 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.
  97609. */
  97610. parallaxScaleBias: number;
  97611. private _roughness;
  97612. /**
  97613. * Helps to define how blurry the reflections should appears in the material.
  97614. */
  97615. roughness: number;
  97616. /**
  97617. * In case of refraction, define the value of the indice of refraction.
  97618. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97619. */
  97620. indexOfRefraction: number;
  97621. /**
  97622. * Invert the refraction texture alongside the y axis.
  97623. * It can be useful with procedural textures or probe for instance.
  97624. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97625. */
  97626. invertRefractionY: boolean;
  97627. /**
  97628. * Defines the alpha limits in alpha test mode.
  97629. */
  97630. alphaCutOff: number;
  97631. private _useLightmapAsShadowmap;
  97632. /**
  97633. * In case of light mapping, define whether the map contains light or shadow informations.
  97634. */
  97635. useLightmapAsShadowmap: boolean;
  97636. private _diffuseFresnelParameters;
  97637. /**
  97638. * Define the diffuse fresnel parameters of the material.
  97639. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97640. */
  97641. diffuseFresnelParameters: FresnelParameters;
  97642. private _opacityFresnelParameters;
  97643. /**
  97644. * Define the opacity fresnel parameters of the material.
  97645. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97646. */
  97647. opacityFresnelParameters: FresnelParameters;
  97648. private _reflectionFresnelParameters;
  97649. /**
  97650. * Define the reflection fresnel parameters of the material.
  97651. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97652. */
  97653. reflectionFresnelParameters: FresnelParameters;
  97654. private _refractionFresnelParameters;
  97655. /**
  97656. * Define the refraction fresnel parameters of the material.
  97657. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97658. */
  97659. refractionFresnelParameters: FresnelParameters;
  97660. private _emissiveFresnelParameters;
  97661. /**
  97662. * Define the emissive fresnel parameters of the material.
  97663. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97664. */
  97665. emissiveFresnelParameters: FresnelParameters;
  97666. private _useReflectionFresnelFromSpecular;
  97667. /**
  97668. * If true automatically deducts the fresnels values from the material specularity.
  97669. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97670. */
  97671. useReflectionFresnelFromSpecular: boolean;
  97672. private _useGlossinessFromSpecularMapAlpha;
  97673. /**
  97674. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97675. */
  97676. useGlossinessFromSpecularMapAlpha: boolean;
  97677. private _maxSimultaneousLights;
  97678. /**
  97679. * Defines the maximum number of lights that can be used in the material
  97680. */
  97681. maxSimultaneousLights: number;
  97682. private _invertNormalMapX;
  97683. /**
  97684. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97685. */
  97686. invertNormalMapX: boolean;
  97687. private _invertNormalMapY;
  97688. /**
  97689. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97690. */
  97691. invertNormalMapY: boolean;
  97692. private _twoSidedLighting;
  97693. /**
  97694. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97695. */
  97696. twoSidedLighting: boolean;
  97697. /**
  97698. * Default configuration related to image processing available in the standard Material.
  97699. */
  97700. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97701. /**
  97702. * Gets the image processing configuration used either in this material.
  97703. */
  97704. /**
  97705. * Sets the Default image processing configuration used either in the this material.
  97706. *
  97707. * If sets to null, the scene one is in use.
  97708. */
  97709. imageProcessingConfiguration: ImageProcessingConfiguration;
  97710. /**
  97711. * Keep track of the image processing observer to allow dispose and replace.
  97712. */
  97713. private _imageProcessingObserver;
  97714. /**
  97715. * Attaches a new image processing configuration to the Standard Material.
  97716. * @param configuration
  97717. */
  97718. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97719. /**
  97720. * Gets wether the color curves effect is enabled.
  97721. */
  97722. /**
  97723. * Sets wether the color curves effect is enabled.
  97724. */
  97725. cameraColorCurvesEnabled: boolean;
  97726. /**
  97727. * Gets wether the color grading effect is enabled.
  97728. */
  97729. /**
  97730. * Gets wether the color grading effect is enabled.
  97731. */
  97732. cameraColorGradingEnabled: boolean;
  97733. /**
  97734. * Gets wether tonemapping is enabled or not.
  97735. */
  97736. /**
  97737. * Sets wether tonemapping is enabled or not
  97738. */
  97739. cameraToneMappingEnabled: boolean;
  97740. /**
  97741. * The camera exposure used on this material.
  97742. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97743. * This corresponds to a photographic exposure.
  97744. */
  97745. /**
  97746. * The camera exposure used on this material.
  97747. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97748. * This corresponds to a photographic exposure.
  97749. */
  97750. cameraExposure: number;
  97751. /**
  97752. * Gets The camera contrast used on this material.
  97753. */
  97754. /**
  97755. * Sets The camera contrast used on this material.
  97756. */
  97757. cameraContrast: number;
  97758. /**
  97759. * Gets the Color Grading 2D Lookup Texture.
  97760. */
  97761. /**
  97762. * Sets the Color Grading 2D Lookup Texture.
  97763. */
  97764. cameraColorGradingTexture: Nullable<BaseTexture>;
  97765. /**
  97766. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97767. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97768. * 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;
  97769. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97770. */
  97771. /**
  97772. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97773. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97774. * 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;
  97775. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97776. */
  97777. cameraColorCurves: Nullable<ColorCurves>;
  97778. /**
  97779. * Custom callback helping to override the default shader used in the material.
  97780. */
  97781. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97782. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97783. protected _worldViewProjectionMatrix: Matrix;
  97784. protected _globalAmbientColor: Color3;
  97785. protected _useLogarithmicDepth: boolean;
  97786. /**
  97787. * Instantiates a new standard material.
  97788. * This is the default material used in Babylon. It is the best trade off between quality
  97789. * and performances.
  97790. * @see http://doc.babylonjs.com/babylon101/materials
  97791. * @param name Define the name of the material in the scene
  97792. * @param scene Define the scene the material belong to
  97793. */
  97794. constructor(name: string, scene: Scene);
  97795. /**
  97796. * Gets a boolean indicating that current material needs to register RTT
  97797. */
  97798. readonly hasRenderTargetTextures: boolean;
  97799. /**
  97800. * Gets the current class name of the material e.g. "StandardMaterial"
  97801. * Mainly use in serialization.
  97802. * @returns the class name
  97803. */
  97804. getClassName(): string;
  97805. /**
  97806. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97807. * You can try switching to logarithmic depth.
  97808. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97809. */
  97810. useLogarithmicDepth: boolean;
  97811. /**
  97812. * Specifies if the material will require alpha blending
  97813. * @returns a boolean specifying if alpha blending is needed
  97814. */
  97815. needAlphaBlending(): boolean;
  97816. /**
  97817. * Specifies if this material should be rendered in alpha test mode
  97818. * @returns a boolean specifying if an alpha test is needed.
  97819. */
  97820. needAlphaTesting(): boolean;
  97821. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97822. /**
  97823. * Get the texture used for alpha test purpose.
  97824. * @returns the diffuse texture in case of the standard material.
  97825. */
  97826. getAlphaTestTexture(): Nullable<BaseTexture>;
  97827. /**
  97828. * Get if the submesh is ready to be used and all its information available.
  97829. * Child classes can use it to update shaders
  97830. * @param mesh defines the mesh to check
  97831. * @param subMesh defines which submesh to check
  97832. * @param useInstances specifies that instances should be used
  97833. * @returns a boolean indicating that the submesh is ready or not
  97834. */
  97835. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97836. /**
  97837. * Builds the material UBO layouts.
  97838. * Used internally during the effect preparation.
  97839. */
  97840. buildUniformLayout(): void;
  97841. /**
  97842. * Unbinds the material from the mesh
  97843. */
  97844. unbind(): void;
  97845. /**
  97846. * Binds the submesh to this material by preparing the effect and shader to draw
  97847. * @param world defines the world transformation matrix
  97848. * @param mesh defines the mesh containing the submesh
  97849. * @param subMesh defines the submesh to bind the material to
  97850. */
  97851. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97852. /**
  97853. * Get the list of animatables in the material.
  97854. * @returns the list of animatables object used in the material
  97855. */
  97856. getAnimatables(): IAnimatable[];
  97857. /**
  97858. * Gets the active textures from the material
  97859. * @returns an array of textures
  97860. */
  97861. getActiveTextures(): BaseTexture[];
  97862. /**
  97863. * Specifies if the material uses a texture
  97864. * @param texture defines the texture to check against the material
  97865. * @returns a boolean specifying if the material uses the texture
  97866. */
  97867. hasTexture(texture: BaseTexture): boolean;
  97868. /**
  97869. * Disposes the material
  97870. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97871. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97872. */
  97873. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97874. /**
  97875. * Makes a duplicate of the material, and gives it a new name
  97876. * @param name defines the new name for the duplicated material
  97877. * @returns the cloned material
  97878. */
  97879. clone(name: string): StandardMaterial;
  97880. /**
  97881. * Serializes this material in a JSON representation
  97882. * @returns the serialized material object
  97883. */
  97884. serialize(): any;
  97885. /**
  97886. * Creates a standard material from parsed material data
  97887. * @param source defines the JSON representation of the material
  97888. * @param scene defines the hosting scene
  97889. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97890. * @returns a new standard material
  97891. */
  97892. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97893. /**
  97894. * Are diffuse textures enabled in the application.
  97895. */
  97896. static DiffuseTextureEnabled: boolean;
  97897. /**
  97898. * Are ambient textures enabled in the application.
  97899. */
  97900. static AmbientTextureEnabled: boolean;
  97901. /**
  97902. * Are opacity textures enabled in the application.
  97903. */
  97904. static OpacityTextureEnabled: boolean;
  97905. /**
  97906. * Are reflection textures enabled in the application.
  97907. */
  97908. static ReflectionTextureEnabled: boolean;
  97909. /**
  97910. * Are emissive textures enabled in the application.
  97911. */
  97912. static EmissiveTextureEnabled: boolean;
  97913. /**
  97914. * Are specular textures enabled in the application.
  97915. */
  97916. static SpecularTextureEnabled: boolean;
  97917. /**
  97918. * Are bump textures enabled in the application.
  97919. */
  97920. static BumpTextureEnabled: boolean;
  97921. /**
  97922. * Are lightmap textures enabled in the application.
  97923. */
  97924. static LightmapTextureEnabled: boolean;
  97925. /**
  97926. * Are refraction textures enabled in the application.
  97927. */
  97928. static RefractionTextureEnabled: boolean;
  97929. /**
  97930. * Are color grading textures enabled in the application.
  97931. */
  97932. static ColorGradingTextureEnabled: boolean;
  97933. /**
  97934. * Are fresnels enabled in the application.
  97935. */
  97936. static FresnelEnabled: boolean;
  97937. }
  97938. }
  97939. declare module BABYLON {
  97940. /**
  97941. * A class extending Texture allowing drawing on a texture
  97942. * @see http://doc.babylonjs.com/how_to/dynamictexture
  97943. */
  97944. export class DynamicTexture extends Texture {
  97945. private _generateMipMaps;
  97946. private _canvas;
  97947. private _context;
  97948. private _engine;
  97949. /**
  97950. * Creates a DynamicTexture
  97951. * @param name defines the name of the texture
  97952. * @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
  97953. * @param scene defines the scene where you want the texture
  97954. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  97955. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  97956. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  97957. */
  97958. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  97959. /**
  97960. * Get the current class name of the texture useful for serialization or dynamic coding.
  97961. * @returns "DynamicTexture"
  97962. */
  97963. getClassName(): string;
  97964. /**
  97965. * Gets the current state of canRescale
  97966. */
  97967. readonly canRescale: boolean;
  97968. private _recreate;
  97969. /**
  97970. * Scales the texture
  97971. * @param ratio the scale factor to apply to both width and height
  97972. */
  97973. scale(ratio: number): void;
  97974. /**
  97975. * Resizes the texture
  97976. * @param width the new width
  97977. * @param height the new height
  97978. */
  97979. scaleTo(width: number, height: number): void;
  97980. /**
  97981. * Gets the context of the canvas used by the texture
  97982. * @returns the canvas context of the dynamic texture
  97983. */
  97984. getContext(): CanvasRenderingContext2D;
  97985. /**
  97986. * Clears the texture
  97987. */
  97988. clear(): void;
  97989. /**
  97990. * Updates the texture
  97991. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  97992. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  97993. */
  97994. update(invertY?: boolean, premulAlpha?: boolean): void;
  97995. /**
  97996. * Draws text onto the texture
  97997. * @param text defines the text to be drawn
  97998. * @param x defines the placement of the text from the left
  97999. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  98000. * @param font defines the font to be used with font-style, font-size, font-name
  98001. * @param color defines the color used for the text
  98002. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  98003. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98004. * @param update defines whether texture is immediately update (default is true)
  98005. */
  98006. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  98007. /**
  98008. * Clones the texture
  98009. * @returns the clone of the texture.
  98010. */
  98011. clone(): DynamicTexture;
  98012. /**
  98013. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  98014. * @returns a serialized dynamic texture object
  98015. */
  98016. serialize(): any;
  98017. /** @hidden */
  98018. _rebuild(): void;
  98019. }
  98020. }
  98021. declare module BABYLON {
  98022. /** @hidden */
  98023. export var imageProcessingPixelShader: {
  98024. name: string;
  98025. shader: string;
  98026. };
  98027. }
  98028. declare module BABYLON {
  98029. /**
  98030. * ImageProcessingPostProcess
  98031. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  98032. */
  98033. export class ImageProcessingPostProcess extends PostProcess {
  98034. /**
  98035. * Default configuration related to image processing available in the PBR Material.
  98036. */
  98037. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98038. /**
  98039. * Gets the image processing configuration used either in this material.
  98040. */
  98041. /**
  98042. * Sets the Default image processing configuration used either in the this material.
  98043. *
  98044. * If sets to null, the scene one is in use.
  98045. */
  98046. imageProcessingConfiguration: ImageProcessingConfiguration;
  98047. /**
  98048. * Keep track of the image processing observer to allow dispose and replace.
  98049. */
  98050. private _imageProcessingObserver;
  98051. /**
  98052. * Attaches a new image processing configuration to the PBR Material.
  98053. * @param configuration
  98054. */
  98055. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  98056. /**
  98057. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98058. */
  98059. /**
  98060. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98061. */
  98062. colorCurves: Nullable<ColorCurves>;
  98063. /**
  98064. * Gets wether the color curves effect is enabled.
  98065. */
  98066. /**
  98067. * Sets wether the color curves effect is enabled.
  98068. */
  98069. colorCurvesEnabled: boolean;
  98070. /**
  98071. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98072. */
  98073. /**
  98074. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98075. */
  98076. colorGradingTexture: Nullable<BaseTexture>;
  98077. /**
  98078. * Gets wether the color grading effect is enabled.
  98079. */
  98080. /**
  98081. * Gets wether the color grading effect is enabled.
  98082. */
  98083. colorGradingEnabled: boolean;
  98084. /**
  98085. * Gets exposure used in the effect.
  98086. */
  98087. /**
  98088. * Sets exposure used in the effect.
  98089. */
  98090. exposure: number;
  98091. /**
  98092. * Gets wether tonemapping is enabled or not.
  98093. */
  98094. /**
  98095. * Sets wether tonemapping is enabled or not
  98096. */
  98097. toneMappingEnabled: boolean;
  98098. /**
  98099. * Gets the type of tone mapping effect.
  98100. */
  98101. /**
  98102. * Sets the type of tone mapping effect.
  98103. */
  98104. toneMappingType: number;
  98105. /**
  98106. * Gets contrast used in the effect.
  98107. */
  98108. /**
  98109. * Sets contrast used in the effect.
  98110. */
  98111. contrast: number;
  98112. /**
  98113. * Gets Vignette stretch size.
  98114. */
  98115. /**
  98116. * Sets Vignette stretch size.
  98117. */
  98118. vignetteStretch: number;
  98119. /**
  98120. * Gets Vignette centre X Offset.
  98121. */
  98122. /**
  98123. * Sets Vignette centre X Offset.
  98124. */
  98125. vignetteCentreX: number;
  98126. /**
  98127. * Gets Vignette centre Y Offset.
  98128. */
  98129. /**
  98130. * Sets Vignette centre Y Offset.
  98131. */
  98132. vignetteCentreY: number;
  98133. /**
  98134. * Gets Vignette weight or intensity of the vignette effect.
  98135. */
  98136. /**
  98137. * Sets Vignette weight or intensity of the vignette effect.
  98138. */
  98139. vignetteWeight: number;
  98140. /**
  98141. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98142. * if vignetteEnabled is set to true.
  98143. */
  98144. /**
  98145. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98146. * if vignetteEnabled is set to true.
  98147. */
  98148. vignetteColor: Color4;
  98149. /**
  98150. * Gets Camera field of view used by the Vignette effect.
  98151. */
  98152. /**
  98153. * Sets Camera field of view used by the Vignette effect.
  98154. */
  98155. vignetteCameraFov: number;
  98156. /**
  98157. * Gets the vignette blend mode allowing different kind of effect.
  98158. */
  98159. /**
  98160. * Sets the vignette blend mode allowing different kind of effect.
  98161. */
  98162. vignetteBlendMode: number;
  98163. /**
  98164. * Gets wether the vignette effect is enabled.
  98165. */
  98166. /**
  98167. * Sets wether the vignette effect is enabled.
  98168. */
  98169. vignetteEnabled: boolean;
  98170. private _fromLinearSpace;
  98171. /**
  98172. * Gets wether the input of the processing is in Gamma or Linear Space.
  98173. */
  98174. /**
  98175. * Sets wether the input of the processing is in Gamma or Linear Space.
  98176. */
  98177. fromLinearSpace: boolean;
  98178. /**
  98179. * Defines cache preventing GC.
  98180. */
  98181. private _defines;
  98182. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  98183. /**
  98184. * "ImageProcessingPostProcess"
  98185. * @returns "ImageProcessingPostProcess"
  98186. */
  98187. getClassName(): string;
  98188. protected _updateParameters(): void;
  98189. dispose(camera?: Camera): void;
  98190. }
  98191. }
  98192. declare module BABYLON {
  98193. /**
  98194. * Class containing static functions to help procedurally build meshes
  98195. */
  98196. export class GroundBuilder {
  98197. /**
  98198. * Creates a ground mesh
  98199. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  98200. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  98201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98202. * @param name defines the name of the mesh
  98203. * @param options defines the options used to create the mesh
  98204. * @param scene defines the hosting scene
  98205. * @returns the ground mesh
  98206. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  98207. */
  98208. static CreateGround(name: string, options: {
  98209. width?: number;
  98210. height?: number;
  98211. subdivisions?: number;
  98212. subdivisionsX?: number;
  98213. subdivisionsY?: number;
  98214. updatable?: boolean;
  98215. }, scene: any): Mesh;
  98216. /**
  98217. * Creates a tiled ground mesh
  98218. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  98219. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  98220. * * 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
  98221. * * 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
  98222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98223. * @param name defines the name of the mesh
  98224. * @param options defines the options used to create the mesh
  98225. * @param scene defines the hosting scene
  98226. * @returns the tiled ground mesh
  98227. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  98228. */
  98229. static CreateTiledGround(name: string, options: {
  98230. xmin: number;
  98231. zmin: number;
  98232. xmax: number;
  98233. zmax: number;
  98234. subdivisions?: {
  98235. w: number;
  98236. h: number;
  98237. };
  98238. precision?: {
  98239. w: number;
  98240. h: number;
  98241. };
  98242. updatable?: boolean;
  98243. }, scene: Scene): Mesh;
  98244. /**
  98245. * Creates a ground mesh from a height map
  98246. * * The parameter `url` sets the URL of the height map image resource.
  98247. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  98248. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  98249. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  98250. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  98251. * * 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.
  98252. * * 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).
  98253. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98255. * @param name defines the name of the mesh
  98256. * @param url defines the url to the height map
  98257. * @param options defines the options used to create the mesh
  98258. * @param scene defines the hosting scene
  98259. * @returns the ground mesh
  98260. * @see https://doc.babylonjs.com/babylon101/height_map
  98261. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  98262. */
  98263. static CreateGroundFromHeightMap(name: string, url: string, options: {
  98264. width?: number;
  98265. height?: number;
  98266. subdivisions?: number;
  98267. minHeight?: number;
  98268. maxHeight?: number;
  98269. colorFilter?: Color3;
  98270. alphaFilter?: number;
  98271. updatable?: boolean;
  98272. onReady?: (mesh: GroundMesh) => void;
  98273. }, scene: Scene): GroundMesh;
  98274. }
  98275. }
  98276. declare module BABYLON {
  98277. /**
  98278. * Class containing static functions to help procedurally build meshes
  98279. */
  98280. export class TorusBuilder {
  98281. /**
  98282. * Creates a torus mesh
  98283. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  98284. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  98285. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  98286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98289. * @param name defines the name of the mesh
  98290. * @param options defines the options used to create the mesh
  98291. * @param scene defines the hosting scene
  98292. * @returns the torus mesh
  98293. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  98294. */
  98295. static CreateTorus(name: string, options: {
  98296. diameter?: number;
  98297. thickness?: number;
  98298. tessellation?: number;
  98299. updatable?: boolean;
  98300. sideOrientation?: number;
  98301. frontUVs?: Vector4;
  98302. backUVs?: Vector4;
  98303. }, scene: any): Mesh;
  98304. }
  98305. }
  98306. declare module BABYLON {
  98307. /**
  98308. * Class containing static functions to help procedurally build meshes
  98309. */
  98310. export class CylinderBuilder {
  98311. /**
  98312. * Creates a cylinder or a cone mesh
  98313. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  98314. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  98315. * * 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.
  98316. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  98317. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  98318. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  98319. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  98320. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  98321. * * 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).
  98322. * * 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
  98323. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  98324. * * 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
  98325. * * 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.
  98326. * * If `enclose` is false, a ring surface is one element.
  98327. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  98328. * * 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
  98329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98332. * @param name defines the name of the mesh
  98333. * @param options defines the options used to create the mesh
  98334. * @param scene defines the hosting scene
  98335. * @returns the cylinder mesh
  98336. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  98337. */
  98338. static CreateCylinder(name: string, options: {
  98339. height?: number;
  98340. diameterTop?: number;
  98341. diameterBottom?: number;
  98342. diameter?: number;
  98343. tessellation?: number;
  98344. subdivisions?: number;
  98345. arc?: number;
  98346. faceColors?: Color4[];
  98347. faceUV?: Vector4[];
  98348. updatable?: boolean;
  98349. hasRings?: boolean;
  98350. enclose?: boolean;
  98351. sideOrientation?: number;
  98352. frontUVs?: Vector4;
  98353. backUVs?: Vector4;
  98354. }, scene: any): Mesh;
  98355. }
  98356. }
  98357. declare module BABYLON {
  98358. /**
  98359. * Manager for handling gamepads
  98360. */
  98361. export class GamepadManager {
  98362. private _scene?;
  98363. private _babylonGamepads;
  98364. private _oneGamepadConnected;
  98365. /** @hidden */
  98366. _isMonitoring: boolean;
  98367. private _gamepadEventSupported;
  98368. private _gamepadSupport;
  98369. /**
  98370. * observable to be triggered when the gamepad controller has been connected
  98371. */
  98372. onGamepadConnectedObservable: Observable<Gamepad>;
  98373. /**
  98374. * observable to be triggered when the gamepad controller has been disconnected
  98375. */
  98376. onGamepadDisconnectedObservable: Observable<Gamepad>;
  98377. private _onGamepadConnectedEvent;
  98378. private _onGamepadDisconnectedEvent;
  98379. /**
  98380. * Initializes the gamepad manager
  98381. * @param _scene BabylonJS scene
  98382. */
  98383. constructor(_scene?: Scene | undefined);
  98384. /**
  98385. * The gamepads in the game pad manager
  98386. */
  98387. readonly gamepads: Gamepad[];
  98388. /**
  98389. * Get the gamepad controllers based on type
  98390. * @param type The type of gamepad controller
  98391. * @returns Nullable gamepad
  98392. */
  98393. getGamepadByType(type?: number): Nullable<Gamepad>;
  98394. /**
  98395. * Disposes the gamepad manager
  98396. */
  98397. dispose(): void;
  98398. private _addNewGamepad;
  98399. private _startMonitoringGamepads;
  98400. private _stopMonitoringGamepads;
  98401. /** @hidden */
  98402. _checkGamepadsStatus(): void;
  98403. private _updateGamepadObjects;
  98404. }
  98405. }
  98406. declare module BABYLON {
  98407. interface Scene {
  98408. /** @hidden */
  98409. _gamepadManager: Nullable<GamepadManager>;
  98410. /**
  98411. * Gets the gamepad manager associated with the scene
  98412. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  98413. */
  98414. gamepadManager: GamepadManager;
  98415. }
  98416. /**
  98417. * Interface representing a free camera inputs manager
  98418. */
  98419. interface FreeCameraInputsManager {
  98420. /**
  98421. * Adds gamepad input support to the FreeCameraInputsManager.
  98422. * @returns the FreeCameraInputsManager
  98423. */
  98424. addGamepad(): FreeCameraInputsManager;
  98425. }
  98426. /**
  98427. * Interface representing an arc rotate camera inputs manager
  98428. */
  98429. interface ArcRotateCameraInputsManager {
  98430. /**
  98431. * Adds gamepad input support to the ArcRotateCamera InputManager.
  98432. * @returns the camera inputs manager
  98433. */
  98434. addGamepad(): ArcRotateCameraInputsManager;
  98435. }
  98436. /**
  98437. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  98438. */
  98439. export class GamepadSystemSceneComponent implements ISceneComponent {
  98440. /**
  98441. * The component name helpfull to identify the component in the list of scene components.
  98442. */
  98443. readonly name: string;
  98444. /**
  98445. * The scene the component belongs to.
  98446. */
  98447. scene: Scene;
  98448. /**
  98449. * Creates a new instance of the component for the given scene
  98450. * @param scene Defines the scene to register the component in
  98451. */
  98452. constructor(scene: Scene);
  98453. /**
  98454. * Registers the component in a given scene
  98455. */
  98456. register(): void;
  98457. /**
  98458. * Rebuilds the elements related to this component in case of
  98459. * context lost for instance.
  98460. */
  98461. rebuild(): void;
  98462. /**
  98463. * Disposes the component and the associated ressources
  98464. */
  98465. dispose(): void;
  98466. private _beforeCameraUpdate;
  98467. }
  98468. }
  98469. declare module BABYLON {
  98470. /**
  98471. * Options to modify the vr teleportation behavior.
  98472. */
  98473. export interface VRTeleportationOptions {
  98474. /**
  98475. * The name of the mesh which should be used as the teleportation floor. (default: null)
  98476. */
  98477. floorMeshName?: string;
  98478. /**
  98479. * A list of meshes to be used as the teleportation floor. (default: empty)
  98480. */
  98481. floorMeshes?: Mesh[];
  98482. }
  98483. /**
  98484. * Options to modify the vr experience helper's behavior.
  98485. */
  98486. export interface VRExperienceHelperOptions extends WebVROptions {
  98487. /**
  98488. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  98489. */
  98490. createDeviceOrientationCamera?: boolean;
  98491. /**
  98492. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  98493. */
  98494. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  98495. /**
  98496. * Uses the main button on the controller to toggle the laser casted. (default: true)
  98497. */
  98498. laserToggle?: boolean;
  98499. /**
  98500. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  98501. */
  98502. floorMeshes?: Mesh[];
  98503. /**
  98504. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  98505. */
  98506. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  98507. }
  98508. /**
  98509. * Event containing information after VR has been entered
  98510. */
  98511. export class OnAfterEnteringVRObservableEvent {
  98512. /**
  98513. * If entering vr was successful
  98514. */
  98515. success: boolean;
  98516. }
  98517. /**
  98518. * Helps to quickly add VR support to an existing scene.
  98519. * See http://doc.babylonjs.com/how_to/webvr_helper
  98520. */
  98521. export class VRExperienceHelper {
  98522. /** Options to modify the vr experience helper's behavior. */
  98523. webVROptions: VRExperienceHelperOptions;
  98524. private _scene;
  98525. private _position;
  98526. private _btnVR;
  98527. private _btnVRDisplayed;
  98528. private _webVRsupported;
  98529. private _webVRready;
  98530. private _webVRrequesting;
  98531. private _webVRpresenting;
  98532. private _hasEnteredVR;
  98533. private _fullscreenVRpresenting;
  98534. private _canvas;
  98535. private _webVRCamera;
  98536. private _vrDeviceOrientationCamera;
  98537. private _deviceOrientationCamera;
  98538. private _existingCamera;
  98539. private _onKeyDown;
  98540. private _onVrDisplayPresentChange;
  98541. private _onVRDisplayChanged;
  98542. private _onVRRequestPresentStart;
  98543. private _onVRRequestPresentComplete;
  98544. /**
  98545. * Observable raised right before entering VR.
  98546. */
  98547. onEnteringVRObservable: Observable<VRExperienceHelper>;
  98548. /**
  98549. * Observable raised when entering VR has completed.
  98550. */
  98551. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  98552. /**
  98553. * Observable raised when exiting VR.
  98554. */
  98555. onExitingVRObservable: Observable<VRExperienceHelper>;
  98556. /**
  98557. * Observable raised when controller mesh is loaded.
  98558. */
  98559. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98560. /** Return this.onEnteringVRObservable
  98561. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  98562. */
  98563. readonly onEnteringVR: Observable<VRExperienceHelper>;
  98564. /** Return this.onExitingVRObservable
  98565. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  98566. */
  98567. readonly onExitingVR: Observable<VRExperienceHelper>;
  98568. /** Return this.onControllerMeshLoadedObservable
  98569. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  98570. */
  98571. readonly onControllerMeshLoaded: Observable<WebVRController>;
  98572. private _rayLength;
  98573. private _useCustomVRButton;
  98574. private _teleportationRequested;
  98575. private _teleportActive;
  98576. private _floorMeshName;
  98577. private _floorMeshesCollection;
  98578. private _rotationAllowed;
  98579. private _teleportBackwardsVector;
  98580. private _teleportationTarget;
  98581. private _isDefaultTeleportationTarget;
  98582. private _postProcessMove;
  98583. private _teleportationFillColor;
  98584. private _teleportationBorderColor;
  98585. private _rotationAngle;
  98586. private _haloCenter;
  98587. private _cameraGazer;
  98588. private _padSensibilityUp;
  98589. private _padSensibilityDown;
  98590. private _leftController;
  98591. private _rightController;
  98592. /**
  98593. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  98594. */
  98595. onNewMeshSelected: Observable<AbstractMesh>;
  98596. /**
  98597. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  98598. */
  98599. onNewMeshPicked: Observable<PickingInfo>;
  98600. private _circleEase;
  98601. /**
  98602. * Observable raised before camera teleportation
  98603. */
  98604. onBeforeCameraTeleport: Observable<Vector3>;
  98605. /**
  98606. * Observable raised after camera teleportation
  98607. */
  98608. onAfterCameraTeleport: Observable<Vector3>;
  98609. /**
  98610. * Observable raised when current selected mesh gets unselected
  98611. */
  98612. onSelectedMeshUnselected: Observable<AbstractMesh>;
  98613. private _raySelectionPredicate;
  98614. /**
  98615. * To be optionaly changed by user to define custom ray selection
  98616. */
  98617. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  98618. /**
  98619. * To be optionaly changed by user to define custom selection logic (after ray selection)
  98620. */
  98621. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  98622. /**
  98623. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  98624. */
  98625. teleportationEnabled: boolean;
  98626. private _defaultHeight;
  98627. private _teleportationInitialized;
  98628. private _interactionsEnabled;
  98629. private _interactionsRequested;
  98630. private _displayGaze;
  98631. private _displayLaserPointer;
  98632. /**
  98633. * The mesh used to display where the user is going to teleport.
  98634. */
  98635. /**
  98636. * Sets the mesh to be used to display where the user is going to teleport.
  98637. */
  98638. teleportationTarget: Mesh;
  98639. /**
  98640. * 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
  98641. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  98642. * See http://doc.babylonjs.com/resources/baking_transformations
  98643. */
  98644. gazeTrackerMesh: Mesh;
  98645. /**
  98646. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  98647. */
  98648. updateGazeTrackerScale: boolean;
  98649. /**
  98650. * If the gaze trackers color should be updated when selecting meshes
  98651. */
  98652. updateGazeTrackerColor: boolean;
  98653. /**
  98654. * The gaze tracking mesh corresponding to the left controller
  98655. */
  98656. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  98657. /**
  98658. * The gaze tracking mesh corresponding to the right controller
  98659. */
  98660. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  98661. /**
  98662. * If the ray of the gaze should be displayed.
  98663. */
  98664. /**
  98665. * Sets if the ray of the gaze should be displayed.
  98666. */
  98667. displayGaze: boolean;
  98668. /**
  98669. * If the ray of the LaserPointer should be displayed.
  98670. */
  98671. /**
  98672. * Sets if the ray of the LaserPointer should be displayed.
  98673. */
  98674. displayLaserPointer: boolean;
  98675. /**
  98676. * The deviceOrientationCamera used as the camera when not in VR.
  98677. */
  98678. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  98679. /**
  98680. * Based on the current WebVR support, returns the current VR camera used.
  98681. */
  98682. readonly currentVRCamera: Nullable<Camera>;
  98683. /**
  98684. * The webVRCamera which is used when in VR.
  98685. */
  98686. readonly webVRCamera: WebVRFreeCamera;
  98687. /**
  98688. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  98689. */
  98690. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  98691. private readonly _teleportationRequestInitiated;
  98692. /**
  98693. * Defines wether or not Pointer lock should be requested when switching to
  98694. * full screen.
  98695. */
  98696. requestPointerLockOnFullScreen: boolean;
  98697. /**
  98698. * Instantiates a VRExperienceHelper.
  98699. * Helps to quickly add VR support to an existing scene.
  98700. * @param scene The scene the VRExperienceHelper belongs to.
  98701. * @param webVROptions Options to modify the vr experience helper's behavior.
  98702. */
  98703. constructor(scene: Scene,
  98704. /** Options to modify the vr experience helper's behavior. */
  98705. webVROptions?: VRExperienceHelperOptions);
  98706. private _onDefaultMeshLoaded;
  98707. private _onResize;
  98708. private _onFullscreenChange;
  98709. /**
  98710. * Gets a value indicating if we are currently in VR mode.
  98711. */
  98712. readonly isInVRMode: boolean;
  98713. private onVrDisplayPresentChange;
  98714. private onVRDisplayChanged;
  98715. private moveButtonToBottomRight;
  98716. private displayVRButton;
  98717. private updateButtonVisibility;
  98718. private _cachedAngularSensibility;
  98719. /**
  98720. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  98721. * Otherwise, will use the fullscreen API.
  98722. */
  98723. enterVR(): void;
  98724. /**
  98725. * Attempt to exit VR, or fullscreen.
  98726. */
  98727. exitVR(): void;
  98728. /**
  98729. * The position of the vr experience helper.
  98730. */
  98731. /**
  98732. * Sets the position of the vr experience helper.
  98733. */
  98734. position: Vector3;
  98735. /**
  98736. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  98737. */
  98738. enableInteractions(): void;
  98739. private readonly _noControllerIsActive;
  98740. private beforeRender;
  98741. private _isTeleportationFloor;
  98742. /**
  98743. * Adds a floor mesh to be used for teleportation.
  98744. * @param floorMesh the mesh to be used for teleportation.
  98745. */
  98746. addFloorMesh(floorMesh: Mesh): void;
  98747. /**
  98748. * Removes a floor mesh from being used for teleportation.
  98749. * @param floorMesh the mesh to be removed.
  98750. */
  98751. removeFloorMesh(floorMesh: Mesh): void;
  98752. /**
  98753. * Enables interactions and teleportation using the VR controllers and gaze.
  98754. * @param vrTeleportationOptions options to modify teleportation behavior.
  98755. */
  98756. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  98757. private _onNewGamepadConnected;
  98758. private _tryEnableInteractionOnController;
  98759. private _onNewGamepadDisconnected;
  98760. private _enableInteractionOnController;
  98761. private _checkTeleportWithRay;
  98762. private _checkRotate;
  98763. private _checkTeleportBackwards;
  98764. private _enableTeleportationOnController;
  98765. private _createTeleportationCircles;
  98766. private _displayTeleportationTarget;
  98767. private _hideTeleportationTarget;
  98768. private _rotateCamera;
  98769. private _moveTeleportationSelectorTo;
  98770. private _workingVector;
  98771. private _workingQuaternion;
  98772. private _workingMatrix;
  98773. /**
  98774. * Teleports the users feet to the desired location
  98775. * @param location The location where the user's feet should be placed
  98776. */
  98777. teleportCamera(location: Vector3): void;
  98778. private _convertNormalToDirectionOfRay;
  98779. private _castRayAndSelectObject;
  98780. private _notifySelectedMeshUnselected;
  98781. /**
  98782. * Sets the color of the laser ray from the vr controllers.
  98783. * @param color new color for the ray.
  98784. */
  98785. changeLaserColor(color: Color3): void;
  98786. /**
  98787. * Sets the color of the ray from the vr headsets gaze.
  98788. * @param color new color for the ray.
  98789. */
  98790. changeGazeColor(color: Color3): void;
  98791. /**
  98792. * Exits VR and disposes of the vr experience helper
  98793. */
  98794. dispose(): void;
  98795. /**
  98796. * Gets the name of the VRExperienceHelper class
  98797. * @returns "VRExperienceHelper"
  98798. */
  98799. getClassName(): string;
  98800. }
  98801. }
  98802. declare module BABYLON {
  98803. /**
  98804. * Manages an XRSession
  98805. * @see https://doc.babylonjs.com/how_to/webxr
  98806. */
  98807. export class WebXRSessionManager implements IDisposable {
  98808. private scene;
  98809. /**
  98810. * Fires every time a new xrFrame arrives which can be used to update the camera
  98811. */
  98812. onXRFrameObservable: Observable<any>;
  98813. /**
  98814. * Fires when the xr session is ended either by the device or manually done
  98815. */
  98816. onXRSessionEnded: Observable<any>;
  98817. /** @hidden */
  98818. _xrSession: XRSession;
  98819. /** @hidden */
  98820. _frameOfReference: XRFrameOfReference;
  98821. /** @hidden */
  98822. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  98823. /** @hidden */
  98824. _currentXRFrame: Nullable<XRFrame>;
  98825. private _xrNavigator;
  98826. private _xrDevice;
  98827. private _tmpMatrix;
  98828. /**
  98829. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  98830. * @param scene The scene which the session should be created for
  98831. */
  98832. constructor(scene: Scene);
  98833. /**
  98834. * Initializes the manager
  98835. * After initialization enterXR can be called to start an XR session
  98836. * @returns Promise which resolves after it is initialized
  98837. */
  98838. initializeAsync(): Promise<void>;
  98839. /**
  98840. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  98841. * @param sessionCreationOptions xr options to create the session with
  98842. * @param frameOfReferenceType option to configure how the xr pose is expressed
  98843. * @returns Promise which resolves after it enters XR
  98844. */
  98845. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  98846. /**
  98847. * Stops the xrSession and restores the renderloop
  98848. * @returns Promise which resolves after it exits XR
  98849. */
  98850. exitXRAsync(): Promise<void>;
  98851. /**
  98852. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98853. * @param ray ray to cast into the environment
  98854. * @returns Promise which resolves with a collision point in the environment if it exists
  98855. */
  98856. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98857. /**
  98858. * Checks if a session would be supported for the creation options specified
  98859. * @param options creation options to check if they are supported
  98860. * @returns true if supported
  98861. */
  98862. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98863. /**
  98864. * @hidden
  98865. * Converts the render layer of xrSession to a render target
  98866. * @param session session to create render target for
  98867. * @param scene scene the new render target should be created for
  98868. */
  98869. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  98870. /**
  98871. * Disposes of the session manager
  98872. */
  98873. dispose(): void;
  98874. }
  98875. }
  98876. declare module BABYLON {
  98877. /**
  98878. * WebXR Camera which holds the views for the xrSession
  98879. * @see https://doc.babylonjs.com/how_to/webxr
  98880. */
  98881. export class WebXRCamera extends FreeCamera {
  98882. private static _TmpMatrix;
  98883. /**
  98884. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  98885. * @param name the name of the camera
  98886. * @param scene the scene to add the camera to
  98887. */
  98888. constructor(name: string, scene: Scene);
  98889. private _updateNumberOfRigCameras;
  98890. /** @hidden */
  98891. _updateForDualEyeDebugging(pupilDistance?: number): void;
  98892. /**
  98893. * Updates the cameras position from the current pose information of the XR session
  98894. * @param xrSessionManager the session containing pose information
  98895. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  98896. */
  98897. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  98898. }
  98899. }
  98900. declare module BABYLON {
  98901. /**
  98902. * States of the webXR experience
  98903. */
  98904. export enum WebXRState {
  98905. /**
  98906. * Transitioning to being in XR mode
  98907. */
  98908. ENTERING_XR = 0,
  98909. /**
  98910. * Transitioning to non XR mode
  98911. */
  98912. EXITING_XR = 1,
  98913. /**
  98914. * In XR mode and presenting
  98915. */
  98916. IN_XR = 2,
  98917. /**
  98918. * Not entered XR mode
  98919. */
  98920. NOT_IN_XR = 3
  98921. }
  98922. /**
  98923. * Helper class used to enable XR
  98924. * @see https://doc.babylonjs.com/how_to/webxr
  98925. */
  98926. export class WebXRExperienceHelper implements IDisposable {
  98927. private scene;
  98928. /**
  98929. * 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
  98930. */
  98931. container: AbstractMesh;
  98932. /**
  98933. * Camera used to render xr content
  98934. */
  98935. camera: WebXRCamera;
  98936. /**
  98937. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  98938. */
  98939. state: WebXRState;
  98940. private _setState;
  98941. private static _TmpVector;
  98942. /**
  98943. * Fires when the state of the experience helper has changed
  98944. */
  98945. onStateChangedObservable: Observable<WebXRState>;
  98946. /** @hidden */
  98947. _sessionManager: WebXRSessionManager;
  98948. private _nonVRCamera;
  98949. private _originalSceneAutoClear;
  98950. private _supported;
  98951. /**
  98952. * Creates the experience helper
  98953. * @param scene the scene to attach the experience helper to
  98954. * @returns a promise for the experience helper
  98955. */
  98956. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  98957. /**
  98958. * Creates a WebXRExperienceHelper
  98959. * @param scene The scene the helper should be created in
  98960. */
  98961. private constructor();
  98962. /**
  98963. * Exits XR mode and returns the scene to its original state
  98964. * @returns promise that resolves after xr mode has exited
  98965. */
  98966. exitXRAsync(): Promise<void>;
  98967. /**
  98968. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  98969. * @param sessionCreationOptions options for the XR session
  98970. * @param frameOfReference frame of reference of the XR session
  98971. * @returns promise that resolves after xr mode has entered
  98972. */
  98973. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  98974. /**
  98975. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98976. * @param ray ray to cast into the environment
  98977. * @returns Promise which resolves with a collision point in the environment if it exists
  98978. */
  98979. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98980. /**
  98981. * Updates the global position of the camera by moving the camera's container
  98982. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  98983. * @param position The desired global position of the camera
  98984. */
  98985. setPositionOfCameraUsingContainer(position: Vector3): void;
  98986. /**
  98987. * Rotates the xr camera by rotating the camera's container around the camera's position
  98988. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  98989. * @param rotation the desired quaternion rotation to apply to the camera
  98990. */
  98991. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  98992. /**
  98993. * Checks if the creation options are supported by the xr session
  98994. * @param options creation options
  98995. * @returns true if supported
  98996. */
  98997. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98998. /**
  98999. * Disposes of the experience helper
  99000. */
  99001. dispose(): void;
  99002. }
  99003. }
  99004. declare module BABYLON {
  99005. /**
  99006. * Button which can be used to enter a different mode of XR
  99007. */
  99008. export class WebXREnterExitUIButton {
  99009. /** button element */
  99010. element: HTMLElement;
  99011. /** XR initialization options for the button */
  99012. initializationOptions: XRSessionCreationOptions;
  99013. /**
  99014. * Creates a WebXREnterExitUIButton
  99015. * @param element button element
  99016. * @param initializationOptions XR initialization options for the button
  99017. */
  99018. constructor(
  99019. /** button element */
  99020. element: HTMLElement,
  99021. /** XR initialization options for the button */
  99022. initializationOptions: XRSessionCreationOptions);
  99023. /**
  99024. * Overwritable function which can be used to update the button's visuals when the state changes
  99025. * @param activeButton the current active button in the UI
  99026. */
  99027. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  99028. }
  99029. /**
  99030. * Options to create the webXR UI
  99031. */
  99032. export class WebXREnterExitUIOptions {
  99033. /**
  99034. * Context to enter xr with
  99035. */
  99036. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  99037. /**
  99038. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  99039. */
  99040. customButtons?: Array<WebXREnterExitUIButton>;
  99041. }
  99042. /**
  99043. * UI to allow the user to enter/exit XR mode
  99044. */
  99045. export class WebXREnterExitUI implements IDisposable {
  99046. private scene;
  99047. private _overlay;
  99048. private _buttons;
  99049. private _activeButton;
  99050. /**
  99051. * Fired every time the active button is changed.
  99052. *
  99053. * When xr is entered via a button that launches xr that button will be the callback parameter
  99054. *
  99055. * When exiting xr the callback parameter will be null)
  99056. */
  99057. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  99058. /**
  99059. * Creates UI to allow the user to enter/exit XR mode
  99060. * @param scene the scene to add the ui to
  99061. * @param helper the xr experience helper to enter/exit xr with
  99062. * @param options options to configure the UI
  99063. * @returns the created ui
  99064. */
  99065. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  99066. private constructor();
  99067. private _updateButtons;
  99068. /**
  99069. * Disposes of the object
  99070. */
  99071. dispose(): void;
  99072. }
  99073. }
  99074. declare module BABYLON {
  99075. /**
  99076. * Represents an XR input
  99077. */
  99078. export class WebXRController {
  99079. /**
  99080. * 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
  99081. */
  99082. grip?: AbstractMesh;
  99083. /**
  99084. * Pointer which can be used to select objects or attach a visible laser to
  99085. */
  99086. pointer: AbstractMesh;
  99087. /**
  99088. * Creates the controller
  99089. * @see https://doc.babylonjs.com/how_to/webxr
  99090. * @param scene the scene which the controller should be associated to
  99091. */
  99092. constructor(scene: Scene);
  99093. /**
  99094. * Disposes of the object
  99095. */
  99096. dispose(): void;
  99097. }
  99098. /**
  99099. * XR input used to track XR inputs such as controllers/rays
  99100. */
  99101. export class WebXRInput implements IDisposable {
  99102. private helper;
  99103. /**
  99104. * XR controllers being tracked
  99105. */
  99106. controllers: Array<WebXRController>;
  99107. private _tmpMatrix;
  99108. private _frameObserver;
  99109. /**
  99110. * Initializes the WebXRInput
  99111. * @param helper experience helper which the input should be created for
  99112. */
  99113. constructor(helper: WebXRExperienceHelper);
  99114. /**
  99115. * Disposes of the object
  99116. */
  99117. dispose(): void;
  99118. }
  99119. }
  99120. declare module BABYLON {
  99121. /**
  99122. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  99123. */
  99124. export class WebXRManagedOutputCanvas implements IDisposable {
  99125. private _canvas;
  99126. /**
  99127. * xrpresent context of the canvas which can be used to display/mirror xr content
  99128. */
  99129. canvasContext: Nullable<WebGLRenderingContext>;
  99130. /**
  99131. * Initializes the canvas to be added/removed upon entering/exiting xr
  99132. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  99133. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  99134. */
  99135. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  99136. /**
  99137. * Disposes of the object
  99138. */
  99139. dispose(): void;
  99140. private _setManagedOutputCanvas;
  99141. private _addCanvas;
  99142. private _removeCanvas;
  99143. }
  99144. }
  99145. declare module BABYLON {
  99146. /**
  99147. * Contains an array of blocks representing the octree
  99148. */
  99149. export interface IOctreeContainer<T> {
  99150. /**
  99151. * Blocks within the octree
  99152. */
  99153. blocks: Array<OctreeBlock<T>>;
  99154. }
  99155. /**
  99156. * Class used to store a cell in an octree
  99157. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99158. */
  99159. export class OctreeBlock<T> {
  99160. /**
  99161. * Gets the content of the current block
  99162. */
  99163. entries: T[];
  99164. /**
  99165. * Gets the list of block children
  99166. */
  99167. blocks: Array<OctreeBlock<T>>;
  99168. private _depth;
  99169. private _maxDepth;
  99170. private _capacity;
  99171. private _minPoint;
  99172. private _maxPoint;
  99173. private _boundingVectors;
  99174. private _creationFunc;
  99175. /**
  99176. * Creates a new block
  99177. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  99178. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  99179. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99180. * @param depth defines the current depth of this block in the octree
  99181. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  99182. * @param creationFunc defines a callback to call when an element is added to the block
  99183. */
  99184. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  99185. /**
  99186. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99187. */
  99188. readonly capacity: number;
  99189. /**
  99190. * Gets the minimum vector (in world space) of the block's bounding box
  99191. */
  99192. readonly minPoint: Vector3;
  99193. /**
  99194. * Gets the maximum vector (in world space) of the block's bounding box
  99195. */
  99196. readonly maxPoint: Vector3;
  99197. /**
  99198. * Add a new element to this block
  99199. * @param entry defines the element to add
  99200. */
  99201. addEntry(entry: T): void;
  99202. /**
  99203. * Remove an element from this block
  99204. * @param entry defines the element to remove
  99205. */
  99206. removeEntry(entry: T): void;
  99207. /**
  99208. * Add an array of elements to this block
  99209. * @param entries defines the array of elements to add
  99210. */
  99211. addEntries(entries: T[]): void;
  99212. /**
  99213. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  99214. * @param frustumPlanes defines the frustum planes to test
  99215. * @param selection defines the array to store current content if selection is positive
  99216. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99217. */
  99218. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99219. /**
  99220. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  99221. * @param sphereCenter defines the bounding sphere center
  99222. * @param sphereRadius defines the bounding sphere radius
  99223. * @param selection defines the array to store current content if selection is positive
  99224. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99225. */
  99226. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99227. /**
  99228. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  99229. * @param ray defines the ray to test with
  99230. * @param selection defines the array to store current content if selection is positive
  99231. */
  99232. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  99233. /**
  99234. * Subdivide the content into child blocks (this block will then be empty)
  99235. */
  99236. createInnerBlocks(): void;
  99237. /**
  99238. * @hidden
  99239. */
  99240. 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;
  99241. }
  99242. }
  99243. declare module BABYLON {
  99244. /**
  99245. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  99246. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99247. */
  99248. export class Octree<T> {
  99249. /** 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.) */
  99250. maxDepth: number;
  99251. /**
  99252. * Blocks within the octree containing objects
  99253. */
  99254. blocks: Array<OctreeBlock<T>>;
  99255. /**
  99256. * Content stored in the octree
  99257. */
  99258. dynamicContent: T[];
  99259. private _maxBlockCapacity;
  99260. private _selectionContent;
  99261. private _creationFunc;
  99262. /**
  99263. * Creates a octree
  99264. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99265. * @param creationFunc function to be used to instatiate the octree
  99266. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  99267. * @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.)
  99268. */
  99269. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  99270. /** 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.) */
  99271. maxDepth?: number);
  99272. /**
  99273. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  99274. * @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);
  99275. * @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);
  99276. * @param entries meshes to be added to the octree blocks
  99277. */
  99278. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  99279. /**
  99280. * Adds a mesh to the octree
  99281. * @param entry Mesh to add to the octree
  99282. */
  99283. addMesh(entry: T): void;
  99284. /**
  99285. * Remove an element from the octree
  99286. * @param entry defines the element to remove
  99287. */
  99288. removeMesh(entry: T): void;
  99289. /**
  99290. * Selects an array of meshes within the frustum
  99291. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  99292. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  99293. * @returns array of meshes within the frustum
  99294. */
  99295. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  99296. /**
  99297. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  99298. * @param sphereCenter defines the bounding sphere center
  99299. * @param sphereRadius defines the bounding sphere radius
  99300. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99301. * @returns an array of objects that intersect the sphere
  99302. */
  99303. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  99304. /**
  99305. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  99306. * @param ray defines the ray to test with
  99307. * @returns array of intersected objects
  99308. */
  99309. intersectsRay(ray: Ray): SmartArray<T>;
  99310. /**
  99311. * Adds a mesh into the octree block if it intersects the block
  99312. */
  99313. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  99314. /**
  99315. * Adds a submesh into the octree block if it intersects the block
  99316. */
  99317. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  99318. }
  99319. }
  99320. declare module BABYLON {
  99321. interface Scene {
  99322. /**
  99323. * @hidden
  99324. * Backing Filed
  99325. */
  99326. _selectionOctree: Octree<AbstractMesh>;
  99327. /**
  99328. * Gets the octree used to boost mesh selection (picking)
  99329. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99330. */
  99331. selectionOctree: Octree<AbstractMesh>;
  99332. /**
  99333. * Creates or updates the octree used to boost selection (picking)
  99334. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99335. * @param maxCapacity defines the maximum capacity per leaf
  99336. * @param maxDepth defines the maximum depth of the octree
  99337. * @returns an octree of AbstractMesh
  99338. */
  99339. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  99340. }
  99341. interface AbstractMesh {
  99342. /**
  99343. * @hidden
  99344. * Backing Field
  99345. */
  99346. _submeshesOctree: Octree<SubMesh>;
  99347. /**
  99348. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  99349. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99350. * @param maxCapacity defines the maximum size of each block (64 by default)
  99351. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  99352. * @returns the new octree
  99353. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  99354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99355. */
  99356. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  99357. }
  99358. /**
  99359. * Defines the octree scene component responsible to manage any octrees
  99360. * in a given scene.
  99361. */
  99362. export class OctreeSceneComponent {
  99363. /**
  99364. * The component name helpfull to identify the component in the list of scene components.
  99365. */
  99366. readonly name: string;
  99367. /**
  99368. * The scene the component belongs to.
  99369. */
  99370. scene: Scene;
  99371. /**
  99372. * Indicates if the meshes have been checked to make sure they are isEnabled()
  99373. */
  99374. readonly checksIsEnabled: boolean;
  99375. /**
  99376. * Creates a new instance of the component for the given scene
  99377. * @param scene Defines the scene to register the component in
  99378. */
  99379. constructor(scene: Scene);
  99380. /**
  99381. * Registers the component in a given scene
  99382. */
  99383. register(): void;
  99384. /**
  99385. * Return the list of active meshes
  99386. * @returns the list of active meshes
  99387. */
  99388. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99389. /**
  99390. * Return the list of active sub meshes
  99391. * @param mesh The mesh to get the candidates sub meshes from
  99392. * @returns the list of active sub meshes
  99393. */
  99394. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99395. private _tempRay;
  99396. /**
  99397. * Return the list of sub meshes intersecting with a given local ray
  99398. * @param mesh defines the mesh to find the submesh for
  99399. * @param localRay defines the ray in local space
  99400. * @returns the list of intersecting sub meshes
  99401. */
  99402. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  99403. /**
  99404. * Return the list of sub meshes colliding with a collider
  99405. * @param mesh defines the mesh to find the submesh for
  99406. * @param collider defines the collider to evaluate the collision against
  99407. * @returns the list of colliding sub meshes
  99408. */
  99409. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  99410. /**
  99411. * Rebuilds the elements related to this component in case of
  99412. * context lost for instance.
  99413. */
  99414. rebuild(): void;
  99415. /**
  99416. * Disposes the component and the associated ressources.
  99417. */
  99418. dispose(): void;
  99419. }
  99420. }
  99421. declare module BABYLON {
  99422. /**
  99423. * Renders a layer on top of an existing scene
  99424. */
  99425. export class UtilityLayerRenderer implements IDisposable {
  99426. /** the original scene that will be rendered on top of */
  99427. originalScene: Scene;
  99428. private _pointerCaptures;
  99429. private _lastPointerEvents;
  99430. private static _DefaultUtilityLayer;
  99431. private static _DefaultKeepDepthUtilityLayer;
  99432. private _sharedGizmoLight;
  99433. /**
  99434. * @hidden
  99435. * Light which used by gizmos to get light shading
  99436. */
  99437. _getSharedGizmoLight(): HemisphericLight;
  99438. /**
  99439. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  99440. */
  99441. pickUtilitySceneFirst: boolean;
  99442. /**
  99443. * 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)
  99444. */
  99445. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  99446. /**
  99447. * 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)
  99448. */
  99449. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  99450. /**
  99451. * The scene that is rendered on top of the original scene
  99452. */
  99453. utilityLayerScene: Scene;
  99454. /**
  99455. * If the utility layer should automatically be rendered on top of existing scene
  99456. */
  99457. shouldRender: boolean;
  99458. /**
  99459. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  99460. */
  99461. onlyCheckPointerDownEvents: boolean;
  99462. /**
  99463. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  99464. */
  99465. processAllEvents: boolean;
  99466. /**
  99467. * Observable raised when the pointer move from the utility layer scene to the main scene
  99468. */
  99469. onPointerOutObservable: Observable<number>;
  99470. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  99471. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  99472. private _afterRenderObserver;
  99473. private _sceneDisposeObserver;
  99474. private _originalPointerObserver;
  99475. /**
  99476. * Instantiates a UtilityLayerRenderer
  99477. * @param originalScene the original scene that will be rendered on top of
  99478. * @param handleEvents boolean indicating if the utility layer should handle events
  99479. */
  99480. constructor(
  99481. /** the original scene that will be rendered on top of */
  99482. originalScene: Scene, handleEvents?: boolean);
  99483. private _notifyObservers;
  99484. /**
  99485. * Renders the utility layers scene on top of the original scene
  99486. */
  99487. render(): void;
  99488. /**
  99489. * Disposes of the renderer
  99490. */
  99491. dispose(): void;
  99492. private _updateCamera;
  99493. }
  99494. }
  99495. declare module BABYLON {
  99496. /**
  99497. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  99498. */
  99499. export class Gizmo implements IDisposable {
  99500. /** The utility layer the gizmo will be added to */
  99501. gizmoLayer: UtilityLayerRenderer;
  99502. /**
  99503. * The root mesh of the gizmo
  99504. */
  99505. _rootMesh: Mesh;
  99506. private _attachedMesh;
  99507. /**
  99508. * Ratio for the scale of the gizmo (Default: 1)
  99509. */
  99510. scaleRatio: number;
  99511. private _tmpMatrix;
  99512. /**
  99513. * If a custom mesh has been set (Default: false)
  99514. */
  99515. protected _customMeshSet: boolean;
  99516. /**
  99517. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  99518. * * When set, interactions will be enabled
  99519. */
  99520. attachedMesh: Nullable<AbstractMesh>;
  99521. /**
  99522. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99523. * @param mesh The mesh to replace the default mesh of the gizmo
  99524. */
  99525. setCustomMesh(mesh: Mesh): void;
  99526. /**
  99527. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  99528. */
  99529. updateGizmoRotationToMatchAttachedMesh: boolean;
  99530. /**
  99531. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  99532. */
  99533. updateGizmoPositionToMatchAttachedMesh: boolean;
  99534. /**
  99535. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  99536. */
  99537. protected _updateScale: boolean;
  99538. protected _interactionsEnabled: boolean;
  99539. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99540. private _beforeRenderObserver;
  99541. /**
  99542. * Creates a gizmo
  99543. * @param gizmoLayer The utility layer the gizmo will be added to
  99544. */
  99545. constructor(
  99546. /** The utility layer the gizmo will be added to */
  99547. gizmoLayer?: UtilityLayerRenderer);
  99548. private _tempVector;
  99549. /**
  99550. * @hidden
  99551. * Updates the gizmo to match the attached mesh's position/rotation
  99552. */
  99553. protected _update(): void;
  99554. /**
  99555. * Disposes of the gizmo
  99556. */
  99557. dispose(): void;
  99558. }
  99559. }
  99560. declare module BABYLON {
  99561. /**
  99562. * Single axis drag gizmo
  99563. */
  99564. export class AxisDragGizmo extends Gizmo {
  99565. /**
  99566. * Drag behavior responsible for the gizmos dragging interactions
  99567. */
  99568. dragBehavior: PointerDragBehavior;
  99569. private _pointerObserver;
  99570. /**
  99571. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99572. */
  99573. snapDistance: number;
  99574. /**
  99575. * Event that fires each time the gizmo snaps to a new location.
  99576. * * snapDistance is the the change in distance
  99577. */
  99578. onSnapObservable: Observable<{
  99579. snapDistance: number;
  99580. }>;
  99581. /** @hidden */
  99582. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  99583. /** @hidden */
  99584. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  99585. /**
  99586. * Creates an AxisDragGizmo
  99587. * @param gizmoLayer The utility layer the gizmo will be added to
  99588. * @param dragAxis The axis which the gizmo will be able to drag on
  99589. * @param color The color of the gizmo
  99590. */
  99591. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99592. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99593. /**
  99594. * Disposes of the gizmo
  99595. */
  99596. dispose(): void;
  99597. }
  99598. }
  99599. declare module BABYLON.Debug {
  99600. /**
  99601. * The Axes viewer will show 3 axes in a specific point in space
  99602. */
  99603. export class AxesViewer {
  99604. private _xAxis;
  99605. private _yAxis;
  99606. private _zAxis;
  99607. private _scaleLinesFactor;
  99608. private _instanced;
  99609. /**
  99610. * Gets the hosting scene
  99611. */
  99612. scene: Scene;
  99613. /**
  99614. * Gets or sets a number used to scale line length
  99615. */
  99616. scaleLines: number;
  99617. /** Gets the node hierarchy used to render x-axis */
  99618. readonly xAxis: TransformNode;
  99619. /** Gets the node hierarchy used to render y-axis */
  99620. readonly yAxis: TransformNode;
  99621. /** Gets the node hierarchy used to render z-axis */
  99622. readonly zAxis: TransformNode;
  99623. /**
  99624. * Creates a new AxesViewer
  99625. * @param scene defines the hosting scene
  99626. * @param scaleLines defines a number used to scale line length (1 by default)
  99627. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  99628. * @param xAxis defines the node hierarchy used to render the x-axis
  99629. * @param yAxis defines the node hierarchy used to render the y-axis
  99630. * @param zAxis defines the node hierarchy used to render the z-axis
  99631. */
  99632. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  99633. /**
  99634. * Force the viewer to update
  99635. * @param position defines the position of the viewer
  99636. * @param xaxis defines the x axis of the viewer
  99637. * @param yaxis defines the y axis of the viewer
  99638. * @param zaxis defines the z axis of the viewer
  99639. */
  99640. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  99641. /**
  99642. * Creates an instance of this axes viewer.
  99643. * @returns a new axes viewer with instanced meshes
  99644. */
  99645. createInstance(): AxesViewer;
  99646. /** Releases resources */
  99647. dispose(): void;
  99648. private static _SetRenderingGroupId;
  99649. }
  99650. }
  99651. declare module BABYLON.Debug {
  99652. /**
  99653. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  99654. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  99655. */
  99656. export class BoneAxesViewer extends AxesViewer {
  99657. /**
  99658. * Gets or sets the target mesh where to display the axes viewer
  99659. */
  99660. mesh: Nullable<Mesh>;
  99661. /**
  99662. * Gets or sets the target bone where to display the axes viewer
  99663. */
  99664. bone: Nullable<Bone>;
  99665. /** Gets current position */
  99666. pos: Vector3;
  99667. /** Gets direction of X axis */
  99668. xaxis: Vector3;
  99669. /** Gets direction of Y axis */
  99670. yaxis: Vector3;
  99671. /** Gets direction of Z axis */
  99672. zaxis: Vector3;
  99673. /**
  99674. * Creates a new BoneAxesViewer
  99675. * @param scene defines the hosting scene
  99676. * @param bone defines the target bone
  99677. * @param mesh defines the target mesh
  99678. * @param scaleLines defines a scaling factor for line length (1 by default)
  99679. */
  99680. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  99681. /**
  99682. * Force the viewer to update
  99683. */
  99684. update(): void;
  99685. /** Releases resources */
  99686. dispose(): void;
  99687. }
  99688. }
  99689. declare module BABYLON {
  99690. /**
  99691. * Interface used to define scene explorer extensibility option
  99692. */
  99693. export interface IExplorerExtensibilityOption {
  99694. /**
  99695. * Define the option label
  99696. */
  99697. label: string;
  99698. /**
  99699. * Defines the action to execute on click
  99700. */
  99701. action: (entity: any) => void;
  99702. }
  99703. /**
  99704. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  99705. */
  99706. export interface IExplorerExtensibilityGroup {
  99707. /**
  99708. * Defines a predicate to test if a given type mut be extended
  99709. */
  99710. predicate: (entity: any) => boolean;
  99711. /**
  99712. * Gets the list of options added to a type
  99713. */
  99714. entries: IExplorerExtensibilityOption[];
  99715. }
  99716. /**
  99717. * Interface used to define the options to use to create the Inspector
  99718. */
  99719. export interface IInspectorOptions {
  99720. /**
  99721. * Display in overlay mode (default: false)
  99722. */
  99723. overlay?: boolean;
  99724. /**
  99725. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  99726. */
  99727. globalRoot?: HTMLElement;
  99728. /**
  99729. * Display the Scene explorer
  99730. */
  99731. showExplorer?: boolean;
  99732. /**
  99733. * Display the property inspector
  99734. */
  99735. showInspector?: boolean;
  99736. /**
  99737. * Display in embed mode (both panes on the right)
  99738. */
  99739. embedMode?: boolean;
  99740. /**
  99741. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  99742. */
  99743. handleResize?: boolean;
  99744. /**
  99745. * Allow the panes to popup (default: true)
  99746. */
  99747. enablePopup?: boolean;
  99748. /**
  99749. * Allow the panes to be closed by users (default: true)
  99750. */
  99751. enableClose?: boolean;
  99752. /**
  99753. * Optional list of extensibility entries
  99754. */
  99755. explorerExtensibility?: IExplorerExtensibilityGroup[];
  99756. /**
  99757. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  99758. */
  99759. inspectorURL?: string;
  99760. }
  99761. interface Scene {
  99762. /**
  99763. * @hidden
  99764. * Backing field
  99765. */
  99766. _debugLayer: DebugLayer;
  99767. /**
  99768. * Gets the debug layer (aka Inspector) associated with the scene
  99769. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99770. */
  99771. debugLayer: DebugLayer;
  99772. }
  99773. /**
  99774. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99775. * what is happening in your scene
  99776. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99777. */
  99778. export class DebugLayer {
  99779. /**
  99780. * Define the url to get the inspector script from.
  99781. * By default it uses the babylonjs CDN.
  99782. * @ignoreNaming
  99783. */
  99784. static InspectorURL: string;
  99785. private _scene;
  99786. private BJSINSPECTOR;
  99787. /**
  99788. * Observable triggered when a property is changed through the inspector.
  99789. */
  99790. onPropertyChangedObservable: Observable<{
  99791. object: any;
  99792. property: string;
  99793. value: any;
  99794. initialValue: any;
  99795. }>;
  99796. /**
  99797. * Instantiates a new debug layer.
  99798. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99799. * what is happening in your scene
  99800. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99801. * @param scene Defines the scene to inspect
  99802. */
  99803. constructor(scene: Scene);
  99804. /** Creates the inspector window. */
  99805. private _createInspector;
  99806. /**
  99807. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  99808. * @param entity defines the entity to select
  99809. * @param lineContainerTitle defines the specific block to highlight
  99810. */
  99811. select(entity: any, lineContainerTitle?: string): void;
  99812. /** Get the inspector from bundle or global */
  99813. private _getGlobalInspector;
  99814. /**
  99815. * Get if the inspector is visible or not.
  99816. * @returns true if visible otherwise, false
  99817. */
  99818. isVisible(): boolean;
  99819. /**
  99820. * Hide the inspector and close its window.
  99821. */
  99822. hide(): void;
  99823. /**
  99824. * Launch the debugLayer.
  99825. * @param config Define the configuration of the inspector
  99826. * @return a promise fulfilled when the debug layer is visible
  99827. */
  99828. show(config?: IInspectorOptions): Promise<DebugLayer>;
  99829. }
  99830. }
  99831. declare module BABYLON {
  99832. /**
  99833. * Class containing static functions to help procedurally build meshes
  99834. */
  99835. export class BoxBuilder {
  99836. /**
  99837. * Creates a box mesh
  99838. * * The parameter `size` sets the size (float) of each box side (default 1)
  99839. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  99840. * * 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)
  99841. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  99842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99845. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  99846. * @param name defines the name of the mesh
  99847. * @param options defines the options used to create the mesh
  99848. * @param scene defines the hosting scene
  99849. * @returns the box mesh
  99850. */
  99851. static CreateBox(name: string, options: {
  99852. size?: number;
  99853. width?: number;
  99854. height?: number;
  99855. depth?: number;
  99856. faceUV?: Vector4[];
  99857. faceColors?: Color4[];
  99858. sideOrientation?: number;
  99859. frontUVs?: Vector4;
  99860. backUVs?: Vector4;
  99861. updatable?: boolean;
  99862. }, scene?: Nullable<Scene>): Mesh;
  99863. }
  99864. }
  99865. declare module BABYLON {
  99866. /**
  99867. * Class containing static functions to help procedurally build meshes
  99868. */
  99869. export class SphereBuilder {
  99870. /**
  99871. * Creates a sphere mesh
  99872. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  99873. * * 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`)
  99874. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  99875. * * 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
  99876. * * 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)
  99877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99880. * @param name defines the name of the mesh
  99881. * @param options defines the options used to create the mesh
  99882. * @param scene defines the hosting scene
  99883. * @returns the sphere mesh
  99884. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  99885. */
  99886. static CreateSphere(name: string, options: {
  99887. segments?: number;
  99888. diameter?: number;
  99889. diameterX?: number;
  99890. diameterY?: number;
  99891. diameterZ?: number;
  99892. arc?: number;
  99893. slice?: number;
  99894. sideOrientation?: number;
  99895. frontUVs?: Vector4;
  99896. backUVs?: Vector4;
  99897. updatable?: boolean;
  99898. }, scene: any): Mesh;
  99899. }
  99900. }
  99901. declare module BABYLON.Debug {
  99902. /**
  99903. * Used to show the physics impostor around the specific mesh
  99904. */
  99905. export class PhysicsViewer {
  99906. /** @hidden */
  99907. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  99908. /** @hidden */
  99909. protected _meshes: Array<Nullable<AbstractMesh>>;
  99910. /** @hidden */
  99911. protected _scene: Nullable<Scene>;
  99912. /** @hidden */
  99913. protected _numMeshes: number;
  99914. /** @hidden */
  99915. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  99916. private _renderFunction;
  99917. private _utilityLayer;
  99918. private _debugBoxMesh;
  99919. private _debugSphereMesh;
  99920. private _debugMaterial;
  99921. private _debugMeshMeshes;
  99922. /**
  99923. * Creates a new PhysicsViewer
  99924. * @param scene defines the hosting scene
  99925. */
  99926. constructor(scene: Scene);
  99927. /** @hidden */
  99928. protected _updateDebugMeshes(): void;
  99929. /**
  99930. * Renders a specified physic impostor
  99931. * @param impostor defines the impostor to render
  99932. * @param targetMesh defines the mesh represented by the impostor
  99933. * @returns the new debug mesh used to render the impostor
  99934. */
  99935. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  99936. /**
  99937. * Hides a specified physic impostor
  99938. * @param impostor defines the impostor to hide
  99939. */
  99940. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  99941. private _getDebugMaterial;
  99942. private _getDebugBoxMesh;
  99943. private _getDebugSphereMesh;
  99944. private _getDebugMeshMesh;
  99945. private _getDebugMesh;
  99946. /** Releases all resources */
  99947. dispose(): void;
  99948. }
  99949. }
  99950. declare module BABYLON {
  99951. /**
  99952. * Class containing static functions to help procedurally build meshes
  99953. */
  99954. export class LinesBuilder {
  99955. /**
  99956. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  99957. * * 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
  99958. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  99959. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  99960. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  99961. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  99962. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  99963. * * 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
  99964. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  99965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99966. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  99967. * @param name defines the name of the new line system
  99968. * @param options defines the options used to create the line system
  99969. * @param scene defines the hosting scene
  99970. * @returns a new line system mesh
  99971. */
  99972. static CreateLineSystem(name: string, options: {
  99973. lines: Vector3[][];
  99974. updatable?: boolean;
  99975. instance?: Nullable<LinesMesh>;
  99976. colors?: Nullable<Color4[][]>;
  99977. useVertexAlpha?: boolean;
  99978. }, scene: Nullable<Scene>): LinesMesh;
  99979. /**
  99980. * Creates a line mesh
  99981. * 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
  99982. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  99983. * * The parameter `points` is an array successive Vector3
  99984. * * 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
  99985. * * The optional parameter `colors` is an array of successive Color4, one per line point
  99986. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  99987. * * When updating an instance, remember that only point positions can change, not the number of points
  99988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99989. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  99990. * @param name defines the name of the new line system
  99991. * @param options defines the options used to create the line system
  99992. * @param scene defines the hosting scene
  99993. * @returns a new line mesh
  99994. */
  99995. static CreateLines(name: string, options: {
  99996. points: Vector3[];
  99997. updatable?: boolean;
  99998. instance?: Nullable<LinesMesh>;
  99999. colors?: Color4[];
  100000. useVertexAlpha?: boolean;
  100001. }, scene?: Nullable<Scene>): LinesMesh;
  100002. /**
  100003. * Creates a dashed line mesh
  100004. * * 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
  100005. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100006. * * The parameter `points` is an array successive Vector3
  100007. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  100008. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  100009. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100010. * * 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
  100011. * * When updating an instance, remember that only point positions can change, not the number of points
  100012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100013. * @param name defines the name of the mesh
  100014. * @param options defines the options used to create the mesh
  100015. * @param scene defines the hosting scene
  100016. * @returns the dashed line mesh
  100017. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  100018. */
  100019. static CreateDashedLines(name: string, options: {
  100020. points: Vector3[];
  100021. dashSize?: number;
  100022. gapSize?: number;
  100023. dashNb?: number;
  100024. updatable?: boolean;
  100025. instance?: LinesMesh;
  100026. }, scene?: Nullable<Scene>): LinesMesh;
  100027. }
  100028. }
  100029. declare module BABYLON {
  100030. /**
  100031. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100032. * in order to better appreciate the issue one might have.
  100033. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100034. */
  100035. export class RayHelper {
  100036. /**
  100037. * Defines the ray we are currently tryin to visualize.
  100038. */
  100039. ray: Nullable<Ray>;
  100040. private _renderPoints;
  100041. private _renderLine;
  100042. private _renderFunction;
  100043. private _scene;
  100044. private _updateToMeshFunction;
  100045. private _attachedToMesh;
  100046. private _meshSpaceDirection;
  100047. private _meshSpaceOrigin;
  100048. /**
  100049. * Helper function to create a colored helper in a scene in one line.
  100050. * @param ray Defines the ray we are currently tryin to visualize
  100051. * @param scene Defines the scene the ray is used in
  100052. * @param color Defines the color we want to see the ray in
  100053. * @returns The newly created ray helper.
  100054. */
  100055. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  100056. /**
  100057. * Instantiate a new ray helper.
  100058. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100059. * in order to better appreciate the issue one might have.
  100060. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100061. * @param ray Defines the ray we are currently tryin to visualize
  100062. */
  100063. constructor(ray: Ray);
  100064. /**
  100065. * Shows the ray we are willing to debug.
  100066. * @param scene Defines the scene the ray needs to be rendered in
  100067. * @param color Defines the color the ray needs to be rendered in
  100068. */
  100069. show(scene: Scene, color?: Color3): void;
  100070. /**
  100071. * Hides the ray we are debugging.
  100072. */
  100073. hide(): void;
  100074. private _render;
  100075. /**
  100076. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  100077. * @param mesh Defines the mesh we want the helper attached to
  100078. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  100079. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  100080. * @param length Defines the length of the ray
  100081. */
  100082. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  100083. /**
  100084. * Detach the ray helper from the mesh it has previously been attached to.
  100085. */
  100086. detachFromMesh(): void;
  100087. private _updateToMesh;
  100088. /**
  100089. * Dispose the helper and release its associated resources.
  100090. */
  100091. dispose(): void;
  100092. }
  100093. }
  100094. declare module BABYLON.Debug {
  100095. /**
  100096. * Class used to render a debug view of a given skeleton
  100097. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  100098. */
  100099. export class SkeletonViewer {
  100100. /** defines the skeleton to render */
  100101. skeleton: Skeleton;
  100102. /** defines the mesh attached to the skeleton */
  100103. mesh: AbstractMesh;
  100104. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100105. autoUpdateBonesMatrices: boolean;
  100106. /** defines the rendering group id to use with the viewer */
  100107. renderingGroupId: number;
  100108. /** Gets or sets the color used to render the skeleton */
  100109. color: Color3;
  100110. private _scene;
  100111. private _debugLines;
  100112. private _debugMesh;
  100113. private _isEnabled;
  100114. private _renderFunction;
  100115. private _utilityLayer;
  100116. /**
  100117. * Returns the mesh used to render the bones
  100118. */
  100119. readonly debugMesh: Nullable<LinesMesh>;
  100120. /**
  100121. * Creates a new SkeletonViewer
  100122. * @param skeleton defines the skeleton to render
  100123. * @param mesh defines the mesh attached to the skeleton
  100124. * @param scene defines the hosting scene
  100125. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  100126. * @param renderingGroupId defines the rendering group id to use with the viewer
  100127. */
  100128. constructor(
  100129. /** defines the skeleton to render */
  100130. skeleton: Skeleton,
  100131. /** defines the mesh attached to the skeleton */
  100132. mesh: AbstractMesh, scene: Scene,
  100133. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100134. autoUpdateBonesMatrices?: boolean,
  100135. /** defines the rendering group id to use with the viewer */
  100136. renderingGroupId?: number);
  100137. /** Gets or sets a boolean indicating if the viewer is enabled */
  100138. isEnabled: boolean;
  100139. private _getBonePosition;
  100140. private _getLinesForBonesWithLength;
  100141. private _getLinesForBonesNoLength;
  100142. /** Update the viewer to sync with current skeleton state */
  100143. update(): void;
  100144. /** Release associated resources */
  100145. dispose(): void;
  100146. }
  100147. }
  100148. declare module BABYLON {
  100149. /**
  100150. * Options to create the null engine
  100151. */
  100152. export class NullEngineOptions {
  100153. /**
  100154. * Render width (Default: 512)
  100155. */
  100156. renderWidth: number;
  100157. /**
  100158. * Render height (Default: 256)
  100159. */
  100160. renderHeight: number;
  100161. /**
  100162. * Texture size (Default: 512)
  100163. */
  100164. textureSize: number;
  100165. /**
  100166. * If delta time between frames should be constant
  100167. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100168. */
  100169. deterministicLockstep: boolean;
  100170. /**
  100171. * Maximum about of steps between frames (Default: 4)
  100172. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100173. */
  100174. lockstepMaxSteps: number;
  100175. }
  100176. /**
  100177. * The null engine class provides support for headless version of babylon.js.
  100178. * This can be used in server side scenario or for testing purposes
  100179. */
  100180. export class NullEngine extends Engine {
  100181. private _options;
  100182. /**
  100183. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100184. */
  100185. isDeterministicLockStep(): boolean;
  100186. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  100187. getLockstepMaxSteps(): number;
  100188. /**
  100189. * Sets hardware scaling, used to save performance if needed
  100190. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100191. */
  100192. getHardwareScalingLevel(): number;
  100193. constructor(options?: NullEngineOptions);
  100194. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100195. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  100196. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100197. getRenderWidth(useScreen?: boolean): number;
  100198. getRenderHeight(useScreen?: boolean): number;
  100199. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  100200. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  100201. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  100202. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  100203. bindSamplers(effect: Effect): void;
  100204. enableEffect(effect: Effect): void;
  100205. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100206. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  100207. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  100208. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  100209. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  100210. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  100211. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  100212. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  100213. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  100214. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  100215. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  100216. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  100217. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  100218. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  100219. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  100220. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100221. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100222. setFloat(uniform: WebGLUniformLocation, value: number): void;
  100223. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  100224. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  100225. setBool(uniform: WebGLUniformLocation, bool: number): void;
  100226. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  100227. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  100228. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  100229. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100230. bindBuffers(vertexBuffers: {
  100231. [key: string]: VertexBuffer;
  100232. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  100233. wipeCaches(bruteForce?: boolean): void;
  100234. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100235. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100236. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100237. /** @hidden */
  100238. _createTexture(): WebGLTexture;
  100239. /** @hidden */
  100240. _releaseTexture(texture: InternalTexture): void;
  100241. 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;
  100242. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  100243. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100244. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  100245. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100246. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100247. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  100248. areAllEffectsReady(): boolean;
  100249. /**
  100250. * @hidden
  100251. * Get the current error code of the webGL context
  100252. * @returns the error code
  100253. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100254. */
  100255. getError(): number;
  100256. /** @hidden */
  100257. _getUnpackAlignement(): number;
  100258. /** @hidden */
  100259. _unpackFlipY(value: boolean): void;
  100260. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  100261. /**
  100262. * Updates a dynamic vertex buffer.
  100263. * @param vertexBuffer the vertex buffer to update
  100264. * @param data the data used to update the vertex buffer
  100265. * @param byteOffset the byte offset of the data (optional)
  100266. * @param byteLength the byte length of the data (optional)
  100267. */
  100268. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  100269. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  100270. /** @hidden */
  100271. _bindTexture(channel: number, texture: InternalTexture): void;
  100272. /** @hidden */
  100273. _releaseBuffer(buffer: WebGLBuffer): boolean;
  100274. releaseEffects(): void;
  100275. displayLoadingUI(): void;
  100276. hideLoadingUI(): void;
  100277. /** @hidden */
  100278. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100279. /** @hidden */
  100280. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100281. /** @hidden */
  100282. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100283. /** @hidden */
  100284. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  100285. }
  100286. }
  100287. declare module BABYLON {
  100288. /** @hidden */
  100289. export class _OcclusionDataStorage {
  100290. /** @hidden */
  100291. occlusionInternalRetryCounter: number;
  100292. /** @hidden */
  100293. isOcclusionQueryInProgress: boolean;
  100294. /** @hidden */
  100295. isOccluded: boolean;
  100296. /** @hidden */
  100297. occlusionRetryCount: number;
  100298. /** @hidden */
  100299. occlusionType: number;
  100300. /** @hidden */
  100301. occlusionQueryAlgorithmType: number;
  100302. }
  100303. interface Engine {
  100304. /**
  100305. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  100306. * @return the new query
  100307. */
  100308. createQuery(): WebGLQuery;
  100309. /**
  100310. * Delete and release a webGL query
  100311. * @param query defines the query to delete
  100312. * @return the current engine
  100313. */
  100314. deleteQuery(query: WebGLQuery): Engine;
  100315. /**
  100316. * Check if a given query has resolved and got its value
  100317. * @param query defines the query to check
  100318. * @returns true if the query got its value
  100319. */
  100320. isQueryResultAvailable(query: WebGLQuery): boolean;
  100321. /**
  100322. * Gets the value of a given query
  100323. * @param query defines the query to check
  100324. * @returns the value of the query
  100325. */
  100326. getQueryResult(query: WebGLQuery): number;
  100327. /**
  100328. * Initiates an occlusion query
  100329. * @param algorithmType defines the algorithm to use
  100330. * @param query defines the query to use
  100331. * @returns the current engine
  100332. * @see http://doc.babylonjs.com/features/occlusionquery
  100333. */
  100334. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  100335. /**
  100336. * Ends an occlusion query
  100337. * @see http://doc.babylonjs.com/features/occlusionquery
  100338. * @param algorithmType defines the algorithm to use
  100339. * @returns the current engine
  100340. */
  100341. endOcclusionQuery(algorithmType: number): Engine;
  100342. /**
  100343. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  100344. * Please note that only one query can be issued at a time
  100345. * @returns a time token used to track the time span
  100346. */
  100347. startTimeQuery(): Nullable<_TimeToken>;
  100348. /**
  100349. * Ends a time query
  100350. * @param token defines the token used to measure the time span
  100351. * @returns the time spent (in ns)
  100352. */
  100353. endTimeQuery(token: _TimeToken): int;
  100354. /** @hidden */
  100355. _currentNonTimestampToken: Nullable<_TimeToken>;
  100356. /** @hidden */
  100357. _createTimeQuery(): WebGLQuery;
  100358. /** @hidden */
  100359. _deleteTimeQuery(query: WebGLQuery): void;
  100360. /** @hidden */
  100361. _getGlAlgorithmType(algorithmType: number): number;
  100362. /** @hidden */
  100363. _getTimeQueryResult(query: WebGLQuery): any;
  100364. /** @hidden */
  100365. _getTimeQueryAvailability(query: WebGLQuery): any;
  100366. }
  100367. interface AbstractMesh {
  100368. /**
  100369. * Backing filed
  100370. * @hidden
  100371. */
  100372. __occlusionDataStorage: _OcclusionDataStorage;
  100373. /**
  100374. * Access property
  100375. * @hidden
  100376. */
  100377. _occlusionDataStorage: _OcclusionDataStorage;
  100378. /**
  100379. * 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.
  100380. * The default value is -1 which means don't break the query and wait till the result
  100381. * @see http://doc.babylonjs.com/features/occlusionquery
  100382. */
  100383. occlusionRetryCount: number;
  100384. /**
  100385. * 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:
  100386. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  100387. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  100388. * * 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.
  100389. * @see http://doc.babylonjs.com/features/occlusionquery
  100390. */
  100391. occlusionType: number;
  100392. /**
  100393. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  100394. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  100395. * * 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.
  100396. * @see http://doc.babylonjs.com/features/occlusionquery
  100397. */
  100398. occlusionQueryAlgorithmType: number;
  100399. /**
  100400. * 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
  100401. * @see http://doc.babylonjs.com/features/occlusionquery
  100402. */
  100403. isOccluded: boolean;
  100404. /**
  100405. * Flag to check the progress status of the query
  100406. * @see http://doc.babylonjs.com/features/occlusionquery
  100407. */
  100408. isOcclusionQueryInProgress: boolean;
  100409. }
  100410. }
  100411. declare module BABYLON {
  100412. /** @hidden */
  100413. export var _forceTransformFeedbackToBundle: boolean;
  100414. interface Engine {
  100415. /**
  100416. * Creates a webGL transform feedback object
  100417. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  100418. * @returns the webGL transform feedback object
  100419. */
  100420. createTransformFeedback(): WebGLTransformFeedback;
  100421. /**
  100422. * Delete a webGL transform feedback object
  100423. * @param value defines the webGL transform feedback object to delete
  100424. */
  100425. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  100426. /**
  100427. * Bind a webGL transform feedback object to the webgl context
  100428. * @param value defines the webGL transform feedback object to bind
  100429. */
  100430. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  100431. /**
  100432. * Begins a transform feedback operation
  100433. * @param usePoints defines if points or triangles must be used
  100434. */
  100435. beginTransformFeedback(usePoints: boolean): void;
  100436. /**
  100437. * Ends a transform feedback operation
  100438. */
  100439. endTransformFeedback(): void;
  100440. /**
  100441. * Specify the varyings to use with transform feedback
  100442. * @param program defines the associated webGL program
  100443. * @param value defines the list of strings representing the varying names
  100444. */
  100445. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  100446. /**
  100447. * Bind a webGL buffer for a transform feedback operation
  100448. * @param value defines the webGL buffer to bind
  100449. */
  100450. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  100451. }
  100452. }
  100453. declare module BABYLON {
  100454. /**
  100455. * Gather the list of clipboard event types as constants.
  100456. */
  100457. export class ClipboardEventTypes {
  100458. /**
  100459. * The clipboard event is fired when a copy command is active (pressed).
  100460. */
  100461. static readonly COPY: number;
  100462. /**
  100463. * The clipboard event is fired when a cut command is active (pressed).
  100464. */
  100465. static readonly CUT: number;
  100466. /**
  100467. * The clipboard event is fired when a paste command is active (pressed).
  100468. */
  100469. static readonly PASTE: number;
  100470. }
  100471. /**
  100472. * This class is used to store clipboard related info for the onClipboardObservable event.
  100473. */
  100474. export class ClipboardInfo {
  100475. /**
  100476. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100477. */
  100478. type: number;
  100479. /**
  100480. * Defines the related dom event
  100481. */
  100482. event: ClipboardEvent;
  100483. /**
  100484. *Creates an instance of ClipboardInfo.
  100485. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  100486. * @param event Defines the related dom event
  100487. */
  100488. constructor(
  100489. /**
  100490. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100491. */
  100492. type: number,
  100493. /**
  100494. * Defines the related dom event
  100495. */
  100496. event: ClipboardEvent);
  100497. /**
  100498. * Get the clipboard event's type from the keycode.
  100499. * @param keyCode Defines the keyCode for the current keyboard event.
  100500. * @return {number}
  100501. */
  100502. static GetTypeFromCharacter(keyCode: number): number;
  100503. }
  100504. }
  100505. declare module BABYLON {
  100506. /**
  100507. * Class used to represent data loading progression
  100508. */
  100509. export class SceneLoaderProgressEvent {
  100510. /** defines if data length to load can be evaluated */
  100511. readonly lengthComputable: boolean;
  100512. /** defines the loaded data length */
  100513. readonly loaded: number;
  100514. /** defines the data length to load */
  100515. readonly total: number;
  100516. /**
  100517. * Create a new progress event
  100518. * @param lengthComputable defines if data length to load can be evaluated
  100519. * @param loaded defines the loaded data length
  100520. * @param total defines the data length to load
  100521. */
  100522. constructor(
  100523. /** defines if data length to load can be evaluated */
  100524. lengthComputable: boolean,
  100525. /** defines the loaded data length */
  100526. loaded: number,
  100527. /** defines the data length to load */
  100528. total: number);
  100529. /**
  100530. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  100531. * @param event defines the source event
  100532. * @returns a new SceneLoaderProgressEvent
  100533. */
  100534. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  100535. }
  100536. /**
  100537. * Interface used by SceneLoader plugins to define supported file extensions
  100538. */
  100539. export interface ISceneLoaderPluginExtensions {
  100540. /**
  100541. * Defines the list of supported extensions
  100542. */
  100543. [extension: string]: {
  100544. isBinary: boolean;
  100545. };
  100546. }
  100547. /**
  100548. * Interface used by SceneLoader plugin factory
  100549. */
  100550. export interface ISceneLoaderPluginFactory {
  100551. /**
  100552. * Defines the name of the factory
  100553. */
  100554. name: string;
  100555. /**
  100556. * Function called to create a new plugin
  100557. * @return the new plugin
  100558. */
  100559. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  100560. /**
  100561. * Boolean indicating if the plugin can direct load specific data
  100562. */
  100563. canDirectLoad?: (data: string) => boolean;
  100564. }
  100565. /**
  100566. * Interface used to define a SceneLoader plugin
  100567. */
  100568. export interface ISceneLoaderPlugin {
  100569. /**
  100570. * The friendly name of this plugin.
  100571. */
  100572. name: string;
  100573. /**
  100574. * The file extensions supported by this plugin.
  100575. */
  100576. extensions: string | ISceneLoaderPluginExtensions;
  100577. /**
  100578. * Import meshes into a scene.
  100579. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100580. * @param scene The scene to import into
  100581. * @param data The data to import
  100582. * @param rootUrl The root url for scene and resources
  100583. * @param meshes The meshes array to import into
  100584. * @param particleSystems The particle systems array to import into
  100585. * @param skeletons The skeletons array to import into
  100586. * @param onError The callback when import fails
  100587. * @returns True if successful or false otherwise
  100588. */
  100589. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  100590. /**
  100591. * Load into a scene.
  100592. * @param scene The scene to load into
  100593. * @param data The data to import
  100594. * @param rootUrl The root url for scene and resources
  100595. * @param onError The callback when import fails
  100596. * @returns true if successful or false otherwise
  100597. */
  100598. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  100599. /**
  100600. * The callback that returns true if the data can be directly loaded.
  100601. */
  100602. canDirectLoad?: (data: string) => boolean;
  100603. /**
  100604. * The callback that allows custom handling of the root url based on the response url.
  100605. */
  100606. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100607. /**
  100608. * Load into an asset container.
  100609. * @param scene The scene to load into
  100610. * @param data The data to import
  100611. * @param rootUrl The root url for scene and resources
  100612. * @param onError The callback when import fails
  100613. * @returns The loaded asset container
  100614. */
  100615. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  100616. }
  100617. /**
  100618. * Interface used to define an async SceneLoader plugin
  100619. */
  100620. export interface ISceneLoaderPluginAsync {
  100621. /**
  100622. * The friendly name of this plugin.
  100623. */
  100624. name: string;
  100625. /**
  100626. * The file extensions supported by this plugin.
  100627. */
  100628. extensions: string | ISceneLoaderPluginExtensions;
  100629. /**
  100630. * Import meshes into a scene.
  100631. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100632. * @param scene The scene to import into
  100633. * @param data The data to import
  100634. * @param rootUrl The root url for scene and resources
  100635. * @param onProgress The callback when the load progresses
  100636. * @param fileName Defines the name of the file to load
  100637. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  100638. */
  100639. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  100640. meshes: AbstractMesh[];
  100641. particleSystems: IParticleSystem[];
  100642. skeletons: Skeleton[];
  100643. animationGroups: AnimationGroup[];
  100644. }>;
  100645. /**
  100646. * Load into a scene.
  100647. * @param scene The scene to load into
  100648. * @param data The data to import
  100649. * @param rootUrl The root url for scene and resources
  100650. * @param onProgress The callback when the load progresses
  100651. * @param fileName Defines the name of the file to load
  100652. * @returns Nothing
  100653. */
  100654. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  100655. /**
  100656. * The callback that returns true if the data can be directly loaded.
  100657. */
  100658. canDirectLoad?: (data: string) => boolean;
  100659. /**
  100660. * The callback that allows custom handling of the root url based on the response url.
  100661. */
  100662. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100663. /**
  100664. * Load into an asset container.
  100665. * @param scene The scene to load into
  100666. * @param data The data to import
  100667. * @param rootUrl The root url for scene and resources
  100668. * @param onProgress The callback when the load progresses
  100669. * @param fileName Defines the name of the file to load
  100670. * @returns The loaded asset container
  100671. */
  100672. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  100673. }
  100674. /**
  100675. * Class used to load scene from various file formats using registered plugins
  100676. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  100677. */
  100678. export class SceneLoader {
  100679. /**
  100680. * No logging while loading
  100681. */
  100682. static readonly NO_LOGGING: number;
  100683. /**
  100684. * Minimal logging while loading
  100685. */
  100686. static readonly MINIMAL_LOGGING: number;
  100687. /**
  100688. * Summary logging while loading
  100689. */
  100690. static readonly SUMMARY_LOGGING: number;
  100691. /**
  100692. * Detailled logging while loading
  100693. */
  100694. static readonly DETAILED_LOGGING: number;
  100695. /**
  100696. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  100697. */
  100698. static ForceFullSceneLoadingForIncremental: boolean;
  100699. /**
  100700. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  100701. */
  100702. static ShowLoadingScreen: boolean;
  100703. /**
  100704. * Defines the current logging level (while loading the scene)
  100705. * @ignorenaming
  100706. */
  100707. static loggingLevel: number;
  100708. /**
  100709. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  100710. */
  100711. static CleanBoneMatrixWeights: boolean;
  100712. /**
  100713. * Event raised when a plugin is used to load a scene
  100714. */
  100715. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  100716. private static _registeredPlugins;
  100717. private static _getDefaultPlugin;
  100718. private static _getPluginForExtension;
  100719. private static _getPluginForDirectLoad;
  100720. private static _getPluginForFilename;
  100721. private static _getDirectLoad;
  100722. private static _loadData;
  100723. private static _getFileInfo;
  100724. /**
  100725. * Gets a plugin that can load the given extension
  100726. * @param extension defines the extension to load
  100727. * @returns a plugin or null if none works
  100728. */
  100729. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  100730. /**
  100731. * Gets a boolean indicating that the given extension can be loaded
  100732. * @param extension defines the extension to load
  100733. * @returns true if the extension is supported
  100734. */
  100735. static IsPluginForExtensionAvailable(extension: string): boolean;
  100736. /**
  100737. * Adds a new plugin to the list of registered plugins
  100738. * @param plugin defines the plugin to add
  100739. */
  100740. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  100741. /**
  100742. * Import meshes into a scene
  100743. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100744. * @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)
  100745. * @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)
  100746. * @param scene the instance of BABYLON.Scene to append to
  100747. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  100748. * @param onProgress a callback with a progress event for each file being loaded
  100749. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100750. * @param pluginExtension the extension used to determine the plugin
  100751. * @returns The loaded plugin
  100752. */
  100753. 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>;
  100754. /**
  100755. * Import meshes into a scene
  100756. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100757. * @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)
  100758. * @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)
  100759. * @param scene the instance of BABYLON.Scene to append to
  100760. * @param onProgress a callback with a progress event for each file being loaded
  100761. * @param pluginExtension the extension used to determine the plugin
  100762. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  100763. */
  100764. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  100765. meshes: AbstractMesh[];
  100766. particleSystems: IParticleSystem[];
  100767. skeletons: Skeleton[];
  100768. animationGroups: AnimationGroup[];
  100769. }>;
  100770. /**
  100771. * Load a scene
  100772. * @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)
  100773. * @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)
  100774. * @param engine is the instance of BABYLON.Engine to use to create the scene
  100775. * @param onSuccess a callback with the scene when import succeeds
  100776. * @param onProgress a callback with a progress event for each file being loaded
  100777. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100778. * @param pluginExtension the extension used to determine the plugin
  100779. * @returns The loaded plugin
  100780. */
  100781. 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>;
  100782. /**
  100783. * Load a scene
  100784. * @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)
  100785. * @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)
  100786. * @param engine is the instance of BABYLON.Engine to use to create the scene
  100787. * @param onProgress a callback with a progress event for each file being loaded
  100788. * @param pluginExtension the extension used to determine the plugin
  100789. * @returns The loaded scene
  100790. */
  100791. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  100792. /**
  100793. * Append a scene
  100794. * @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)
  100795. * @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)
  100796. * @param scene is the instance of BABYLON.Scene to append to
  100797. * @param onSuccess a callback with the scene when import succeeds
  100798. * @param onProgress a callback with a progress event for each file being loaded
  100799. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100800. * @param pluginExtension the extension used to determine the plugin
  100801. * @returns The loaded plugin
  100802. */
  100803. 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>;
  100804. /**
  100805. * Append a scene
  100806. * @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)
  100807. * @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)
  100808. * @param scene is the instance of BABYLON.Scene to append to
  100809. * @param onProgress a callback with a progress event for each file being loaded
  100810. * @param pluginExtension the extension used to determine the plugin
  100811. * @returns The given scene
  100812. */
  100813. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  100814. /**
  100815. * Load a scene into an asset container
  100816. * @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)
  100817. * @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)
  100818. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  100819. * @param onSuccess a callback with the scene when import succeeds
  100820. * @param onProgress a callback with a progress event for each file being loaded
  100821. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100822. * @param pluginExtension the extension used to determine the plugin
  100823. * @returns The loaded plugin
  100824. */
  100825. 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>;
  100826. /**
  100827. * Load a scene into an asset container
  100828. * @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)
  100829. * @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)
  100830. * @param scene is the instance of Scene to append to
  100831. * @param onProgress a callback with a progress event for each file being loaded
  100832. * @param pluginExtension the extension used to determine the plugin
  100833. * @returns The loaded asset container
  100834. */
  100835. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  100836. }
  100837. }
  100838. declare module BABYLON {
  100839. /**
  100840. * Google Daydream controller
  100841. */
  100842. export class DaydreamController extends WebVRController {
  100843. /**
  100844. * Base Url for the controller model.
  100845. */
  100846. static MODEL_BASE_URL: string;
  100847. /**
  100848. * File name for the controller model.
  100849. */
  100850. static MODEL_FILENAME: string;
  100851. /**
  100852. * Gamepad Id prefix used to identify Daydream Controller.
  100853. */
  100854. static readonly GAMEPAD_ID_PREFIX: string;
  100855. /**
  100856. * Creates a new DaydreamController from a gamepad
  100857. * @param vrGamepad the gamepad that the controller should be created from
  100858. */
  100859. constructor(vrGamepad: any);
  100860. /**
  100861. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100862. * @param scene scene in which to add meshes
  100863. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100864. */
  100865. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100866. /**
  100867. * Called once for each button that changed state since the last frame
  100868. * @param buttonIdx Which button index changed
  100869. * @param state New state of the button
  100870. * @param changes Which properties on the state changed since last frame
  100871. */
  100872. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100873. }
  100874. }
  100875. declare module BABYLON {
  100876. /**
  100877. * Gear VR Controller
  100878. */
  100879. export class GearVRController extends WebVRController {
  100880. /**
  100881. * Base Url for the controller model.
  100882. */
  100883. static MODEL_BASE_URL: string;
  100884. /**
  100885. * File name for the controller model.
  100886. */
  100887. static MODEL_FILENAME: string;
  100888. /**
  100889. * Gamepad Id prefix used to identify this controller.
  100890. */
  100891. static readonly GAMEPAD_ID_PREFIX: string;
  100892. private readonly _buttonIndexToObservableNameMap;
  100893. /**
  100894. * Creates a new GearVRController from a gamepad
  100895. * @param vrGamepad the gamepad that the controller should be created from
  100896. */
  100897. constructor(vrGamepad: any);
  100898. /**
  100899. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100900. * @param scene scene in which to add meshes
  100901. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100902. */
  100903. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100904. /**
  100905. * Called once for each button that changed state since the last frame
  100906. * @param buttonIdx Which button index changed
  100907. * @param state New state of the button
  100908. * @param changes Which properties on the state changed since last frame
  100909. */
  100910. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100911. }
  100912. }
  100913. declare module BABYLON {
  100914. /**
  100915. * Generic Controller
  100916. */
  100917. export class GenericController extends WebVRController {
  100918. /**
  100919. * Base Url for the controller model.
  100920. */
  100921. static readonly MODEL_BASE_URL: string;
  100922. /**
  100923. * File name for the controller model.
  100924. */
  100925. static readonly MODEL_FILENAME: string;
  100926. /**
  100927. * Creates a new GenericController from a gamepad
  100928. * @param vrGamepad the gamepad that the controller should be created from
  100929. */
  100930. constructor(vrGamepad: any);
  100931. /**
  100932. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100933. * @param scene scene in which to add meshes
  100934. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100935. */
  100936. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100937. /**
  100938. * Called once for each button that changed state since the last frame
  100939. * @param buttonIdx Which button index changed
  100940. * @param state New state of the button
  100941. * @param changes Which properties on the state changed since last frame
  100942. */
  100943. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100944. }
  100945. }
  100946. declare module BABYLON {
  100947. /**
  100948. * Oculus Touch Controller
  100949. */
  100950. export class OculusTouchController extends WebVRController {
  100951. /**
  100952. * Base Url for the controller model.
  100953. */
  100954. static MODEL_BASE_URL: string;
  100955. /**
  100956. * File name for the left controller model.
  100957. */
  100958. static MODEL_LEFT_FILENAME: string;
  100959. /**
  100960. * File name for the right controller model.
  100961. */
  100962. static MODEL_RIGHT_FILENAME: string;
  100963. /**
  100964. * Fired when the secondary trigger on this controller is modified
  100965. */
  100966. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100967. /**
  100968. * Fired when the thumb rest on this controller is modified
  100969. */
  100970. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  100971. /**
  100972. * Creates a new OculusTouchController from a gamepad
  100973. * @param vrGamepad the gamepad that the controller should be created from
  100974. */
  100975. constructor(vrGamepad: any);
  100976. /**
  100977. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100978. * @param scene scene in which to add meshes
  100979. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100980. */
  100981. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100982. /**
  100983. * Fired when the A button on this controller is modified
  100984. */
  100985. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100986. /**
  100987. * Fired when the B button on this controller is modified
  100988. */
  100989. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100990. /**
  100991. * Fired when the X button on this controller is modified
  100992. */
  100993. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100994. /**
  100995. * Fired when the Y button on this controller is modified
  100996. */
  100997. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100998. /**
  100999. * Called once for each button that changed state since the last frame
  101000. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  101001. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  101002. * 2) secondary trigger (same)
  101003. * 3) A (right) X (left), touch, pressed = value
  101004. * 4) B / Y
  101005. * 5) thumb rest
  101006. * @param buttonIdx Which button index changed
  101007. * @param state New state of the button
  101008. * @param changes Which properties on the state changed since last frame
  101009. */
  101010. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101011. }
  101012. }
  101013. declare module BABYLON {
  101014. /**
  101015. * Vive Controller
  101016. */
  101017. export class ViveController extends WebVRController {
  101018. /**
  101019. * Base Url for the controller model.
  101020. */
  101021. static MODEL_BASE_URL: string;
  101022. /**
  101023. * File name for the controller model.
  101024. */
  101025. static MODEL_FILENAME: string;
  101026. /**
  101027. * Creates a new ViveController from a gamepad
  101028. * @param vrGamepad the gamepad that the controller should be created from
  101029. */
  101030. constructor(vrGamepad: any);
  101031. /**
  101032. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101033. * @param scene scene in which to add meshes
  101034. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101035. */
  101036. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101037. /**
  101038. * Fired when the left button on this controller is modified
  101039. */
  101040. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101041. /**
  101042. * Fired when the right button on this controller is modified
  101043. */
  101044. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101045. /**
  101046. * Fired when the menu button on this controller is modified
  101047. */
  101048. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101049. /**
  101050. * Called once for each button that changed state since the last frame
  101051. * Vive mapping:
  101052. * 0: touchpad
  101053. * 1: trigger
  101054. * 2: left AND right buttons
  101055. * 3: menu button
  101056. * @param buttonIdx Which button index changed
  101057. * @param state New state of the button
  101058. * @param changes Which properties on the state changed since last frame
  101059. */
  101060. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101061. }
  101062. }
  101063. declare module BABYLON {
  101064. /**
  101065. * Defines the WindowsMotionController object that the state of the windows motion controller
  101066. */
  101067. export class WindowsMotionController extends WebVRController {
  101068. /**
  101069. * The base url used to load the left and right controller models
  101070. */
  101071. static MODEL_BASE_URL: string;
  101072. /**
  101073. * The name of the left controller model file
  101074. */
  101075. static MODEL_LEFT_FILENAME: string;
  101076. /**
  101077. * The name of the right controller model file
  101078. */
  101079. static MODEL_RIGHT_FILENAME: string;
  101080. /**
  101081. * The controller name prefix for this controller type
  101082. */
  101083. static readonly GAMEPAD_ID_PREFIX: string;
  101084. /**
  101085. * The controller id pattern for this controller type
  101086. */
  101087. private static readonly GAMEPAD_ID_PATTERN;
  101088. private _loadedMeshInfo;
  101089. private readonly _mapping;
  101090. /**
  101091. * Fired when the trackpad on this controller is clicked
  101092. */
  101093. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  101094. /**
  101095. * Fired when the trackpad on this controller is modified
  101096. */
  101097. onTrackpadValuesChangedObservable: Observable<StickValues>;
  101098. /**
  101099. * The current x and y values of this controller's trackpad
  101100. */
  101101. trackpad: StickValues;
  101102. /**
  101103. * Creates a new WindowsMotionController from a gamepad
  101104. * @param vrGamepad the gamepad that the controller should be created from
  101105. */
  101106. constructor(vrGamepad: any);
  101107. /**
  101108. * Fired when the trigger on this controller is modified
  101109. */
  101110. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101111. /**
  101112. * Fired when the menu button on this controller is modified
  101113. */
  101114. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101115. /**
  101116. * Fired when the grip button on this controller is modified
  101117. */
  101118. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101119. /**
  101120. * Fired when the thumbstick button on this controller is modified
  101121. */
  101122. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101123. /**
  101124. * Fired when the touchpad button on this controller is modified
  101125. */
  101126. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101127. /**
  101128. * Fired when the touchpad values on this controller are modified
  101129. */
  101130. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  101131. private _updateTrackpad;
  101132. /**
  101133. * Called once per frame by the engine.
  101134. */
  101135. update(): void;
  101136. /**
  101137. * Called once for each button that changed state since the last frame
  101138. * @param buttonIdx Which button index changed
  101139. * @param state New state of the button
  101140. * @param changes Which properties on the state changed since last frame
  101141. */
  101142. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101143. /**
  101144. * Moves the buttons on the controller mesh based on their current state
  101145. * @param buttonName the name of the button to move
  101146. * @param buttonValue the value of the button which determines the buttons new position
  101147. */
  101148. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  101149. /**
  101150. * Moves the axis on the controller mesh based on its current state
  101151. * @param axis the index of the axis
  101152. * @param axisValue the value of the axis which determines the meshes new position
  101153. * @hidden
  101154. */
  101155. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  101156. /**
  101157. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101158. * @param scene scene in which to add meshes
  101159. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101160. */
  101161. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  101162. /**
  101163. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  101164. * can be transformed by button presses and axes values, based on this._mapping.
  101165. *
  101166. * @param scene scene in which the meshes exist
  101167. * @param meshes list of meshes that make up the controller model to process
  101168. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  101169. */
  101170. private processModel;
  101171. private createMeshInfo;
  101172. /**
  101173. * Gets the ray of the controller in the direction the controller is pointing
  101174. * @param length the length the resulting ray should be
  101175. * @returns a ray in the direction the controller is pointing
  101176. */
  101177. getForwardRay(length?: number): Ray;
  101178. /**
  101179. * Disposes of the controller
  101180. */
  101181. dispose(): void;
  101182. }
  101183. }
  101184. declare module BABYLON {
  101185. /**
  101186. * Single axis scale gizmo
  101187. */
  101188. export class AxisScaleGizmo extends Gizmo {
  101189. private _coloredMaterial;
  101190. /**
  101191. * Drag behavior responsible for the gizmos dragging interactions
  101192. */
  101193. dragBehavior: PointerDragBehavior;
  101194. private _pointerObserver;
  101195. /**
  101196. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101197. */
  101198. snapDistance: number;
  101199. /**
  101200. * Event that fires each time the gizmo snaps to a new location.
  101201. * * snapDistance is the the change in distance
  101202. */
  101203. onSnapObservable: Observable<{
  101204. snapDistance: number;
  101205. }>;
  101206. /**
  101207. * If the scaling operation should be done on all axis (default: false)
  101208. */
  101209. uniformScaling: boolean;
  101210. /**
  101211. * Creates an AxisScaleGizmo
  101212. * @param gizmoLayer The utility layer the gizmo will be added to
  101213. * @param dragAxis The axis which the gizmo will be able to scale on
  101214. * @param color The color of the gizmo
  101215. */
  101216. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101217. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101218. /**
  101219. * Disposes of the gizmo
  101220. */
  101221. dispose(): void;
  101222. /**
  101223. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  101224. * @param mesh The mesh to replace the default mesh of the gizmo
  101225. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  101226. */
  101227. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  101228. }
  101229. }
  101230. declare module BABYLON {
  101231. /**
  101232. * Bounding box gizmo
  101233. */
  101234. export class BoundingBoxGizmo extends Gizmo {
  101235. private _lineBoundingBox;
  101236. private _rotateSpheresParent;
  101237. private _scaleBoxesParent;
  101238. private _boundingDimensions;
  101239. private _renderObserver;
  101240. private _pointerObserver;
  101241. private _scaleDragSpeed;
  101242. private _tmpQuaternion;
  101243. private _tmpVector;
  101244. private _tmpRotationMatrix;
  101245. /**
  101246. * 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)
  101247. */
  101248. ignoreChildren: boolean;
  101249. /**
  101250. * 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)
  101251. */
  101252. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  101253. /**
  101254. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  101255. */
  101256. rotationSphereSize: number;
  101257. /**
  101258. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  101259. */
  101260. scaleBoxSize: number;
  101261. /**
  101262. * 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)
  101263. */
  101264. fixedDragMeshScreenSize: boolean;
  101265. /**
  101266. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  101267. */
  101268. fixedDragMeshScreenSizeDistanceFactor: number;
  101269. /**
  101270. * Fired when a rotation sphere or scale box is dragged
  101271. */
  101272. onDragStartObservable: Observable<{}>;
  101273. /**
  101274. * Fired when a scale box is dragged
  101275. */
  101276. onScaleBoxDragObservable: Observable<{}>;
  101277. /**
  101278. * Fired when a scale box drag is ended
  101279. */
  101280. onScaleBoxDragEndObservable: Observable<{}>;
  101281. /**
  101282. * Fired when a rotation sphere is dragged
  101283. */
  101284. onRotationSphereDragObservable: Observable<{}>;
  101285. /**
  101286. * Fired when a rotation sphere drag is ended
  101287. */
  101288. onRotationSphereDragEndObservable: Observable<{}>;
  101289. /**
  101290. * 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)
  101291. */
  101292. scalePivot: Nullable<Vector3>;
  101293. private _anchorMesh;
  101294. private _existingMeshScale;
  101295. private _dragMesh;
  101296. private pointerDragBehavior;
  101297. private coloredMaterial;
  101298. private hoverColoredMaterial;
  101299. /**
  101300. * Sets the color of the bounding box gizmo
  101301. * @param color the color to set
  101302. */
  101303. setColor(color: Color3): void;
  101304. /**
  101305. * Creates an BoundingBoxGizmo
  101306. * @param gizmoLayer The utility layer the gizmo will be added to
  101307. * @param color The color of the gizmo
  101308. */
  101309. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101310. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101311. private _selectNode;
  101312. /**
  101313. * Updates the bounding box information for the Gizmo
  101314. */
  101315. updateBoundingBox(): void;
  101316. private _updateRotationSpheres;
  101317. private _updateScaleBoxes;
  101318. /**
  101319. * Enables rotation on the specified axis and disables rotation on the others
  101320. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  101321. */
  101322. setEnabledRotationAxis(axis: string): void;
  101323. /**
  101324. * Enables/disables scaling
  101325. * @param enable if scaling should be enabled
  101326. */
  101327. setEnabledScaling(enable: boolean): void;
  101328. private _updateDummy;
  101329. /**
  101330. * Enables a pointer drag behavior on the bounding box of the gizmo
  101331. */
  101332. enableDragBehavior(): void;
  101333. /**
  101334. * Disposes of the gizmo
  101335. */
  101336. dispose(): void;
  101337. /**
  101338. * 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)
  101339. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  101340. * @returns the bounding box mesh with the passed in mesh as a child
  101341. */
  101342. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  101343. /**
  101344. * CustomMeshes are not supported by this gizmo
  101345. * @param mesh The mesh to replace the default mesh of the gizmo
  101346. */
  101347. setCustomMesh(mesh: Mesh): void;
  101348. }
  101349. }
  101350. declare module BABYLON {
  101351. /**
  101352. * Single plane rotation gizmo
  101353. */
  101354. export class PlaneRotationGizmo extends Gizmo {
  101355. /**
  101356. * Drag behavior responsible for the gizmos dragging interactions
  101357. */
  101358. dragBehavior: PointerDragBehavior;
  101359. private _pointerObserver;
  101360. /**
  101361. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  101362. */
  101363. snapDistance: number;
  101364. /**
  101365. * Event that fires each time the gizmo snaps to a new location.
  101366. * * snapDistance is the the change in distance
  101367. */
  101368. onSnapObservable: Observable<{
  101369. snapDistance: number;
  101370. }>;
  101371. /**
  101372. * Creates a PlaneRotationGizmo
  101373. * @param gizmoLayer The utility layer the gizmo will be added to
  101374. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  101375. * @param color The color of the gizmo
  101376. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101377. */
  101378. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101379. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101380. /**
  101381. * Disposes of the gizmo
  101382. */
  101383. dispose(): void;
  101384. }
  101385. }
  101386. declare module BABYLON {
  101387. /**
  101388. * Gizmo that enables rotating a mesh along 3 axis
  101389. */
  101390. export class RotationGizmo extends Gizmo {
  101391. /**
  101392. * Internal gizmo used for interactions on the x axis
  101393. */
  101394. xGizmo: PlaneRotationGizmo;
  101395. /**
  101396. * Internal gizmo used for interactions on the y axis
  101397. */
  101398. yGizmo: PlaneRotationGizmo;
  101399. /**
  101400. * Internal gizmo used for interactions on the z axis
  101401. */
  101402. zGizmo: PlaneRotationGizmo;
  101403. /** Fires an event when any of it's sub gizmos are dragged */
  101404. onDragStartObservable: Observable<{}>;
  101405. /** Fires an event when any of it's sub gizmos are released from dragging */
  101406. onDragEndObservable: Observable<{}>;
  101407. attachedMesh: Nullable<AbstractMesh>;
  101408. /**
  101409. * Creates a RotationGizmo
  101410. * @param gizmoLayer The utility layer the gizmo will be added to
  101411. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101412. */
  101413. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101414. updateGizmoRotationToMatchAttachedMesh: boolean;
  101415. /**
  101416. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101417. */
  101418. snapDistance: number;
  101419. /**
  101420. * Ratio for the scale of the gizmo (Default: 1)
  101421. */
  101422. scaleRatio: number;
  101423. /**
  101424. * Disposes of the gizmo
  101425. */
  101426. dispose(): void;
  101427. /**
  101428. * CustomMeshes are not supported by this gizmo
  101429. * @param mesh The mesh to replace the default mesh of the gizmo
  101430. */
  101431. setCustomMesh(mesh: Mesh): void;
  101432. }
  101433. }
  101434. declare module BABYLON {
  101435. /**
  101436. * Gizmo that enables dragging a mesh along 3 axis
  101437. */
  101438. export class PositionGizmo extends Gizmo {
  101439. /**
  101440. * Internal gizmo used for interactions on the x axis
  101441. */
  101442. xGizmo: AxisDragGizmo;
  101443. /**
  101444. * Internal gizmo used for interactions on the y axis
  101445. */
  101446. yGizmo: AxisDragGizmo;
  101447. /**
  101448. * Internal gizmo used for interactions on the z axis
  101449. */
  101450. zGizmo: AxisDragGizmo;
  101451. /** Fires an event when any of it's sub gizmos are dragged */
  101452. onDragStartObservable: Observable<{}>;
  101453. /** Fires an event when any of it's sub gizmos are released from dragging */
  101454. onDragEndObservable: Observable<{}>;
  101455. attachedMesh: Nullable<AbstractMesh>;
  101456. /**
  101457. * Creates a PositionGizmo
  101458. * @param gizmoLayer The utility layer the gizmo will be added to
  101459. */
  101460. constructor(gizmoLayer?: UtilityLayerRenderer);
  101461. updateGizmoRotationToMatchAttachedMesh: boolean;
  101462. /**
  101463. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101464. */
  101465. snapDistance: number;
  101466. /**
  101467. * Ratio for the scale of the gizmo (Default: 1)
  101468. */
  101469. scaleRatio: number;
  101470. /**
  101471. * Disposes of the gizmo
  101472. */
  101473. dispose(): void;
  101474. /**
  101475. * CustomMeshes are not supported by this gizmo
  101476. * @param mesh The mesh to replace the default mesh of the gizmo
  101477. */
  101478. setCustomMesh(mesh: Mesh): void;
  101479. }
  101480. }
  101481. declare module BABYLON {
  101482. /**
  101483. * Class containing static functions to help procedurally build meshes
  101484. */
  101485. export class PolyhedronBuilder {
  101486. /**
  101487. * Creates a polyhedron mesh
  101488. * * 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
  101489. * * The parameter `size` (positive float, default 1) sets the polygon size
  101490. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101491. * * 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`
  101492. * * 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
  101493. * * 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)`)
  101494. * * 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
  101495. * * 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
  101496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101499. * @param name defines the name of the mesh
  101500. * @param options defines the options used to create the mesh
  101501. * @param scene defines the hosting scene
  101502. * @returns the polyhedron mesh
  101503. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  101504. */
  101505. static CreatePolyhedron(name: string, options: {
  101506. type?: number;
  101507. size?: number;
  101508. sizeX?: number;
  101509. sizeY?: number;
  101510. sizeZ?: number;
  101511. custom?: any;
  101512. faceUV?: Vector4[];
  101513. faceColors?: Color4[];
  101514. flat?: boolean;
  101515. updatable?: boolean;
  101516. sideOrientation?: number;
  101517. frontUVs?: Vector4;
  101518. backUVs?: Vector4;
  101519. }, scene: Scene): Mesh;
  101520. }
  101521. }
  101522. declare module BABYLON {
  101523. /**
  101524. * Gizmo that enables scaling a mesh along 3 axis
  101525. */
  101526. export class ScaleGizmo extends Gizmo {
  101527. /**
  101528. * Internal gizmo used for interactions on the x axis
  101529. */
  101530. xGizmo: AxisScaleGizmo;
  101531. /**
  101532. * Internal gizmo used for interactions on the y axis
  101533. */
  101534. yGizmo: AxisScaleGizmo;
  101535. /**
  101536. * Internal gizmo used for interactions on the z axis
  101537. */
  101538. zGizmo: AxisScaleGizmo;
  101539. /**
  101540. * Internal gizmo used to scale all axis equally
  101541. */
  101542. uniformScaleGizmo: AxisScaleGizmo;
  101543. /** Fires an event when any of it's sub gizmos are dragged */
  101544. onDragStartObservable: Observable<{}>;
  101545. /** Fires an event when any of it's sub gizmos are released from dragging */
  101546. onDragEndObservable: Observable<{}>;
  101547. attachedMesh: Nullable<AbstractMesh>;
  101548. /**
  101549. * Creates a ScaleGizmo
  101550. * @param gizmoLayer The utility layer the gizmo will be added to
  101551. */
  101552. constructor(gizmoLayer?: UtilityLayerRenderer);
  101553. updateGizmoRotationToMatchAttachedMesh: boolean;
  101554. /**
  101555. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101556. */
  101557. snapDistance: number;
  101558. /**
  101559. * Ratio for the scale of the gizmo (Default: 1)
  101560. */
  101561. scaleRatio: number;
  101562. /**
  101563. * Disposes of the gizmo
  101564. */
  101565. dispose(): void;
  101566. }
  101567. }
  101568. declare module BABYLON {
  101569. /**
  101570. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  101571. */
  101572. export class GizmoManager implements IDisposable {
  101573. private scene;
  101574. /**
  101575. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  101576. */
  101577. gizmos: {
  101578. positionGizmo: Nullable<PositionGizmo>;
  101579. rotationGizmo: Nullable<RotationGizmo>;
  101580. scaleGizmo: Nullable<ScaleGizmo>;
  101581. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  101582. };
  101583. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  101584. clearGizmoOnEmptyPointerEvent: boolean;
  101585. /** Fires an event when the manager is attached to a mesh */
  101586. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  101587. private _gizmosEnabled;
  101588. private _pointerObserver;
  101589. private _attachedMesh;
  101590. private _boundingBoxColor;
  101591. private _defaultUtilityLayer;
  101592. private _defaultKeepDepthUtilityLayer;
  101593. /**
  101594. * When bounding box gizmo is enabled, this can be used to track drag/end events
  101595. */
  101596. boundingBoxDragBehavior: SixDofDragBehavior;
  101597. /**
  101598. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  101599. */
  101600. attachableMeshes: Nullable<Array<AbstractMesh>>;
  101601. /**
  101602. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  101603. */
  101604. usePointerToAttachGizmos: boolean;
  101605. /**
  101606. * Instatiates a gizmo manager
  101607. * @param scene the scene to overlay the gizmos on top of
  101608. */
  101609. constructor(scene: Scene);
  101610. /**
  101611. * Attaches a set of gizmos to the specified mesh
  101612. * @param mesh The mesh the gizmo's should be attached to
  101613. */
  101614. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101615. /**
  101616. * If the position gizmo is enabled
  101617. */
  101618. positionGizmoEnabled: boolean;
  101619. /**
  101620. * If the rotation gizmo is enabled
  101621. */
  101622. rotationGizmoEnabled: boolean;
  101623. /**
  101624. * If the scale gizmo is enabled
  101625. */
  101626. scaleGizmoEnabled: boolean;
  101627. /**
  101628. * If the boundingBox gizmo is enabled
  101629. */
  101630. boundingBoxGizmoEnabled: boolean;
  101631. /**
  101632. * Disposes of the gizmo manager
  101633. */
  101634. dispose(): void;
  101635. }
  101636. }
  101637. declare module BABYLON {
  101638. /**
  101639. * A directional light is defined by a direction (what a surprise!).
  101640. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101641. * 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.
  101642. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101643. */
  101644. export class DirectionalLight extends ShadowLight {
  101645. private _shadowFrustumSize;
  101646. /**
  101647. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101648. */
  101649. /**
  101650. * Specifies a fix frustum size for the shadow generation.
  101651. */
  101652. shadowFrustumSize: number;
  101653. private _shadowOrthoScale;
  101654. /**
  101655. * Gets the shadow projection scale against the optimal computed one.
  101656. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101657. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101658. */
  101659. /**
  101660. * Sets the shadow projection scale against the optimal computed one.
  101661. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101662. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101663. */
  101664. shadowOrthoScale: number;
  101665. /**
  101666. * Automatically compute the projection matrix to best fit (including all the casters)
  101667. * on each frame.
  101668. */
  101669. autoUpdateExtends: boolean;
  101670. private _orthoLeft;
  101671. private _orthoRight;
  101672. private _orthoTop;
  101673. private _orthoBottom;
  101674. /**
  101675. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101676. * The directional light is emitted from everywhere in the given direction.
  101677. * It can cast shadows.
  101678. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101679. * @param name The friendly name of the light
  101680. * @param direction The direction of the light
  101681. * @param scene The scene the light belongs to
  101682. */
  101683. constructor(name: string, direction: Vector3, scene: Scene);
  101684. /**
  101685. * Returns the string "DirectionalLight".
  101686. * @return The class name
  101687. */
  101688. getClassName(): string;
  101689. /**
  101690. * Returns the integer 1.
  101691. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101692. */
  101693. getTypeID(): number;
  101694. /**
  101695. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101696. * Returns the DirectionalLight Shadow projection matrix.
  101697. */
  101698. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101699. /**
  101700. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101701. * Returns the DirectionalLight Shadow projection matrix.
  101702. */
  101703. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101704. /**
  101705. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  101706. * Returns the DirectionalLight Shadow projection matrix.
  101707. */
  101708. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101709. protected _buildUniformLayout(): void;
  101710. /**
  101711. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  101712. * @param effect The effect to update
  101713. * @param lightIndex The index of the light in the effect to update
  101714. * @returns The directional light
  101715. */
  101716. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  101717. /**
  101718. * Gets the minZ used for shadow according to both the scene and the light.
  101719. *
  101720. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101721. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101722. * @param activeCamera The camera we are returning the min for
  101723. * @returns the depth min z
  101724. */
  101725. getDepthMinZ(activeCamera: Camera): number;
  101726. /**
  101727. * Gets the maxZ used for shadow according to both the scene and the light.
  101728. *
  101729. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101730. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101731. * @param activeCamera The camera we are returning the max for
  101732. * @returns the depth max z
  101733. */
  101734. getDepthMaxZ(activeCamera: Camera): number;
  101735. /**
  101736. * Prepares the list of defines specific to the light type.
  101737. * @param defines the list of defines
  101738. * @param lightIndex defines the index of the light for the effect
  101739. */
  101740. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101741. }
  101742. }
  101743. declare module BABYLON {
  101744. /**
  101745. * Class containing static functions to help procedurally build meshes
  101746. */
  101747. export class HemisphereBuilder {
  101748. /**
  101749. * Creates a hemisphere mesh
  101750. * @param name defines the name of the mesh
  101751. * @param options defines the options used to create the mesh
  101752. * @param scene defines the hosting scene
  101753. * @returns the hemisphere mesh
  101754. */
  101755. static CreateHemisphere(name: string, options: {
  101756. segments?: number;
  101757. diameter?: number;
  101758. sideOrientation?: number;
  101759. }, scene: any): Mesh;
  101760. }
  101761. }
  101762. declare module BABYLON {
  101763. /**
  101764. * A spot light is defined by a position, a direction, an angle, and an exponent.
  101765. * These values define a cone of light starting from the position, emitting toward the direction.
  101766. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  101767. * and the exponent defines the speed of the decay of the light with distance (reach).
  101768. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101769. */
  101770. export class SpotLight extends ShadowLight {
  101771. private _angle;
  101772. private _innerAngle;
  101773. private _cosHalfAngle;
  101774. private _lightAngleScale;
  101775. private _lightAngleOffset;
  101776. /**
  101777. * Gets the cone angle of the spot light in Radians.
  101778. */
  101779. /**
  101780. * Sets the cone angle of the spot light in Radians.
  101781. */
  101782. angle: number;
  101783. /**
  101784. * Only used in gltf falloff mode, this defines the angle where
  101785. * the directional falloff will start before cutting at angle which could be seen
  101786. * as outer angle.
  101787. */
  101788. /**
  101789. * Only used in gltf falloff mode, this defines the angle where
  101790. * the directional falloff will start before cutting at angle which could be seen
  101791. * as outer angle.
  101792. */
  101793. innerAngle: number;
  101794. private _shadowAngleScale;
  101795. /**
  101796. * Allows scaling the angle of the light for shadow generation only.
  101797. */
  101798. /**
  101799. * Allows scaling the angle of the light for shadow generation only.
  101800. */
  101801. shadowAngleScale: number;
  101802. /**
  101803. * The light decay speed with the distance from the emission spot.
  101804. */
  101805. exponent: number;
  101806. private _projectionTextureMatrix;
  101807. /**
  101808. * Allows reading the projecton texture
  101809. */
  101810. readonly projectionTextureMatrix: Matrix;
  101811. protected _projectionTextureLightNear: number;
  101812. /**
  101813. * Gets the near clip of the Spotlight for texture projection.
  101814. */
  101815. /**
  101816. * Sets the near clip of the Spotlight for texture projection.
  101817. */
  101818. projectionTextureLightNear: number;
  101819. protected _projectionTextureLightFar: number;
  101820. /**
  101821. * Gets the far clip of the Spotlight for texture projection.
  101822. */
  101823. /**
  101824. * Sets the far clip of the Spotlight for texture projection.
  101825. */
  101826. projectionTextureLightFar: number;
  101827. protected _projectionTextureUpDirection: Vector3;
  101828. /**
  101829. * Gets the Up vector of the Spotlight for texture projection.
  101830. */
  101831. /**
  101832. * Sets the Up vector of the Spotlight for texture projection.
  101833. */
  101834. projectionTextureUpDirection: Vector3;
  101835. private _projectionTexture;
  101836. /**
  101837. * Gets the projection texture of the light.
  101838. */
  101839. /**
  101840. * Sets the projection texture of the light.
  101841. */
  101842. projectionTexture: Nullable<BaseTexture>;
  101843. private _projectionTextureViewLightDirty;
  101844. private _projectionTextureProjectionLightDirty;
  101845. private _projectionTextureDirty;
  101846. private _projectionTextureViewTargetVector;
  101847. private _projectionTextureViewLightMatrix;
  101848. private _projectionTextureProjectionLightMatrix;
  101849. private _projectionTextureScalingMatrix;
  101850. /**
  101851. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  101852. * It can cast shadows.
  101853. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101854. * @param name The light friendly name
  101855. * @param position The position of the spot light in the scene
  101856. * @param direction The direction of the light in the scene
  101857. * @param angle The cone angle of the light in Radians
  101858. * @param exponent The light decay speed with the distance from the emission spot
  101859. * @param scene The scene the lights belongs to
  101860. */
  101861. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  101862. /**
  101863. * Returns the string "SpotLight".
  101864. * @returns the class name
  101865. */
  101866. getClassName(): string;
  101867. /**
  101868. * Returns the integer 2.
  101869. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101870. */
  101871. getTypeID(): number;
  101872. /**
  101873. * Overrides the direction setter to recompute the projection texture view light Matrix.
  101874. */
  101875. protected _setDirection(value: Vector3): void;
  101876. /**
  101877. * Overrides the position setter to recompute the projection texture view light Matrix.
  101878. */
  101879. protected _setPosition(value: Vector3): void;
  101880. /**
  101881. * 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.
  101882. * Returns the SpotLight.
  101883. */
  101884. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101885. protected _computeProjectionTextureViewLightMatrix(): void;
  101886. protected _computeProjectionTextureProjectionLightMatrix(): void;
  101887. /**
  101888. * Main function for light texture projection matrix computing.
  101889. */
  101890. protected _computeProjectionTextureMatrix(): void;
  101891. protected _buildUniformLayout(): void;
  101892. private _computeAngleValues;
  101893. /**
  101894. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  101895. * @param effect The effect to update
  101896. * @param lightIndex The index of the light in the effect to update
  101897. * @returns The spot light
  101898. */
  101899. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  101900. /**
  101901. * Disposes the light and the associated resources.
  101902. */
  101903. dispose(): void;
  101904. /**
  101905. * Prepares the list of defines specific to the light type.
  101906. * @param defines the list of defines
  101907. * @param lightIndex defines the index of the light for the effect
  101908. */
  101909. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101910. }
  101911. }
  101912. declare module BABYLON {
  101913. /**
  101914. * Gizmo that enables viewing a light
  101915. */
  101916. export class LightGizmo extends Gizmo {
  101917. private _lightMesh;
  101918. private _material;
  101919. /**
  101920. * Creates a LightGizmo
  101921. * @param gizmoLayer The utility layer the gizmo will be added to
  101922. */
  101923. constructor(gizmoLayer?: UtilityLayerRenderer);
  101924. private _light;
  101925. /**
  101926. * The light that the gizmo is attached to
  101927. */
  101928. light: Nullable<Light>;
  101929. /**
  101930. * @hidden
  101931. * Updates the gizmo to match the attached mesh's position/rotation
  101932. */
  101933. protected _update(): void;
  101934. private static _Scale;
  101935. /**
  101936. * Creates the lines for a light mesh
  101937. */
  101938. private static _createLightLines;
  101939. private static _CreateHemisphericLightMesh;
  101940. private static _CreatePointLightMesh;
  101941. private static _CreateSpotLightMesh;
  101942. private static _CreateDirectionalLightMesh;
  101943. }
  101944. }
  101945. declare module BABYLON {
  101946. /** @hidden */
  101947. export var backgroundFragmentDeclaration: {
  101948. name: string;
  101949. shader: string;
  101950. };
  101951. }
  101952. declare module BABYLON {
  101953. /** @hidden */
  101954. export var backgroundUboDeclaration: {
  101955. name: string;
  101956. shader: string;
  101957. };
  101958. }
  101959. declare module BABYLON {
  101960. /** @hidden */
  101961. export var backgroundPixelShader: {
  101962. name: string;
  101963. shader: string;
  101964. };
  101965. }
  101966. declare module BABYLON {
  101967. /** @hidden */
  101968. export var backgroundVertexDeclaration: {
  101969. name: string;
  101970. shader: string;
  101971. };
  101972. }
  101973. declare module BABYLON {
  101974. /** @hidden */
  101975. export var backgroundVertexShader: {
  101976. name: string;
  101977. shader: string;
  101978. };
  101979. }
  101980. declare module BABYLON {
  101981. /**
  101982. * Background material used to create an efficient environement around your scene.
  101983. */
  101984. export class BackgroundMaterial extends PushMaterial {
  101985. /**
  101986. * Standard reflectance value at parallel view angle.
  101987. */
  101988. static StandardReflectance0: number;
  101989. /**
  101990. * Standard reflectance value at grazing angle.
  101991. */
  101992. static StandardReflectance90: number;
  101993. protected _primaryColor: Color3;
  101994. /**
  101995. * Key light Color (multiply against the environement texture)
  101996. */
  101997. primaryColor: Color3;
  101998. protected __perceptualColor: Nullable<Color3>;
  101999. /**
  102000. * Experimental Internal Use Only.
  102001. *
  102002. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  102003. * This acts as a helper to set the primary color to a more "human friendly" value.
  102004. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  102005. * output color as close as possible from the chosen value.
  102006. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  102007. * part of lighting setup.)
  102008. */
  102009. _perceptualColor: Nullable<Color3>;
  102010. protected _primaryColorShadowLevel: float;
  102011. /**
  102012. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  102013. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  102014. */
  102015. primaryColorShadowLevel: float;
  102016. protected _primaryColorHighlightLevel: float;
  102017. /**
  102018. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  102019. * The primary color is used at the level chosen to define what the white area would look.
  102020. */
  102021. primaryColorHighlightLevel: float;
  102022. protected _reflectionTexture: Nullable<BaseTexture>;
  102023. /**
  102024. * Reflection Texture used in the material.
  102025. * Should be author in a specific way for the best result (refer to the documentation).
  102026. */
  102027. reflectionTexture: Nullable<BaseTexture>;
  102028. protected _reflectionBlur: float;
  102029. /**
  102030. * Reflection Texture level of blur.
  102031. *
  102032. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  102033. * texture twice.
  102034. */
  102035. reflectionBlur: float;
  102036. protected _diffuseTexture: Nullable<BaseTexture>;
  102037. /**
  102038. * Diffuse Texture used in the material.
  102039. * Should be author in a specific way for the best result (refer to the documentation).
  102040. */
  102041. diffuseTexture: Nullable<BaseTexture>;
  102042. protected _shadowLights: Nullable<IShadowLight[]>;
  102043. /**
  102044. * Specify the list of lights casting shadow on the material.
  102045. * All scene shadow lights will be included if null.
  102046. */
  102047. shadowLights: Nullable<IShadowLight[]>;
  102048. protected _shadowLevel: float;
  102049. /**
  102050. * Helps adjusting the shadow to a softer level if required.
  102051. * 0 means black shadows and 1 means no shadows.
  102052. */
  102053. shadowLevel: float;
  102054. protected _sceneCenter: Vector3;
  102055. /**
  102056. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  102057. * It is usually zero but might be interesting to modify according to your setup.
  102058. */
  102059. sceneCenter: Vector3;
  102060. protected _opacityFresnel: boolean;
  102061. /**
  102062. * This helps specifying that the material is falling off to the sky box at grazing angle.
  102063. * This helps ensuring a nice transition when the camera goes under the ground.
  102064. */
  102065. opacityFresnel: boolean;
  102066. protected _reflectionFresnel: boolean;
  102067. /**
  102068. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  102069. * This helps adding a mirror texture on the ground.
  102070. */
  102071. reflectionFresnel: boolean;
  102072. protected _reflectionFalloffDistance: number;
  102073. /**
  102074. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  102075. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  102076. */
  102077. reflectionFalloffDistance: number;
  102078. protected _reflectionAmount: number;
  102079. /**
  102080. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  102081. */
  102082. reflectionAmount: number;
  102083. protected _reflectionReflectance0: number;
  102084. /**
  102085. * This specifies the weight of the reflection at grazing angle.
  102086. */
  102087. reflectionReflectance0: number;
  102088. protected _reflectionReflectance90: number;
  102089. /**
  102090. * This specifies the weight of the reflection at a perpendicular point of view.
  102091. */
  102092. reflectionReflectance90: number;
  102093. /**
  102094. * Sets the reflection reflectance fresnel values according to the default standard
  102095. * empirically know to work well :-)
  102096. */
  102097. reflectionStandardFresnelWeight: number;
  102098. protected _useRGBColor: boolean;
  102099. /**
  102100. * Helps to directly use the maps channels instead of their level.
  102101. */
  102102. useRGBColor: boolean;
  102103. protected _enableNoise: boolean;
  102104. /**
  102105. * This helps reducing the banding effect that could occur on the background.
  102106. */
  102107. enableNoise: boolean;
  102108. /**
  102109. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102110. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  102111. * Recommended to be keep at 1.0 except for special cases.
  102112. */
  102113. fovMultiplier: number;
  102114. private _fovMultiplier;
  102115. /**
  102116. * Enable the FOV adjustment feature controlled by fovMultiplier.
  102117. */
  102118. useEquirectangularFOV: boolean;
  102119. private _maxSimultaneousLights;
  102120. /**
  102121. * Number of Simultaneous lights allowed on the material.
  102122. */
  102123. maxSimultaneousLights: int;
  102124. /**
  102125. * Default configuration related to image processing available in the Background Material.
  102126. */
  102127. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102128. /**
  102129. * Keep track of the image processing observer to allow dispose and replace.
  102130. */
  102131. private _imageProcessingObserver;
  102132. /**
  102133. * Attaches a new image processing configuration to the PBR Material.
  102134. * @param configuration (if null the scene configuration will be use)
  102135. */
  102136. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102137. /**
  102138. * Gets the image processing configuration used either in this material.
  102139. */
  102140. /**
  102141. * Sets the Default image processing configuration used either in the this material.
  102142. *
  102143. * If sets to null, the scene one is in use.
  102144. */
  102145. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  102146. /**
  102147. * Gets wether the color curves effect is enabled.
  102148. */
  102149. /**
  102150. * Sets wether the color curves effect is enabled.
  102151. */
  102152. cameraColorCurvesEnabled: boolean;
  102153. /**
  102154. * Gets wether the color grading effect is enabled.
  102155. */
  102156. /**
  102157. * Gets wether the color grading effect is enabled.
  102158. */
  102159. cameraColorGradingEnabled: boolean;
  102160. /**
  102161. * Gets wether tonemapping is enabled or not.
  102162. */
  102163. /**
  102164. * Sets wether tonemapping is enabled or not
  102165. */
  102166. cameraToneMappingEnabled: boolean;
  102167. /**
  102168. * The camera exposure used on this material.
  102169. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102170. * This corresponds to a photographic exposure.
  102171. */
  102172. /**
  102173. * The camera exposure used on this material.
  102174. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102175. * This corresponds to a photographic exposure.
  102176. */
  102177. cameraExposure: float;
  102178. /**
  102179. * Gets The camera contrast used on this material.
  102180. */
  102181. /**
  102182. * Sets The camera contrast used on this material.
  102183. */
  102184. cameraContrast: float;
  102185. /**
  102186. * Gets the Color Grading 2D Lookup Texture.
  102187. */
  102188. /**
  102189. * Sets the Color Grading 2D Lookup Texture.
  102190. */
  102191. cameraColorGradingTexture: Nullable<BaseTexture>;
  102192. /**
  102193. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102194. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102195. * 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;
  102196. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102197. */
  102198. /**
  102199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102201. * 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;
  102202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102203. */
  102204. cameraColorCurves: Nullable<ColorCurves>;
  102205. /**
  102206. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  102207. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  102208. */
  102209. switchToBGR: boolean;
  102210. private _renderTargets;
  102211. private _reflectionControls;
  102212. private _white;
  102213. private _primaryShadowColor;
  102214. private _primaryHighlightColor;
  102215. /**
  102216. * Instantiates a Background Material in the given scene
  102217. * @param name The friendly name of the material
  102218. * @param scene The scene to add the material to
  102219. */
  102220. constructor(name: string, scene: Scene);
  102221. /**
  102222. * Gets a boolean indicating that current material needs to register RTT
  102223. */
  102224. readonly hasRenderTargetTextures: boolean;
  102225. /**
  102226. * The entire material has been created in order to prevent overdraw.
  102227. * @returns false
  102228. */
  102229. needAlphaTesting(): boolean;
  102230. /**
  102231. * The entire material has been created in order to prevent overdraw.
  102232. * @returns true if blending is enable
  102233. */
  102234. needAlphaBlending(): boolean;
  102235. /**
  102236. * Checks wether the material is ready to be rendered for a given mesh.
  102237. * @param mesh The mesh to render
  102238. * @param subMesh The submesh to check against
  102239. * @param useInstances Specify wether or not the material is used with instances
  102240. * @returns true if all the dependencies are ready (Textures, Effects...)
  102241. */
  102242. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102243. /**
  102244. * Compute the primary color according to the chosen perceptual color.
  102245. */
  102246. private _computePrimaryColorFromPerceptualColor;
  102247. /**
  102248. * Compute the highlights and shadow colors according to their chosen levels.
  102249. */
  102250. private _computePrimaryColors;
  102251. /**
  102252. * Build the uniform buffer used in the material.
  102253. */
  102254. buildUniformLayout(): void;
  102255. /**
  102256. * Unbind the material.
  102257. */
  102258. unbind(): void;
  102259. /**
  102260. * Bind only the world matrix to the material.
  102261. * @param world The world matrix to bind.
  102262. */
  102263. bindOnlyWorldMatrix(world: Matrix): void;
  102264. /**
  102265. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  102266. * @param world The world matrix to bind.
  102267. * @param subMesh The submesh to bind for.
  102268. */
  102269. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102270. /**
  102271. * Dispose the material.
  102272. * @param forceDisposeEffect Force disposal of the associated effect.
  102273. * @param forceDisposeTextures Force disposal of the associated textures.
  102274. */
  102275. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102276. /**
  102277. * Clones the material.
  102278. * @param name The cloned name.
  102279. * @returns The cloned material.
  102280. */
  102281. clone(name: string): BackgroundMaterial;
  102282. /**
  102283. * Serializes the current material to its JSON representation.
  102284. * @returns The JSON representation.
  102285. */
  102286. serialize(): any;
  102287. /**
  102288. * Gets the class name of the material
  102289. * @returns "BackgroundMaterial"
  102290. */
  102291. getClassName(): string;
  102292. /**
  102293. * Parse a JSON input to create back a background material.
  102294. * @param source The JSON data to parse
  102295. * @param scene The scene to create the parsed material in
  102296. * @param rootUrl The root url of the assets the material depends upon
  102297. * @returns the instantiated BackgroundMaterial.
  102298. */
  102299. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  102300. }
  102301. }
  102302. declare module BABYLON {
  102303. /**
  102304. * Represents the different options available during the creation of
  102305. * a Environment helper.
  102306. *
  102307. * This can control the default ground, skybox and image processing setup of your scene.
  102308. */
  102309. export interface IEnvironmentHelperOptions {
  102310. /**
  102311. * Specifies wether or not to create a ground.
  102312. * True by default.
  102313. */
  102314. createGround: boolean;
  102315. /**
  102316. * Specifies the ground size.
  102317. * 15 by default.
  102318. */
  102319. groundSize: number;
  102320. /**
  102321. * The texture used on the ground for the main color.
  102322. * Comes from the BabylonJS CDN by default.
  102323. *
  102324. * Remarks: Can be either a texture or a url.
  102325. */
  102326. groundTexture: string | BaseTexture;
  102327. /**
  102328. * The color mixed in the ground texture by default.
  102329. * BabylonJS clearColor by default.
  102330. */
  102331. groundColor: Color3;
  102332. /**
  102333. * Specifies the ground opacity.
  102334. * 1 by default.
  102335. */
  102336. groundOpacity: number;
  102337. /**
  102338. * Enables the ground to receive shadows.
  102339. * True by default.
  102340. */
  102341. enableGroundShadow: boolean;
  102342. /**
  102343. * Helps preventing the shadow to be fully black on the ground.
  102344. * 0.5 by default.
  102345. */
  102346. groundShadowLevel: number;
  102347. /**
  102348. * Creates a mirror texture attach to the ground.
  102349. * false by default.
  102350. */
  102351. enableGroundMirror: boolean;
  102352. /**
  102353. * Specifies the ground mirror size ratio.
  102354. * 0.3 by default as the default kernel is 64.
  102355. */
  102356. groundMirrorSizeRatio: number;
  102357. /**
  102358. * Specifies the ground mirror blur kernel size.
  102359. * 64 by default.
  102360. */
  102361. groundMirrorBlurKernel: number;
  102362. /**
  102363. * Specifies the ground mirror visibility amount.
  102364. * 1 by default
  102365. */
  102366. groundMirrorAmount: number;
  102367. /**
  102368. * Specifies the ground mirror reflectance weight.
  102369. * This uses the standard weight of the background material to setup the fresnel effect
  102370. * of the mirror.
  102371. * 1 by default.
  102372. */
  102373. groundMirrorFresnelWeight: number;
  102374. /**
  102375. * Specifies the ground mirror Falloff distance.
  102376. * This can helps reducing the size of the reflection.
  102377. * 0 by Default.
  102378. */
  102379. groundMirrorFallOffDistance: number;
  102380. /**
  102381. * Specifies the ground mirror texture type.
  102382. * Unsigned Int by Default.
  102383. */
  102384. groundMirrorTextureType: number;
  102385. /**
  102386. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  102387. * the shown objects.
  102388. */
  102389. groundYBias: number;
  102390. /**
  102391. * Specifies wether or not to create a skybox.
  102392. * True by default.
  102393. */
  102394. createSkybox: boolean;
  102395. /**
  102396. * Specifies the skybox size.
  102397. * 20 by default.
  102398. */
  102399. skyboxSize: number;
  102400. /**
  102401. * The texture used on the skybox for the main color.
  102402. * Comes from the BabylonJS CDN by default.
  102403. *
  102404. * Remarks: Can be either a texture or a url.
  102405. */
  102406. skyboxTexture: string | BaseTexture;
  102407. /**
  102408. * The color mixed in the skybox texture by default.
  102409. * BabylonJS clearColor by default.
  102410. */
  102411. skyboxColor: Color3;
  102412. /**
  102413. * The background rotation around the Y axis of the scene.
  102414. * This helps aligning the key lights of your scene with the background.
  102415. * 0 by default.
  102416. */
  102417. backgroundYRotation: number;
  102418. /**
  102419. * Compute automatically the size of the elements to best fit with the scene.
  102420. */
  102421. sizeAuto: boolean;
  102422. /**
  102423. * Default position of the rootMesh if autoSize is not true.
  102424. */
  102425. rootPosition: Vector3;
  102426. /**
  102427. * Sets up the image processing in the scene.
  102428. * true by default.
  102429. */
  102430. setupImageProcessing: boolean;
  102431. /**
  102432. * The texture used as your environment texture in the scene.
  102433. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  102434. *
  102435. * Remarks: Can be either a texture or a url.
  102436. */
  102437. environmentTexture: string | BaseTexture;
  102438. /**
  102439. * The value of the exposure to apply to the scene.
  102440. * 0.6 by default if setupImageProcessing is true.
  102441. */
  102442. cameraExposure: number;
  102443. /**
  102444. * The value of the contrast to apply to the scene.
  102445. * 1.6 by default if setupImageProcessing is true.
  102446. */
  102447. cameraContrast: number;
  102448. /**
  102449. * Specifies wether or not tonemapping should be enabled in the scene.
  102450. * true by default if setupImageProcessing is true.
  102451. */
  102452. toneMappingEnabled: boolean;
  102453. }
  102454. /**
  102455. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  102456. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  102457. * It also helps with the default setup of your imageProcessing configuration.
  102458. */
  102459. export class EnvironmentHelper {
  102460. /**
  102461. * Default ground texture URL.
  102462. */
  102463. private static _groundTextureCDNUrl;
  102464. /**
  102465. * Default skybox texture URL.
  102466. */
  102467. private static _skyboxTextureCDNUrl;
  102468. /**
  102469. * Default environment texture URL.
  102470. */
  102471. private static _environmentTextureCDNUrl;
  102472. /**
  102473. * Creates the default options for the helper.
  102474. */
  102475. private static _getDefaultOptions;
  102476. private _rootMesh;
  102477. /**
  102478. * Gets the root mesh created by the helper.
  102479. */
  102480. readonly rootMesh: Mesh;
  102481. private _skybox;
  102482. /**
  102483. * Gets the skybox created by the helper.
  102484. */
  102485. readonly skybox: Nullable<Mesh>;
  102486. private _skyboxTexture;
  102487. /**
  102488. * Gets the skybox texture created by the helper.
  102489. */
  102490. readonly skyboxTexture: Nullable<BaseTexture>;
  102491. private _skyboxMaterial;
  102492. /**
  102493. * Gets the skybox material created by the helper.
  102494. */
  102495. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  102496. private _ground;
  102497. /**
  102498. * Gets the ground mesh created by the helper.
  102499. */
  102500. readonly ground: Nullable<Mesh>;
  102501. private _groundTexture;
  102502. /**
  102503. * Gets the ground texture created by the helper.
  102504. */
  102505. readonly groundTexture: Nullable<BaseTexture>;
  102506. private _groundMirror;
  102507. /**
  102508. * Gets the ground mirror created by the helper.
  102509. */
  102510. readonly groundMirror: Nullable<MirrorTexture>;
  102511. /**
  102512. * Gets the ground mirror render list to helps pushing the meshes
  102513. * you wish in the ground reflection.
  102514. */
  102515. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  102516. private _groundMaterial;
  102517. /**
  102518. * Gets the ground material created by the helper.
  102519. */
  102520. readonly groundMaterial: Nullable<BackgroundMaterial>;
  102521. /**
  102522. * Stores the creation options.
  102523. */
  102524. private readonly _scene;
  102525. private _options;
  102526. /**
  102527. * This observable will be notified with any error during the creation of the environment,
  102528. * mainly texture creation errors.
  102529. */
  102530. onErrorObservable: Observable<{
  102531. message?: string;
  102532. exception?: any;
  102533. }>;
  102534. /**
  102535. * constructor
  102536. * @param options Defines the options we want to customize the helper
  102537. * @param scene The scene to add the material to
  102538. */
  102539. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  102540. /**
  102541. * Updates the background according to the new options
  102542. * @param options
  102543. */
  102544. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  102545. /**
  102546. * Sets the primary color of all the available elements.
  102547. * @param color the main color to affect to the ground and the background
  102548. */
  102549. setMainColor(color: Color3): void;
  102550. /**
  102551. * Setup the image processing according to the specified options.
  102552. */
  102553. private _setupImageProcessing;
  102554. /**
  102555. * Setup the environment texture according to the specified options.
  102556. */
  102557. private _setupEnvironmentTexture;
  102558. /**
  102559. * Setup the background according to the specified options.
  102560. */
  102561. private _setupBackground;
  102562. /**
  102563. * Get the scene sizes according to the setup.
  102564. */
  102565. private _getSceneSize;
  102566. /**
  102567. * Setup the ground according to the specified options.
  102568. */
  102569. private _setupGround;
  102570. /**
  102571. * Setup the ground material according to the specified options.
  102572. */
  102573. private _setupGroundMaterial;
  102574. /**
  102575. * Setup the ground diffuse texture according to the specified options.
  102576. */
  102577. private _setupGroundDiffuseTexture;
  102578. /**
  102579. * Setup the ground mirror texture according to the specified options.
  102580. */
  102581. private _setupGroundMirrorTexture;
  102582. /**
  102583. * Setup the ground to receive the mirror texture.
  102584. */
  102585. private _setupMirrorInGroundMaterial;
  102586. /**
  102587. * Setup the skybox according to the specified options.
  102588. */
  102589. private _setupSkybox;
  102590. /**
  102591. * Setup the skybox material according to the specified options.
  102592. */
  102593. private _setupSkyboxMaterial;
  102594. /**
  102595. * Setup the skybox reflection texture according to the specified options.
  102596. */
  102597. private _setupSkyboxReflectionTexture;
  102598. private _errorHandler;
  102599. /**
  102600. * Dispose all the elements created by the Helper.
  102601. */
  102602. dispose(): void;
  102603. }
  102604. }
  102605. declare module BABYLON {
  102606. /**
  102607. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  102608. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  102609. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  102610. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102611. */
  102612. export class PhotoDome extends TransformNode {
  102613. private _useDirectMapping;
  102614. /**
  102615. * The texture being displayed on the sphere
  102616. */
  102617. protected _photoTexture: Texture;
  102618. /**
  102619. * Gets or sets the texture being displayed on the sphere
  102620. */
  102621. photoTexture: Texture;
  102622. /**
  102623. * Observable raised when an error occured while loading the 360 image
  102624. */
  102625. onLoadErrorObservable: Observable<string>;
  102626. /**
  102627. * The skybox material
  102628. */
  102629. protected _material: BackgroundMaterial;
  102630. /**
  102631. * The surface used for the skybox
  102632. */
  102633. protected _mesh: Mesh;
  102634. /**
  102635. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102636. * Also see the options.resolution property.
  102637. */
  102638. fovMultiplier: number;
  102639. /**
  102640. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  102641. * @param name Element's name, child elements will append suffixes for their own names.
  102642. * @param urlsOfPhoto defines the url of the photo to display
  102643. * @param options defines an object containing optional or exposed sub element properties
  102644. * @param onError defines a callback called when an error occured while loading the texture
  102645. */
  102646. constructor(name: string, urlOfPhoto: string, options: {
  102647. resolution?: number;
  102648. size?: number;
  102649. useDirectMapping?: boolean;
  102650. faceForward?: boolean;
  102651. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  102652. /**
  102653. * Releases resources associated with this node.
  102654. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102655. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102656. */
  102657. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102658. }
  102659. }
  102660. declare module BABYLON {
  102661. /**
  102662. * Class used to host texture specific utilities
  102663. */
  102664. export class BRDFTextureTools {
  102665. /**
  102666. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  102667. * @param texture the texture to expand.
  102668. */
  102669. private static _ExpandDefaultBRDFTexture;
  102670. /**
  102671. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  102672. * @param scene defines the hosting scene
  102673. * @returns the environment BRDF texture
  102674. */
  102675. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  102676. private static _environmentBRDFBase64Texture;
  102677. }
  102678. }
  102679. declare module BABYLON {
  102680. /**
  102681. * @hidden
  102682. */
  102683. export interface IMaterialClearCoatDefines {
  102684. CLEARCOAT: boolean;
  102685. CLEARCOAT_DEFAULTIOR: boolean;
  102686. CLEARCOAT_TEXTURE: boolean;
  102687. CLEARCOAT_TEXTUREDIRECTUV: number;
  102688. CLEARCOAT_BUMP: boolean;
  102689. CLEARCOAT_BUMPDIRECTUV: number;
  102690. CLEARCOAT_TINT: boolean;
  102691. CLEARCOAT_TINT_TEXTURE: boolean;
  102692. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  102693. /** @hidden */
  102694. _areTexturesDirty: boolean;
  102695. }
  102696. /**
  102697. * Define the code related to the clear coat parameters of the pbr material.
  102698. */
  102699. export class PBRClearCoatConfiguration {
  102700. /**
  102701. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  102702. * The default fits with a polyurethane material.
  102703. */
  102704. private static readonly _DefaultIndiceOfRefraction;
  102705. private _isEnabled;
  102706. /**
  102707. * Defines if the clear coat is enabled in the material.
  102708. */
  102709. isEnabled: boolean;
  102710. /**
  102711. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  102712. */
  102713. intensity: number;
  102714. /**
  102715. * Defines the clear coat layer roughness.
  102716. */
  102717. roughness: number;
  102718. private _indiceOfRefraction;
  102719. /**
  102720. * Defines the indice of refraction of the clear coat.
  102721. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  102722. * The default fits with a polyurethane material.
  102723. * Changing the default value is more performance intensive.
  102724. */
  102725. indiceOfRefraction: number;
  102726. private _texture;
  102727. /**
  102728. * Stores the clear coat values in a texture.
  102729. */
  102730. texture: Nullable<BaseTexture>;
  102731. private _bumpTexture;
  102732. /**
  102733. * Define the clear coat specific bump texture.
  102734. */
  102735. bumpTexture: Nullable<BaseTexture>;
  102736. private _isTintEnabled;
  102737. /**
  102738. * Defines if the clear coat tint is enabled in the material.
  102739. */
  102740. isTintEnabled: boolean;
  102741. /**
  102742. * Defines if the clear coat tint is enabled in the material.
  102743. * This is only use if tint is enabled
  102744. */
  102745. tintColor: Color3;
  102746. /**
  102747. * Defines if the distance at which the tint color should be found in the
  102748. * clear coat media.
  102749. * This is only use if tint is enabled
  102750. */
  102751. tintColorAtDistance: number;
  102752. /**
  102753. * Defines the clear coat layer thickness.
  102754. * This is only use if tint is enabled
  102755. */
  102756. tintThickness: number;
  102757. private _tintTexture;
  102758. /**
  102759. * Stores the clear tint values in a texture.
  102760. * rgb is tint
  102761. * a is a thickness factor
  102762. */
  102763. tintTexture: Nullable<BaseTexture>;
  102764. /** @hidden */
  102765. private _internalMarkAllSubMeshesAsTexturesDirty;
  102766. /** @hidden */
  102767. _markAllSubMeshesAsTexturesDirty(): void;
  102768. /**
  102769. * Instantiate a new istance of clear coat configuration.
  102770. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  102771. */
  102772. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  102773. /**
  102774. * Specifies that the submesh is ready to be used.
  102775. * @param defines the list of "defines" to update.
  102776. * @param scene defines the scene the material belongs to.
  102777. * @param engine defines the engine the material belongs to.
  102778. * @param disableBumpMap defines wether the material disables bump or not.
  102779. * @returns - boolean indicating that the submesh is ready or not.
  102780. */
  102781. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  102782. /**
  102783. * Checks to see if a texture is used in the material.
  102784. * @param defines the list of "defines" to update.
  102785. * @param scene defines the scene to the material belongs to.
  102786. */
  102787. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  102788. /**
  102789. * Binds the material data.
  102790. * @param uniformBuffer defines the Uniform buffer to fill in.
  102791. * @param scene defines the scene the material belongs to.
  102792. * @param engine defines the engine the material belongs to.
  102793. * @param disableBumpMap defines wether the material disables bump or not.
  102794. * @param isFrozen defines wether the material is frozen or not.
  102795. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102796. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102797. */
  102798. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  102799. /**
  102800. * Checks to see if a texture is used in the material.
  102801. * @param texture - Base texture to use.
  102802. * @returns - Boolean specifying if a texture is used in the material.
  102803. */
  102804. hasTexture(texture: BaseTexture): boolean;
  102805. /**
  102806. * Returns an array of the actively used textures.
  102807. * @param activeTextures Array of BaseTextures
  102808. */
  102809. getActiveTextures(activeTextures: BaseTexture[]): void;
  102810. /**
  102811. * Returns the animatable textures.
  102812. * @param animatables Array of animatable textures.
  102813. */
  102814. getAnimatables(animatables: IAnimatable[]): void;
  102815. /**
  102816. * Disposes the resources of the material.
  102817. * @param forceDisposeTextures - Forces the disposal of all textures.
  102818. */
  102819. dispose(forceDisposeTextures?: boolean): void;
  102820. /**
  102821. * Get the current class name of the texture useful for serialization or dynamic coding.
  102822. * @returns "PBRClearCoatConfiguration"
  102823. */
  102824. getClassName(): string;
  102825. /**
  102826. * Add fallbacks to the effect fallbacks list.
  102827. * @param defines defines the Base texture to use.
  102828. * @param fallbacks defines the current fallback list.
  102829. * @param currentRank defines the current fallback rank.
  102830. * @returns the new fallback rank.
  102831. */
  102832. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  102833. /**
  102834. * Add the required uniforms to the current list.
  102835. * @param uniforms defines the current uniform list.
  102836. */
  102837. static AddUniforms(uniforms: string[]): void;
  102838. /**
  102839. * Add the required samplers to the current list.
  102840. * @param samplers defines the current sampler list.
  102841. */
  102842. static AddSamplers(samplers: string[]): void;
  102843. /**
  102844. * Add the required uniforms to the current buffer.
  102845. * @param uniformBuffer defines the current uniform buffer.
  102846. */
  102847. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  102848. /**
  102849. * Makes a duplicate of the current configuration into another one.
  102850. * @param clearCoatConfiguration define the config where to copy the info
  102851. */
  102852. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  102853. /**
  102854. * Serializes this clear coat configuration.
  102855. * @returns - An object with the serialized config.
  102856. */
  102857. serialize(): any;
  102858. /**
  102859. * Parses a Clear Coat Configuration from a serialized object.
  102860. * @param source - Serialized object.
  102861. */
  102862. parse(source: any): void;
  102863. }
  102864. }
  102865. declare module BABYLON {
  102866. /**
  102867. * @hidden
  102868. */
  102869. export interface IMaterialAnisotropicDefines {
  102870. ANISOTROPIC: boolean;
  102871. ANISOTROPIC_TEXTURE: boolean;
  102872. ANISOTROPIC_TEXTUREDIRECTUV: number;
  102873. MAINUV1: boolean;
  102874. _areTexturesDirty: boolean;
  102875. _needUVs: boolean;
  102876. }
  102877. /**
  102878. * Define the code related to the anisotropic parameters of the pbr material.
  102879. */
  102880. export class PBRAnisotropicConfiguration {
  102881. private _isEnabled;
  102882. /**
  102883. * Defines if the anisotropy is enabled in the material.
  102884. */
  102885. isEnabled: boolean;
  102886. /**
  102887. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  102888. */
  102889. intensity: number;
  102890. /**
  102891. * Defines if the effect is along the tangents, bitangents or in between.
  102892. * By default, the effect is "strectching" the highlights along the tangents.
  102893. */
  102894. direction: Vector2;
  102895. private _texture;
  102896. /**
  102897. * Stores the anisotropy values in a texture.
  102898. * rg is direction (like normal from -1 to 1)
  102899. * b is a intensity
  102900. */
  102901. texture: Nullable<BaseTexture>;
  102902. /** @hidden */
  102903. private _internalMarkAllSubMeshesAsTexturesDirty;
  102904. /** @hidden */
  102905. _markAllSubMeshesAsTexturesDirty(): void;
  102906. /**
  102907. * Instantiate a new istance of anisotropy configuration.
  102908. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  102909. */
  102910. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  102911. /**
  102912. * Specifies that the submesh is ready to be used.
  102913. * @param defines the list of "defines" to update.
  102914. * @param scene defines the scene the material belongs to.
  102915. * @returns - boolean indicating that the submesh is ready or not.
  102916. */
  102917. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  102918. /**
  102919. * Checks to see if a texture is used in the material.
  102920. * @param defines the list of "defines" to update.
  102921. * @param mesh the mesh we are preparing the defines for.
  102922. * @param scene defines the scene the material belongs to.
  102923. */
  102924. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  102925. /**
  102926. * Binds the material data.
  102927. * @param uniformBuffer defines the Uniform buffer to fill in.
  102928. * @param scene defines the scene the material belongs to.
  102929. * @param isFrozen defines wether the material is frozen or not.
  102930. */
  102931. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  102932. /**
  102933. * Checks to see if a texture is used in the material.
  102934. * @param texture - Base texture to use.
  102935. * @returns - Boolean specifying if a texture is used in the material.
  102936. */
  102937. hasTexture(texture: BaseTexture): boolean;
  102938. /**
  102939. * Returns an array of the actively used textures.
  102940. * @param activeTextures Array of BaseTextures
  102941. */
  102942. getActiveTextures(activeTextures: BaseTexture[]): void;
  102943. /**
  102944. * Returns the animatable textures.
  102945. * @param animatables Array of animatable textures.
  102946. */
  102947. getAnimatables(animatables: IAnimatable[]): void;
  102948. /**
  102949. * Disposes the resources of the material.
  102950. * @param forceDisposeTextures - Forces the disposal of all textures.
  102951. */
  102952. dispose(forceDisposeTextures?: boolean): void;
  102953. /**
  102954. * Get the current class name of the texture useful for serialization or dynamic coding.
  102955. * @returns "PBRAnisotropicConfiguration"
  102956. */
  102957. getClassName(): string;
  102958. /**
  102959. * Add fallbacks to the effect fallbacks list.
  102960. * @param defines defines the Base texture to use.
  102961. * @param fallbacks defines the current fallback list.
  102962. * @param currentRank defines the current fallback rank.
  102963. * @returns the new fallback rank.
  102964. */
  102965. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  102966. /**
  102967. * Add the required uniforms to the current list.
  102968. * @param uniforms defines the current uniform list.
  102969. */
  102970. static AddUniforms(uniforms: string[]): void;
  102971. /**
  102972. * Add the required uniforms to the current buffer.
  102973. * @param uniformBuffer defines the current uniform buffer.
  102974. */
  102975. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  102976. /**
  102977. * Add the required samplers to the current list.
  102978. * @param samplers defines the current sampler list.
  102979. */
  102980. static AddSamplers(samplers: string[]): void;
  102981. /**
  102982. * Makes a duplicate of the current configuration into another one.
  102983. * @param anisotropicConfiguration define the config where to copy the info
  102984. */
  102985. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  102986. /**
  102987. * Serializes this anisotropy configuration.
  102988. * @returns - An object with the serialized config.
  102989. */
  102990. serialize(): any;
  102991. /**
  102992. * Parses a anisotropy Configuration from a serialized object.
  102993. * @param source - Serialized object.
  102994. */
  102995. parse(source: any): void;
  102996. }
  102997. }
  102998. declare module BABYLON {
  102999. /**
  103000. * @hidden
  103001. */
  103002. export interface IMaterialBRDFDefines {
  103003. BRDF_V_HEIGHT_CORRELATED: boolean;
  103004. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103005. /** @hidden */
  103006. _areMiscDirty: boolean;
  103007. }
  103008. /**
  103009. * Define the code related to the BRDF parameters of the pbr material.
  103010. */
  103011. export class PBRBRDFConfiguration {
  103012. /**
  103013. * Default value used for the energy conservation.
  103014. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103015. */
  103016. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  103017. /**
  103018. * Default value used for the Smith Visibility Height Correlated mode.
  103019. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103020. */
  103021. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  103022. private _useEnergyConservation;
  103023. /**
  103024. * Defines if the material uses energy conservation.
  103025. */
  103026. useEnergyConservation: boolean;
  103027. private _useSmithVisibilityHeightCorrelated;
  103028. /**
  103029. * LEGACY Mode set to false
  103030. * Defines if the material uses height smith correlated visibility term.
  103031. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  103032. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103033. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  103034. * Not relying on height correlated will also disable energy conservation.
  103035. */
  103036. useSmithVisibilityHeightCorrelated: boolean;
  103037. /** @hidden */
  103038. private _internalMarkAllSubMeshesAsMiscDirty;
  103039. /** @hidden */
  103040. _markAllSubMeshesAsMiscDirty(): void;
  103041. /**
  103042. * Instantiate a new istance of clear coat configuration.
  103043. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  103044. */
  103045. constructor(markAllSubMeshesAsMiscDirty: () => void);
  103046. /**
  103047. * Checks to see if a texture is used in the material.
  103048. * @param defines the list of "defines" to update.
  103049. */
  103050. prepareDefines(defines: IMaterialBRDFDefines): void;
  103051. /**
  103052. * Get the current class name of the texture useful for serialization or dynamic coding.
  103053. * @returns "PBRClearCoatConfiguration"
  103054. */
  103055. getClassName(): string;
  103056. /**
  103057. * Makes a duplicate of the current configuration into another one.
  103058. * @param brdfConfiguration define the config where to copy the info
  103059. */
  103060. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  103061. /**
  103062. * Serializes this BRDF configuration.
  103063. * @returns - An object with the serialized config.
  103064. */
  103065. serialize(): any;
  103066. /**
  103067. * Parses a BRDF Configuration from a serialized object.
  103068. * @param source - Serialized object.
  103069. */
  103070. parse(source: any): void;
  103071. }
  103072. }
  103073. declare module BABYLON {
  103074. /**
  103075. * @hidden
  103076. */
  103077. export interface IMaterialSheenDefines {
  103078. SHEEN: boolean;
  103079. SHEEN_TEXTURE: boolean;
  103080. SHEEN_TEXTUREDIRECTUV: number;
  103081. SHEEN_LINKWITHALBEDO: boolean;
  103082. /** @hidden */
  103083. _areTexturesDirty: boolean;
  103084. }
  103085. /**
  103086. * Define the code related to the Sheen parameters of the pbr material.
  103087. */
  103088. export class PBRSheenConfiguration {
  103089. private _isEnabled;
  103090. /**
  103091. * Defines if the material uses sheen.
  103092. */
  103093. isEnabled: boolean;
  103094. private _linkSheenWithAlbedo;
  103095. /**
  103096. * Defines if the sheen is linked to the sheen color.
  103097. */
  103098. linkSheenWithAlbedo: boolean;
  103099. /**
  103100. * Defines the sheen intensity.
  103101. */
  103102. intensity: number;
  103103. /**
  103104. * Defines the sheen color.
  103105. */
  103106. color: Color3;
  103107. private _texture;
  103108. /**
  103109. * Stores the sheen tint values in a texture.
  103110. * rgb is tint
  103111. * a is a intensity
  103112. */
  103113. texture: Nullable<BaseTexture>;
  103114. /** @hidden */
  103115. private _internalMarkAllSubMeshesAsTexturesDirty;
  103116. /** @hidden */
  103117. _markAllSubMeshesAsTexturesDirty(): void;
  103118. /**
  103119. * Instantiate a new istance of clear coat configuration.
  103120. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103121. */
  103122. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103123. /**
  103124. * Specifies that the submesh is ready to be used.
  103125. * @param defines the list of "defines" to update.
  103126. * @param scene defines the scene the material belongs to.
  103127. * @returns - boolean indicating that the submesh is ready or not.
  103128. */
  103129. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  103130. /**
  103131. * Checks to see if a texture is used in the material.
  103132. * @param defines the list of "defines" to update.
  103133. * @param scene defines the scene the material belongs to.
  103134. */
  103135. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  103136. /**
  103137. * Binds the material data.
  103138. * @param uniformBuffer defines the Uniform buffer to fill in.
  103139. * @param scene defines the scene the material belongs to.
  103140. * @param isFrozen defines wether the material is frozen or not.
  103141. */
  103142. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103143. /**
  103144. * Checks to see if a texture is used in the material.
  103145. * @param texture - Base texture to use.
  103146. * @returns - Boolean specifying if a texture is used in the material.
  103147. */
  103148. hasTexture(texture: BaseTexture): boolean;
  103149. /**
  103150. * Returns an array of the actively used textures.
  103151. * @param activeTextures Array of BaseTextures
  103152. */
  103153. getActiveTextures(activeTextures: BaseTexture[]): void;
  103154. /**
  103155. * Returns the animatable textures.
  103156. * @param animatables Array of animatable textures.
  103157. */
  103158. getAnimatables(animatables: IAnimatable[]): void;
  103159. /**
  103160. * Disposes the resources of the material.
  103161. * @param forceDisposeTextures - Forces the disposal of all textures.
  103162. */
  103163. dispose(forceDisposeTextures?: boolean): void;
  103164. /**
  103165. * Get the current class name of the texture useful for serialization or dynamic coding.
  103166. * @returns "PBRSheenConfiguration"
  103167. */
  103168. getClassName(): string;
  103169. /**
  103170. * Add fallbacks to the effect fallbacks list.
  103171. * @param defines defines the Base texture to use.
  103172. * @param fallbacks defines the current fallback list.
  103173. * @param currentRank defines the current fallback rank.
  103174. * @returns the new fallback rank.
  103175. */
  103176. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103177. /**
  103178. * Add the required uniforms to the current list.
  103179. * @param uniforms defines the current uniform list.
  103180. */
  103181. static AddUniforms(uniforms: string[]): void;
  103182. /**
  103183. * Add the required uniforms to the current buffer.
  103184. * @param uniformBuffer defines the current uniform buffer.
  103185. */
  103186. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103187. /**
  103188. * Add the required samplers to the current list.
  103189. * @param samplers defines the current sampler list.
  103190. */
  103191. static AddSamplers(samplers: string[]): void;
  103192. /**
  103193. * Makes a duplicate of the current configuration into another one.
  103194. * @param sheenConfiguration define the config where to copy the info
  103195. */
  103196. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  103197. /**
  103198. * Serializes this BRDF configuration.
  103199. * @returns - An object with the serialized config.
  103200. */
  103201. serialize(): any;
  103202. /**
  103203. * Parses a Sheen Configuration from a serialized object.
  103204. * @param source - Serialized object.
  103205. */
  103206. parse(source: any): void;
  103207. }
  103208. }
  103209. declare module BABYLON {
  103210. /** @hidden */
  103211. export var pbrFragmentDeclaration: {
  103212. name: string;
  103213. shader: string;
  103214. };
  103215. }
  103216. declare module BABYLON {
  103217. /** @hidden */
  103218. export var pbrUboDeclaration: {
  103219. name: string;
  103220. shader: string;
  103221. };
  103222. }
  103223. declare module BABYLON {
  103224. /** @hidden */
  103225. export var pbrFragmentExtraDeclaration: {
  103226. name: string;
  103227. shader: string;
  103228. };
  103229. }
  103230. declare module BABYLON {
  103231. /** @hidden */
  103232. export var pbrFragmentSamplersDeclaration: {
  103233. name: string;
  103234. shader: string;
  103235. };
  103236. }
  103237. declare module BABYLON {
  103238. /** @hidden */
  103239. export var pbrHelperFunctions: {
  103240. name: string;
  103241. shader: string;
  103242. };
  103243. }
  103244. declare module BABYLON {
  103245. /** @hidden */
  103246. export var harmonicsFunctions: {
  103247. name: string;
  103248. shader: string;
  103249. };
  103250. }
  103251. declare module BABYLON {
  103252. /** @hidden */
  103253. export var pbrDirectLightingSetupFunctions: {
  103254. name: string;
  103255. shader: string;
  103256. };
  103257. }
  103258. declare module BABYLON {
  103259. /** @hidden */
  103260. export var pbrDirectLightingFalloffFunctions: {
  103261. name: string;
  103262. shader: string;
  103263. };
  103264. }
  103265. declare module BABYLON {
  103266. /** @hidden */
  103267. export var pbrBRDFFunctions: {
  103268. name: string;
  103269. shader: string;
  103270. };
  103271. }
  103272. declare module BABYLON {
  103273. /** @hidden */
  103274. export var pbrDirectLightingFunctions: {
  103275. name: string;
  103276. shader: string;
  103277. };
  103278. }
  103279. declare module BABYLON {
  103280. /** @hidden */
  103281. export var pbrIBLFunctions: {
  103282. name: string;
  103283. shader: string;
  103284. };
  103285. }
  103286. declare module BABYLON {
  103287. /** @hidden */
  103288. export var pbrDebug: {
  103289. name: string;
  103290. shader: string;
  103291. };
  103292. }
  103293. declare module BABYLON {
  103294. /** @hidden */
  103295. export var pbrPixelShader: {
  103296. name: string;
  103297. shader: string;
  103298. };
  103299. }
  103300. declare module BABYLON {
  103301. /** @hidden */
  103302. export var pbrVertexDeclaration: {
  103303. name: string;
  103304. shader: string;
  103305. };
  103306. }
  103307. declare module BABYLON {
  103308. /** @hidden */
  103309. export var pbrVertexShader: {
  103310. name: string;
  103311. shader: string;
  103312. };
  103313. }
  103314. declare module BABYLON {
  103315. /**
  103316. * Manages the defines for the PBR Material.
  103317. * @hidden
  103318. */
  103319. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines {
  103320. PBR: boolean;
  103321. MAINUV1: boolean;
  103322. MAINUV2: boolean;
  103323. UV1: boolean;
  103324. UV2: boolean;
  103325. ALBEDO: boolean;
  103326. ALBEDODIRECTUV: number;
  103327. VERTEXCOLOR: boolean;
  103328. AMBIENT: boolean;
  103329. AMBIENTDIRECTUV: number;
  103330. AMBIENTINGRAYSCALE: boolean;
  103331. OPACITY: boolean;
  103332. VERTEXALPHA: boolean;
  103333. OPACITYDIRECTUV: number;
  103334. OPACITYRGB: boolean;
  103335. ALPHATEST: boolean;
  103336. DEPTHPREPASS: boolean;
  103337. ALPHABLEND: boolean;
  103338. ALPHAFROMALBEDO: boolean;
  103339. ALPHATESTVALUE: string;
  103340. SPECULAROVERALPHA: boolean;
  103341. RADIANCEOVERALPHA: boolean;
  103342. ALPHAFRESNEL: boolean;
  103343. LINEARALPHAFRESNEL: boolean;
  103344. PREMULTIPLYALPHA: boolean;
  103345. EMISSIVE: boolean;
  103346. EMISSIVEDIRECTUV: number;
  103347. REFLECTIVITY: boolean;
  103348. REFLECTIVITYDIRECTUV: number;
  103349. SPECULARTERM: boolean;
  103350. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  103351. MICROSURFACEAUTOMATIC: boolean;
  103352. LODBASEDMICROSFURACE: boolean;
  103353. MICROSURFACEMAP: boolean;
  103354. MICROSURFACEMAPDIRECTUV: number;
  103355. METALLICWORKFLOW: boolean;
  103356. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  103357. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  103358. METALLNESSSTOREINMETALMAPBLUE: boolean;
  103359. AOSTOREINMETALMAPRED: boolean;
  103360. ENVIRONMENTBRDF: boolean;
  103361. ENVIRONMENTBRDF_RGBD: boolean;
  103362. NORMAL: boolean;
  103363. TANGENT: boolean;
  103364. BUMP: boolean;
  103365. BUMPDIRECTUV: number;
  103366. OBJECTSPACE_NORMALMAP: boolean;
  103367. PARALLAX: boolean;
  103368. PARALLAXOCCLUSION: boolean;
  103369. NORMALXYSCALE: boolean;
  103370. LIGHTMAP: boolean;
  103371. LIGHTMAPDIRECTUV: number;
  103372. USELIGHTMAPASSHADOWMAP: boolean;
  103373. GAMMALIGHTMAP: boolean;
  103374. REFLECTION: boolean;
  103375. REFLECTIONMAP_3D: boolean;
  103376. REFLECTIONMAP_SPHERICAL: boolean;
  103377. REFLECTIONMAP_PLANAR: boolean;
  103378. REFLECTIONMAP_CUBIC: boolean;
  103379. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103380. REFLECTIONMAP_PROJECTION: boolean;
  103381. REFLECTIONMAP_SKYBOX: boolean;
  103382. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103383. REFLECTIONMAP_EXPLICIT: boolean;
  103384. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103385. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103386. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103387. INVERTCUBICMAP: boolean;
  103388. USESPHERICALFROMREFLECTIONMAP: boolean;
  103389. USESPHERICALINVERTEX: boolean;
  103390. REFLECTIONMAP_OPPOSITEZ: boolean;
  103391. LODINREFLECTIONALPHA: boolean;
  103392. GAMMAREFLECTION: boolean;
  103393. RGBDREFLECTION: boolean;
  103394. RADIANCEOCCLUSION: boolean;
  103395. HORIZONOCCLUSION: boolean;
  103396. REFRACTION: boolean;
  103397. REFRACTIONMAP_3D: boolean;
  103398. REFRACTIONMAP_OPPOSITEZ: boolean;
  103399. LODINREFRACTIONALPHA: boolean;
  103400. GAMMAREFRACTION: boolean;
  103401. RGBDREFRACTION: boolean;
  103402. LINKREFRACTIONTOTRANSPARENCY: boolean;
  103403. INSTANCES: boolean;
  103404. NUM_BONE_INFLUENCERS: number;
  103405. BonesPerMesh: number;
  103406. BONETEXTURE: boolean;
  103407. NONUNIFORMSCALING: boolean;
  103408. MORPHTARGETS: boolean;
  103409. MORPHTARGETS_NORMAL: boolean;
  103410. MORPHTARGETS_TANGENT: boolean;
  103411. NUM_MORPH_INFLUENCERS: number;
  103412. IMAGEPROCESSING: boolean;
  103413. VIGNETTE: boolean;
  103414. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103415. VIGNETTEBLENDMODEOPAQUE: boolean;
  103416. TONEMAPPING: boolean;
  103417. TONEMAPPING_ACES: boolean;
  103418. CONTRAST: boolean;
  103419. COLORCURVES: boolean;
  103420. COLORGRADING: boolean;
  103421. COLORGRADING3D: boolean;
  103422. SAMPLER3DGREENDEPTH: boolean;
  103423. SAMPLER3DBGRMAP: boolean;
  103424. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103425. EXPOSURE: boolean;
  103426. MULTIVIEW: boolean;
  103427. USEPHYSICALLIGHTFALLOFF: boolean;
  103428. USEGLTFLIGHTFALLOFF: boolean;
  103429. TWOSIDEDLIGHTING: boolean;
  103430. SHADOWFLOAT: boolean;
  103431. CLIPPLANE: boolean;
  103432. CLIPPLANE2: boolean;
  103433. CLIPPLANE3: boolean;
  103434. CLIPPLANE4: boolean;
  103435. POINTSIZE: boolean;
  103436. FOG: boolean;
  103437. LOGARITHMICDEPTH: boolean;
  103438. FORCENORMALFORWARD: boolean;
  103439. SPECULARAA: boolean;
  103440. CLEARCOAT: boolean;
  103441. CLEARCOAT_DEFAULTIOR: boolean;
  103442. CLEARCOAT_TEXTURE: boolean;
  103443. CLEARCOAT_TEXTUREDIRECTUV: number;
  103444. CLEARCOAT_BUMP: boolean;
  103445. CLEARCOAT_BUMPDIRECTUV: number;
  103446. CLEARCOAT_TINT: boolean;
  103447. CLEARCOAT_TINT_TEXTURE: boolean;
  103448. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103449. ANISOTROPIC: boolean;
  103450. ANISOTROPIC_TEXTURE: boolean;
  103451. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103452. BRDF_V_HEIGHT_CORRELATED: boolean;
  103453. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103454. SHEEN: boolean;
  103455. SHEEN_TEXTURE: boolean;
  103456. SHEEN_TEXTUREDIRECTUV: number;
  103457. SHEEN_LINKWITHALBEDO: boolean;
  103458. UNLIT: boolean;
  103459. DEBUGMODE: number;
  103460. /**
  103461. * Initializes the PBR Material defines.
  103462. */
  103463. constructor();
  103464. /**
  103465. * Resets the PBR Material defines.
  103466. */
  103467. reset(): void;
  103468. }
  103469. /**
  103470. * The Physically based material base class of BJS.
  103471. *
  103472. * This offers the main features of a standard PBR material.
  103473. * For more information, please refer to the documentation :
  103474. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  103475. */
  103476. export abstract class PBRBaseMaterial extends PushMaterial {
  103477. /**
  103478. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103479. */
  103480. static readonly PBRMATERIAL_OPAQUE: number;
  103481. /**
  103482. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103483. */
  103484. static readonly PBRMATERIAL_ALPHATEST: number;
  103485. /**
  103486. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103487. */
  103488. static readonly PBRMATERIAL_ALPHABLEND: number;
  103489. /**
  103490. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103491. * They are also discarded below the alpha cutoff threshold to improve performances.
  103492. */
  103493. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  103494. /**
  103495. * Defines the default value of how much AO map is occluding the analytical lights
  103496. * (point spot...).
  103497. */
  103498. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  103499. /**
  103500. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  103501. */
  103502. static readonly LIGHTFALLOFF_PHYSICAL: number;
  103503. /**
  103504. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  103505. * to enhance interoperability with other engines.
  103506. */
  103507. static readonly LIGHTFALLOFF_GLTF: number;
  103508. /**
  103509. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  103510. * to enhance interoperability with other materials.
  103511. */
  103512. static readonly LIGHTFALLOFF_STANDARD: number;
  103513. /**
  103514. * Intensity of the direct lights e.g. the four lights available in your scene.
  103515. * This impacts both the direct diffuse and specular highlights.
  103516. */
  103517. protected _directIntensity: number;
  103518. /**
  103519. * Intensity of the emissive part of the material.
  103520. * This helps controlling the emissive effect without modifying the emissive color.
  103521. */
  103522. protected _emissiveIntensity: number;
  103523. /**
  103524. * Intensity of the environment e.g. how much the environment will light the object
  103525. * either through harmonics for rough material or through the refelction for shiny ones.
  103526. */
  103527. protected _environmentIntensity: number;
  103528. /**
  103529. * This is a special control allowing the reduction of the specular highlights coming from the
  103530. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  103531. */
  103532. protected _specularIntensity: number;
  103533. /**
  103534. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  103535. */
  103536. private _lightingInfos;
  103537. /**
  103538. * Debug Control allowing disabling the bump map on this material.
  103539. */
  103540. protected _disableBumpMap: boolean;
  103541. /**
  103542. * AKA Diffuse Texture in standard nomenclature.
  103543. */
  103544. protected _albedoTexture: BaseTexture;
  103545. /**
  103546. * AKA Occlusion Texture in other nomenclature.
  103547. */
  103548. protected _ambientTexture: BaseTexture;
  103549. /**
  103550. * AKA Occlusion Texture Intensity in other nomenclature.
  103551. */
  103552. protected _ambientTextureStrength: number;
  103553. /**
  103554. * Defines how much the AO map is occluding the analytical lights (point spot...).
  103555. * 1 means it completely occludes it
  103556. * 0 mean it has no impact
  103557. */
  103558. protected _ambientTextureImpactOnAnalyticalLights: number;
  103559. /**
  103560. * Stores the alpha values in a texture.
  103561. */
  103562. protected _opacityTexture: BaseTexture;
  103563. /**
  103564. * Stores the reflection values in a texture.
  103565. */
  103566. protected _reflectionTexture: BaseTexture;
  103567. /**
  103568. * Stores the refraction values in a texture.
  103569. */
  103570. protected _refractionTexture: BaseTexture;
  103571. /**
  103572. * Stores the emissive values in a texture.
  103573. */
  103574. protected _emissiveTexture: BaseTexture;
  103575. /**
  103576. * AKA Specular texture in other nomenclature.
  103577. */
  103578. protected _reflectivityTexture: BaseTexture;
  103579. /**
  103580. * Used to switch from specular/glossiness to metallic/roughness workflow.
  103581. */
  103582. protected _metallicTexture: BaseTexture;
  103583. /**
  103584. * Specifies the metallic scalar of the metallic/roughness workflow.
  103585. * Can also be used to scale the metalness values of the metallic texture.
  103586. */
  103587. protected _metallic: Nullable<number>;
  103588. /**
  103589. * Specifies the roughness scalar of the metallic/roughness workflow.
  103590. * Can also be used to scale the roughness values of the metallic texture.
  103591. */
  103592. protected _roughness: Nullable<number>;
  103593. /**
  103594. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  103595. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  103596. */
  103597. protected _microSurfaceTexture: BaseTexture;
  103598. /**
  103599. * Stores surface normal data used to displace a mesh in a texture.
  103600. */
  103601. protected _bumpTexture: BaseTexture;
  103602. /**
  103603. * Stores the pre-calculated light information of a mesh in a texture.
  103604. */
  103605. protected _lightmapTexture: BaseTexture;
  103606. /**
  103607. * The color of a material in ambient lighting.
  103608. */
  103609. protected _ambientColor: Color3;
  103610. /**
  103611. * AKA Diffuse Color in other nomenclature.
  103612. */
  103613. protected _albedoColor: Color3;
  103614. /**
  103615. * AKA Specular Color in other nomenclature.
  103616. */
  103617. protected _reflectivityColor: Color3;
  103618. /**
  103619. * The color applied when light is reflected from a material.
  103620. */
  103621. protected _reflectionColor: Color3;
  103622. /**
  103623. * The color applied when light is emitted from a material.
  103624. */
  103625. protected _emissiveColor: Color3;
  103626. /**
  103627. * AKA Glossiness in other nomenclature.
  103628. */
  103629. protected _microSurface: number;
  103630. /**
  103631. * source material index of refraction (IOR)' / 'destination material IOR.
  103632. */
  103633. protected _indexOfRefraction: number;
  103634. /**
  103635. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103636. */
  103637. protected _invertRefractionY: boolean;
  103638. /**
  103639. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103640. * Materials half opaque for instance using refraction could benefit from this control.
  103641. */
  103642. protected _linkRefractionWithTransparency: boolean;
  103643. /**
  103644. * Specifies that the material will use the light map as a show map.
  103645. */
  103646. protected _useLightmapAsShadowmap: boolean;
  103647. /**
  103648. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  103649. * makes the reflect vector face the model (under horizon).
  103650. */
  103651. protected _useHorizonOcclusion: boolean;
  103652. /**
  103653. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  103654. * too much the area relying on ambient texture to define their ambient occlusion.
  103655. */
  103656. protected _useRadianceOcclusion: boolean;
  103657. /**
  103658. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  103659. */
  103660. protected _useAlphaFromAlbedoTexture: boolean;
  103661. /**
  103662. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  103663. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103664. */
  103665. protected _useSpecularOverAlpha: boolean;
  103666. /**
  103667. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  103668. */
  103669. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  103670. /**
  103671. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  103672. */
  103673. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  103674. /**
  103675. * Specifies if the metallic texture contains the roughness information in its green channel.
  103676. */
  103677. protected _useRoughnessFromMetallicTextureGreen: boolean;
  103678. /**
  103679. * Specifies if the metallic texture contains the metallness information in its blue channel.
  103680. */
  103681. protected _useMetallnessFromMetallicTextureBlue: boolean;
  103682. /**
  103683. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  103684. */
  103685. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  103686. /**
  103687. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  103688. */
  103689. protected _useAmbientInGrayScale: boolean;
  103690. /**
  103691. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  103692. * The material will try to infer what glossiness each pixel should be.
  103693. */
  103694. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  103695. /**
  103696. * Defines the falloff type used in this material.
  103697. * It by default is Physical.
  103698. */
  103699. protected _lightFalloff: number;
  103700. /**
  103701. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103702. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103703. */
  103704. protected _useRadianceOverAlpha: boolean;
  103705. /**
  103706. * Allows using an object space normal map (instead of tangent space).
  103707. */
  103708. protected _useObjectSpaceNormalMap: boolean;
  103709. /**
  103710. * Allows using the bump map in parallax mode.
  103711. */
  103712. protected _useParallax: boolean;
  103713. /**
  103714. * Allows using the bump map in parallax occlusion mode.
  103715. */
  103716. protected _useParallaxOcclusion: boolean;
  103717. /**
  103718. * Controls the scale bias of the parallax mode.
  103719. */
  103720. protected _parallaxScaleBias: number;
  103721. /**
  103722. * If sets to true, disables all the lights affecting the material.
  103723. */
  103724. protected _disableLighting: boolean;
  103725. /**
  103726. * Number of Simultaneous lights allowed on the material.
  103727. */
  103728. protected _maxSimultaneousLights: number;
  103729. /**
  103730. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103731. */
  103732. protected _invertNormalMapX: boolean;
  103733. /**
  103734. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103735. */
  103736. protected _invertNormalMapY: boolean;
  103737. /**
  103738. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103739. */
  103740. protected _twoSidedLighting: boolean;
  103741. /**
  103742. * Defines the alpha limits in alpha test mode.
  103743. */
  103744. protected _alphaCutOff: number;
  103745. /**
  103746. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103747. */
  103748. protected _forceAlphaTest: boolean;
  103749. /**
  103750. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103751. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  103752. */
  103753. protected _useAlphaFresnel: boolean;
  103754. /**
  103755. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103756. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  103757. */
  103758. protected _useLinearAlphaFresnel: boolean;
  103759. /**
  103760. * The transparency mode of the material.
  103761. */
  103762. protected _transparencyMode: Nullable<number>;
  103763. /**
  103764. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  103765. * from cos thetav and roughness:
  103766. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  103767. */
  103768. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  103769. /**
  103770. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  103771. */
  103772. protected _forceIrradianceInFragment: boolean;
  103773. /**
  103774. * Force normal to face away from face.
  103775. */
  103776. protected _forceNormalForward: boolean;
  103777. /**
  103778. * Enables specular anti aliasing in the PBR shader.
  103779. * It will both interacts on the Geometry for analytical and IBL lighting.
  103780. * It also prefilter the roughness map based on the bump values.
  103781. */
  103782. protected _enableSpecularAntiAliasing: boolean;
  103783. /**
  103784. * Default configuration related to image processing available in the PBR Material.
  103785. */
  103786. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103787. /**
  103788. * Keep track of the image processing observer to allow dispose and replace.
  103789. */
  103790. private _imageProcessingObserver;
  103791. /**
  103792. * Attaches a new image processing configuration to the PBR Material.
  103793. * @param configuration
  103794. */
  103795. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103796. /**
  103797. * Stores the available render targets.
  103798. */
  103799. private _renderTargets;
  103800. /**
  103801. * Sets the global ambient color for the material used in lighting calculations.
  103802. */
  103803. private _globalAmbientColor;
  103804. /**
  103805. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  103806. */
  103807. private _useLogarithmicDepth;
  103808. /**
  103809. * If set to true, no lighting calculations will be applied.
  103810. */
  103811. private _unlit;
  103812. private _debugMode;
  103813. /**
  103814. * @hidden
  103815. * This is reserved for the inspector.
  103816. * Defines the material debug mode.
  103817. * It helps seeing only some components of the material while troubleshooting.
  103818. */
  103819. debugMode: number;
  103820. /**
  103821. * @hidden
  103822. * This is reserved for the inspector.
  103823. * Specify from where on screen the debug mode should start.
  103824. * The value goes from -1 (full screen) to 1 (not visible)
  103825. * It helps with side by side comparison against the final render
  103826. * This defaults to -1
  103827. */
  103828. private debugLimit;
  103829. /**
  103830. * @hidden
  103831. * This is reserved for the inspector.
  103832. * As the default viewing range might not be enough (if the ambient is really small for instance)
  103833. * You can use the factor to better multiply the final value.
  103834. */
  103835. private debugFactor;
  103836. /**
  103837. * Defines the clear coat layer parameters for the material.
  103838. */
  103839. readonly clearCoat: PBRClearCoatConfiguration;
  103840. /**
  103841. * Defines the anisotropic parameters for the material.
  103842. */
  103843. readonly anisotropy: PBRAnisotropicConfiguration;
  103844. /**
  103845. * Defines the BRDF parameters for the material.
  103846. */
  103847. readonly brdf: PBRBRDFConfiguration;
  103848. /**
  103849. * Defines the Sheen parameters for the material.
  103850. */
  103851. readonly sheen: PBRSheenConfiguration;
  103852. /**
  103853. * Custom callback helping to override the default shader used in the material.
  103854. */
  103855. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  103856. /**
  103857. * Instantiates a new PBRMaterial instance.
  103858. *
  103859. * @param name The material name
  103860. * @param scene The scene the material will be use in.
  103861. */
  103862. constructor(name: string, scene: Scene);
  103863. /**
  103864. * Gets a boolean indicating that current material needs to register RTT
  103865. */
  103866. readonly hasRenderTargetTextures: boolean;
  103867. /**
  103868. * Gets the name of the material class.
  103869. */
  103870. getClassName(): string;
  103871. /**
  103872. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  103873. */
  103874. /**
  103875. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  103876. */
  103877. useLogarithmicDepth: boolean;
  103878. /**
  103879. * Gets the current transparency mode.
  103880. */
  103881. /**
  103882. * Sets the transparency mode of the material.
  103883. *
  103884. * | Value | Type | Description |
  103885. * | ----- | ----------------------------------- | ----------- |
  103886. * | 0 | OPAQUE | |
  103887. * | 1 | ALPHATEST | |
  103888. * | 2 | ALPHABLEND | |
  103889. * | 3 | ALPHATESTANDBLEND | |
  103890. *
  103891. */
  103892. transparencyMode: Nullable<number>;
  103893. /**
  103894. * Returns true if alpha blending should be disabled.
  103895. */
  103896. private readonly _disableAlphaBlending;
  103897. /**
  103898. * Specifies whether or not this material should be rendered in alpha blend mode.
  103899. */
  103900. needAlphaBlending(): boolean;
  103901. /**
  103902. * Specifies if the mesh will require alpha blending.
  103903. * @param mesh - BJS mesh.
  103904. */
  103905. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  103906. /**
  103907. * Specifies whether or not this material should be rendered in alpha test mode.
  103908. */
  103909. needAlphaTesting(): boolean;
  103910. /**
  103911. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  103912. */
  103913. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  103914. /**
  103915. * Gets the texture used for the alpha test.
  103916. */
  103917. getAlphaTestTexture(): BaseTexture;
  103918. /**
  103919. * Specifies that the submesh is ready to be used.
  103920. * @param mesh - BJS mesh.
  103921. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  103922. * @param useInstances - Specifies that instances should be used.
  103923. * @returns - boolean indicating that the submesh is ready or not.
  103924. */
  103925. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103926. /**
  103927. * Specifies if the material uses metallic roughness workflow.
  103928. * @returns boolean specifiying if the material uses metallic roughness workflow.
  103929. */
  103930. isMetallicWorkflow(): boolean;
  103931. private _prepareEffect;
  103932. private _prepareDefines;
  103933. /**
  103934. * Force shader compilation
  103935. */
  103936. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  103937. clipPlane: boolean;
  103938. }>): void;
  103939. /**
  103940. * Initializes the uniform buffer layout for the shader.
  103941. */
  103942. buildUniformLayout(): void;
  103943. /**
  103944. * Unbinds the textures.
  103945. */
  103946. unbind(): void;
  103947. /**
  103948. * Binds the submesh data.
  103949. * @param world - The world matrix.
  103950. * @param mesh - The BJS mesh.
  103951. * @param subMesh - A submesh of the BJS mesh.
  103952. */
  103953. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103954. /**
  103955. * Returns the animatable textures.
  103956. * @returns - Array of animatable textures.
  103957. */
  103958. getAnimatables(): IAnimatable[];
  103959. /**
  103960. * Returns the texture used for reflections.
  103961. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  103962. */
  103963. private _getReflectionTexture;
  103964. /**
  103965. * Returns the texture used for refraction or null if none is used.
  103966. * @returns - Refection texture if present. If no refraction texture and refraction
  103967. * is linked with transparency, returns environment texture. Otherwise, returns null.
  103968. */
  103969. private _getRefractionTexture;
  103970. /**
  103971. * Returns an array of the actively used textures.
  103972. * @returns - Array of BaseTextures
  103973. */
  103974. getActiveTextures(): BaseTexture[];
  103975. /**
  103976. * Checks to see if a texture is used in the material.
  103977. * @param texture - Base texture to use.
  103978. * @returns - Boolean specifying if a texture is used in the material.
  103979. */
  103980. hasTexture(texture: BaseTexture): boolean;
  103981. /**
  103982. * Disposes the resources of the material.
  103983. * @param forceDisposeEffect - Forces the disposal of effects.
  103984. * @param forceDisposeTextures - Forces the disposal of all textures.
  103985. */
  103986. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103987. }
  103988. }
  103989. declare module BABYLON {
  103990. /**
  103991. * The Physically based material of BJS.
  103992. *
  103993. * This offers the main features of a standard PBR material.
  103994. * For more information, please refer to the documentation :
  103995. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  103996. */
  103997. export class PBRMaterial extends PBRBaseMaterial {
  103998. /**
  103999. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104000. */
  104001. static readonly PBRMATERIAL_OPAQUE: number;
  104002. /**
  104003. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104004. */
  104005. static readonly PBRMATERIAL_ALPHATEST: number;
  104006. /**
  104007. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104008. */
  104009. static readonly PBRMATERIAL_ALPHABLEND: number;
  104010. /**
  104011. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104012. * They are also discarded below the alpha cutoff threshold to improve performances.
  104013. */
  104014. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104015. /**
  104016. * Defines the default value of how much AO map is occluding the analytical lights
  104017. * (point spot...).
  104018. */
  104019. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104020. /**
  104021. * Intensity of the direct lights e.g. the four lights available in your scene.
  104022. * This impacts both the direct diffuse and specular highlights.
  104023. */
  104024. directIntensity: number;
  104025. /**
  104026. * Intensity of the emissive part of the material.
  104027. * This helps controlling the emissive effect without modifying the emissive color.
  104028. */
  104029. emissiveIntensity: number;
  104030. /**
  104031. * Intensity of the environment e.g. how much the environment will light the object
  104032. * either through harmonics for rough material or through the refelction for shiny ones.
  104033. */
  104034. environmentIntensity: number;
  104035. /**
  104036. * This is a special control allowing the reduction of the specular highlights coming from the
  104037. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104038. */
  104039. specularIntensity: number;
  104040. /**
  104041. * Debug Control allowing disabling the bump map on this material.
  104042. */
  104043. disableBumpMap: boolean;
  104044. /**
  104045. * AKA Diffuse Texture in standard nomenclature.
  104046. */
  104047. albedoTexture: BaseTexture;
  104048. /**
  104049. * AKA Occlusion Texture in other nomenclature.
  104050. */
  104051. ambientTexture: BaseTexture;
  104052. /**
  104053. * AKA Occlusion Texture Intensity in other nomenclature.
  104054. */
  104055. ambientTextureStrength: number;
  104056. /**
  104057. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104058. * 1 means it completely occludes it
  104059. * 0 mean it has no impact
  104060. */
  104061. ambientTextureImpactOnAnalyticalLights: number;
  104062. /**
  104063. * Stores the alpha values in a texture.
  104064. */
  104065. opacityTexture: BaseTexture;
  104066. /**
  104067. * Stores the reflection values in a texture.
  104068. */
  104069. reflectionTexture: Nullable<BaseTexture>;
  104070. /**
  104071. * Stores the emissive values in a texture.
  104072. */
  104073. emissiveTexture: BaseTexture;
  104074. /**
  104075. * AKA Specular texture in other nomenclature.
  104076. */
  104077. reflectivityTexture: BaseTexture;
  104078. /**
  104079. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104080. */
  104081. metallicTexture: BaseTexture;
  104082. /**
  104083. * Specifies the metallic scalar of the metallic/roughness workflow.
  104084. * Can also be used to scale the metalness values of the metallic texture.
  104085. */
  104086. metallic: Nullable<number>;
  104087. /**
  104088. * Specifies the roughness scalar of the metallic/roughness workflow.
  104089. * Can also be used to scale the roughness values of the metallic texture.
  104090. */
  104091. roughness: Nullable<number>;
  104092. /**
  104093. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104094. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104095. */
  104096. microSurfaceTexture: BaseTexture;
  104097. /**
  104098. * Stores surface normal data used to displace a mesh in a texture.
  104099. */
  104100. bumpTexture: BaseTexture;
  104101. /**
  104102. * Stores the pre-calculated light information of a mesh in a texture.
  104103. */
  104104. lightmapTexture: BaseTexture;
  104105. /**
  104106. * Stores the refracted light information in a texture.
  104107. */
  104108. refractionTexture: BaseTexture;
  104109. /**
  104110. * The color of a material in ambient lighting.
  104111. */
  104112. ambientColor: Color3;
  104113. /**
  104114. * AKA Diffuse Color in other nomenclature.
  104115. */
  104116. albedoColor: Color3;
  104117. /**
  104118. * AKA Specular Color in other nomenclature.
  104119. */
  104120. reflectivityColor: Color3;
  104121. /**
  104122. * The color reflected from the material.
  104123. */
  104124. reflectionColor: Color3;
  104125. /**
  104126. * The color emitted from the material.
  104127. */
  104128. emissiveColor: Color3;
  104129. /**
  104130. * AKA Glossiness in other nomenclature.
  104131. */
  104132. microSurface: number;
  104133. /**
  104134. * source material index of refraction (IOR)' / 'destination material IOR.
  104135. */
  104136. indexOfRefraction: number;
  104137. /**
  104138. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104139. */
  104140. invertRefractionY: boolean;
  104141. /**
  104142. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104143. * Materials half opaque for instance using refraction could benefit from this control.
  104144. */
  104145. linkRefractionWithTransparency: boolean;
  104146. /**
  104147. * If true, the light map contains occlusion information instead of lighting info.
  104148. */
  104149. useLightmapAsShadowmap: boolean;
  104150. /**
  104151. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104152. */
  104153. useAlphaFromAlbedoTexture: boolean;
  104154. /**
  104155. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104156. */
  104157. forceAlphaTest: boolean;
  104158. /**
  104159. * Defines the alpha limits in alpha test mode.
  104160. */
  104161. alphaCutOff: number;
  104162. /**
  104163. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104164. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104165. */
  104166. useSpecularOverAlpha: boolean;
  104167. /**
  104168. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104169. */
  104170. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104171. /**
  104172. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104173. */
  104174. useRoughnessFromMetallicTextureAlpha: boolean;
  104175. /**
  104176. * Specifies if the metallic texture contains the roughness information in its green channel.
  104177. */
  104178. useRoughnessFromMetallicTextureGreen: boolean;
  104179. /**
  104180. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104181. */
  104182. useMetallnessFromMetallicTextureBlue: boolean;
  104183. /**
  104184. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104185. */
  104186. useAmbientOcclusionFromMetallicTextureRed: boolean;
  104187. /**
  104188. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104189. */
  104190. useAmbientInGrayScale: boolean;
  104191. /**
  104192. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104193. * The material will try to infer what glossiness each pixel should be.
  104194. */
  104195. useAutoMicroSurfaceFromReflectivityMap: boolean;
  104196. /**
  104197. * BJS is using an harcoded light falloff based on a manually sets up range.
  104198. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104199. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104200. */
  104201. /**
  104202. * BJS is using an harcoded light falloff based on a manually sets up range.
  104203. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104204. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104205. */
  104206. usePhysicalLightFalloff: boolean;
  104207. /**
  104208. * In order to support the falloff compatibility with gltf, a special mode has been added
  104209. * to reproduce the gltf light falloff.
  104210. */
  104211. /**
  104212. * In order to support the falloff compatibility with gltf, a special mode has been added
  104213. * to reproduce the gltf light falloff.
  104214. */
  104215. useGLTFLightFalloff: boolean;
  104216. /**
  104217. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104218. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104219. */
  104220. useRadianceOverAlpha: boolean;
  104221. /**
  104222. * Allows using an object space normal map (instead of tangent space).
  104223. */
  104224. useObjectSpaceNormalMap: boolean;
  104225. /**
  104226. * Allows using the bump map in parallax mode.
  104227. */
  104228. useParallax: boolean;
  104229. /**
  104230. * Allows using the bump map in parallax occlusion mode.
  104231. */
  104232. useParallaxOcclusion: boolean;
  104233. /**
  104234. * Controls the scale bias of the parallax mode.
  104235. */
  104236. parallaxScaleBias: number;
  104237. /**
  104238. * If sets to true, disables all the lights affecting the material.
  104239. */
  104240. disableLighting: boolean;
  104241. /**
  104242. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104243. */
  104244. forceIrradianceInFragment: boolean;
  104245. /**
  104246. * Number of Simultaneous lights allowed on the material.
  104247. */
  104248. maxSimultaneousLights: number;
  104249. /**
  104250. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104251. */
  104252. invertNormalMapX: boolean;
  104253. /**
  104254. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104255. */
  104256. invertNormalMapY: boolean;
  104257. /**
  104258. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104259. */
  104260. twoSidedLighting: boolean;
  104261. /**
  104262. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104263. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104264. */
  104265. useAlphaFresnel: boolean;
  104266. /**
  104267. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104268. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104269. */
  104270. useLinearAlphaFresnel: boolean;
  104271. /**
  104272. * Let user defines the brdf lookup texture used for IBL.
  104273. * A default 8bit version is embedded but you could point at :
  104274. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  104275. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  104276. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104277. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  104278. */
  104279. environmentBRDFTexture: Nullable<BaseTexture>;
  104280. /**
  104281. * Force normal to face away from face.
  104282. */
  104283. forceNormalForward: boolean;
  104284. /**
  104285. * Enables specular anti aliasing in the PBR shader.
  104286. * It will both interacts on the Geometry for analytical and IBL lighting.
  104287. * It also prefilter the roughness map based on the bump values.
  104288. */
  104289. enableSpecularAntiAliasing: boolean;
  104290. /**
  104291. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104292. * makes the reflect vector face the model (under horizon).
  104293. */
  104294. useHorizonOcclusion: boolean;
  104295. /**
  104296. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104297. * too much the area relying on ambient texture to define their ambient occlusion.
  104298. */
  104299. useRadianceOcclusion: boolean;
  104300. /**
  104301. * If set to true, no lighting calculations will be applied.
  104302. */
  104303. unlit: boolean;
  104304. /**
  104305. * Gets the image processing configuration used either in this material.
  104306. */
  104307. /**
  104308. * Sets the Default image processing configuration used either in the this material.
  104309. *
  104310. * If sets to null, the scene one is in use.
  104311. */
  104312. imageProcessingConfiguration: ImageProcessingConfiguration;
  104313. /**
  104314. * Gets wether the color curves effect is enabled.
  104315. */
  104316. /**
  104317. * Sets wether the color curves effect is enabled.
  104318. */
  104319. cameraColorCurvesEnabled: boolean;
  104320. /**
  104321. * Gets wether the color grading effect is enabled.
  104322. */
  104323. /**
  104324. * Gets wether the color grading effect is enabled.
  104325. */
  104326. cameraColorGradingEnabled: boolean;
  104327. /**
  104328. * Gets wether tonemapping is enabled or not.
  104329. */
  104330. /**
  104331. * Sets wether tonemapping is enabled or not
  104332. */
  104333. cameraToneMappingEnabled: boolean;
  104334. /**
  104335. * The camera exposure used on this material.
  104336. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104337. * This corresponds to a photographic exposure.
  104338. */
  104339. /**
  104340. * The camera exposure used on this material.
  104341. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104342. * This corresponds to a photographic exposure.
  104343. */
  104344. cameraExposure: number;
  104345. /**
  104346. * Gets The camera contrast used on this material.
  104347. */
  104348. /**
  104349. * Sets The camera contrast used on this material.
  104350. */
  104351. cameraContrast: number;
  104352. /**
  104353. * Gets the Color Grading 2D Lookup Texture.
  104354. */
  104355. /**
  104356. * Sets the Color Grading 2D Lookup Texture.
  104357. */
  104358. cameraColorGradingTexture: Nullable<BaseTexture>;
  104359. /**
  104360. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104361. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104362. * 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;
  104363. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104364. */
  104365. /**
  104366. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104367. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104368. * 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;
  104369. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104370. */
  104371. cameraColorCurves: Nullable<ColorCurves>;
  104372. /**
  104373. * Instantiates a new PBRMaterial instance.
  104374. *
  104375. * @param name The material name
  104376. * @param scene The scene the material will be use in.
  104377. */
  104378. constructor(name: string, scene: Scene);
  104379. /**
  104380. * Returns the name of this material class.
  104381. */
  104382. getClassName(): string;
  104383. /**
  104384. * Makes a duplicate of the current material.
  104385. * @param name - name to use for the new material.
  104386. */
  104387. clone(name: string): PBRMaterial;
  104388. /**
  104389. * Serializes this PBR Material.
  104390. * @returns - An object with the serialized material.
  104391. */
  104392. serialize(): any;
  104393. /**
  104394. * Parses a PBR Material from a serialized object.
  104395. * @param source - Serialized object.
  104396. * @param scene - BJS scene instance.
  104397. * @param rootUrl - url for the scene object
  104398. * @returns - PBRMaterial
  104399. */
  104400. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  104401. }
  104402. }
  104403. declare module BABYLON {
  104404. /**
  104405. * Direct draw surface info
  104406. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  104407. */
  104408. export interface DDSInfo {
  104409. /**
  104410. * Width of the texture
  104411. */
  104412. width: number;
  104413. /**
  104414. * Width of the texture
  104415. */
  104416. height: number;
  104417. /**
  104418. * Number of Mipmaps for the texture
  104419. * @see https://en.wikipedia.org/wiki/Mipmap
  104420. */
  104421. mipmapCount: number;
  104422. /**
  104423. * If the textures format is a known fourCC format
  104424. * @see https://www.fourcc.org/
  104425. */
  104426. isFourCC: boolean;
  104427. /**
  104428. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  104429. */
  104430. isRGB: boolean;
  104431. /**
  104432. * If the texture is a lumincance format
  104433. */
  104434. isLuminance: boolean;
  104435. /**
  104436. * If this is a cube texture
  104437. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  104438. */
  104439. isCube: boolean;
  104440. /**
  104441. * If the texture is a compressed format eg. FOURCC_DXT1
  104442. */
  104443. isCompressed: boolean;
  104444. /**
  104445. * The dxgiFormat of the texture
  104446. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  104447. */
  104448. dxgiFormat: number;
  104449. /**
  104450. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  104451. */
  104452. textureType: number;
  104453. /**
  104454. * Sphericle polynomial created for the dds texture
  104455. */
  104456. sphericalPolynomial?: SphericalPolynomial;
  104457. }
  104458. /**
  104459. * Class used to provide DDS decompression tools
  104460. */
  104461. export class DDSTools {
  104462. /**
  104463. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  104464. */
  104465. static StoreLODInAlphaChannel: boolean;
  104466. /**
  104467. * Gets DDS information from an array buffer
  104468. * @param arrayBuffer defines the array buffer to read data from
  104469. * @returns the DDS information
  104470. */
  104471. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  104472. private static _FloatView;
  104473. private static _Int32View;
  104474. private static _ToHalfFloat;
  104475. private static _FromHalfFloat;
  104476. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  104477. private static _GetHalfFloatRGBAArrayBuffer;
  104478. private static _GetFloatRGBAArrayBuffer;
  104479. private static _GetFloatAsUIntRGBAArrayBuffer;
  104480. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  104481. private static _GetRGBAArrayBuffer;
  104482. private static _ExtractLongWordOrder;
  104483. private static _GetRGBArrayBuffer;
  104484. private static _GetLuminanceArrayBuffer;
  104485. /**
  104486. * Uploads DDS Levels to a Babylon Texture
  104487. * @hidden
  104488. */
  104489. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  104490. }
  104491. interface Engine {
  104492. /**
  104493. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  104494. * @param rootUrl defines the url where the file to load is located
  104495. * @param scene defines the current scene
  104496. * @param lodScale defines scale to apply to the mip map selection
  104497. * @param lodOffset defines offset to apply to the mip map selection
  104498. * @param onLoad defines an optional callback raised when the texture is loaded
  104499. * @param onError defines an optional callback raised if there is an issue to load the texture
  104500. * @param format defines the format of the data
  104501. * @param forcedExtension defines the extension to use to pick the right loader
  104502. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  104503. * @returns the cube texture as an InternalTexture
  104504. */
  104505. 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;
  104506. }
  104507. }
  104508. declare module BABYLON {
  104509. /**
  104510. * Implementation of the DDS Texture Loader.
  104511. * @hidden
  104512. */
  104513. export class _DDSTextureLoader implements IInternalTextureLoader {
  104514. /**
  104515. * Defines wether the loader supports cascade loading the different faces.
  104516. */
  104517. readonly supportCascades: boolean;
  104518. /**
  104519. * This returns if the loader support the current file information.
  104520. * @param extension defines the file extension of the file being loaded
  104521. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104522. * @param fallback defines the fallback internal texture if any
  104523. * @param isBase64 defines whether the texture is encoded as a base64
  104524. * @param isBuffer defines whether the texture data are stored as a buffer
  104525. * @returns true if the loader can load the specified file
  104526. */
  104527. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104528. /**
  104529. * Transform the url before loading if required.
  104530. * @param rootUrl the url of the texture
  104531. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104532. * @returns the transformed texture
  104533. */
  104534. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104535. /**
  104536. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104537. * @param rootUrl the url of the texture
  104538. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104539. * @returns the fallback texture
  104540. */
  104541. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104542. /**
  104543. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104544. * @param data contains the texture data
  104545. * @param texture defines the BabylonJS internal texture
  104546. * @param createPolynomials will be true if polynomials have been requested
  104547. * @param onLoad defines the callback to trigger once the texture is ready
  104548. * @param onError defines the callback to trigger in case of error
  104549. */
  104550. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104551. /**
  104552. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104553. * @param data contains the texture data
  104554. * @param texture defines the BabylonJS internal texture
  104555. * @param callback defines the method to call once ready to upload
  104556. */
  104557. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104558. }
  104559. }
  104560. declare module BABYLON {
  104561. /** @hidden */
  104562. export var rgbdEncodePixelShader: {
  104563. name: string;
  104564. shader: string;
  104565. };
  104566. }
  104567. declare module BABYLON {
  104568. /** @hidden */
  104569. export var rgbdDecodePixelShader: {
  104570. name: string;
  104571. shader: string;
  104572. };
  104573. }
  104574. declare module BABYLON {
  104575. /**
  104576. * Raw texture data and descriptor sufficient for WebGL texture upload
  104577. */
  104578. export interface EnvironmentTextureInfo {
  104579. /**
  104580. * Version of the environment map
  104581. */
  104582. version: number;
  104583. /**
  104584. * Width of image
  104585. */
  104586. width: number;
  104587. /**
  104588. * Irradiance information stored in the file.
  104589. */
  104590. irradiance: any;
  104591. /**
  104592. * Specular information stored in the file.
  104593. */
  104594. specular: any;
  104595. }
  104596. /**
  104597. * Sets of helpers addressing the serialization and deserialization of environment texture
  104598. * stored in a BabylonJS env file.
  104599. * Those files are usually stored as .env files.
  104600. */
  104601. export class EnvironmentTextureTools {
  104602. /**
  104603. * Magic number identifying the env file.
  104604. */
  104605. private static _MagicBytes;
  104606. /**
  104607. * Gets the environment info from an env file.
  104608. * @param data The array buffer containing the .env bytes.
  104609. * @returns the environment file info (the json header) if successfully parsed.
  104610. */
  104611. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  104612. /**
  104613. * Creates an environment texture from a loaded cube texture.
  104614. * @param texture defines the cube texture to convert in env file
  104615. * @return a promise containing the environment data if succesfull.
  104616. */
  104617. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  104618. /**
  104619. * Creates a JSON representation of the spherical data.
  104620. * @param texture defines the texture containing the polynomials
  104621. * @return the JSON representation of the spherical info
  104622. */
  104623. private static _CreateEnvTextureIrradiance;
  104624. /**
  104625. * Uploads the texture info contained in the env file to the GPU.
  104626. * @param texture defines the internal texture to upload to
  104627. * @param arrayBuffer defines the buffer cotaining the data to load
  104628. * @param info defines the texture info retrieved through the GetEnvInfo method
  104629. * @returns a promise
  104630. */
  104631. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  104632. /**
  104633. * Uploads the levels of image data to the GPU.
  104634. * @param texture defines the internal texture to upload to
  104635. * @param imageData defines the array buffer views of image data [mipmap][face]
  104636. * @returns a promise
  104637. */
  104638. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  104639. /**
  104640. * Uploads spherical polynomials information to the texture.
  104641. * @param texture defines the texture we are trying to upload the information to
  104642. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  104643. */
  104644. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  104645. /** @hidden */
  104646. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104647. }
  104648. }
  104649. declare module BABYLON {
  104650. /**
  104651. * Implementation of the ENV Texture Loader.
  104652. * @hidden
  104653. */
  104654. export class _ENVTextureLoader implements IInternalTextureLoader {
  104655. /**
  104656. * Defines wether the loader supports cascade loading the different faces.
  104657. */
  104658. readonly supportCascades: boolean;
  104659. /**
  104660. * This returns if the loader support the current file information.
  104661. * @param extension defines the file extension of the file being loaded
  104662. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104663. * @param fallback defines the fallback internal texture if any
  104664. * @param isBase64 defines whether the texture is encoded as a base64
  104665. * @param isBuffer defines whether the texture data are stored as a buffer
  104666. * @returns true if the loader can load the specified file
  104667. */
  104668. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104669. /**
  104670. * Transform the url before loading if required.
  104671. * @param rootUrl the url of the texture
  104672. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104673. * @returns the transformed texture
  104674. */
  104675. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104676. /**
  104677. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104678. * @param rootUrl the url of the texture
  104679. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104680. * @returns the fallback texture
  104681. */
  104682. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104683. /**
  104684. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104685. * @param data contains the texture data
  104686. * @param texture defines the BabylonJS internal texture
  104687. * @param createPolynomials will be true if polynomials have been requested
  104688. * @param onLoad defines the callback to trigger once the texture is ready
  104689. * @param onError defines the callback to trigger in case of error
  104690. */
  104691. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104692. /**
  104693. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104694. * @param data contains the texture data
  104695. * @param texture defines the BabylonJS internal texture
  104696. * @param callback defines the method to call once ready to upload
  104697. */
  104698. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104699. }
  104700. }
  104701. declare module BABYLON {
  104702. /**
  104703. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104704. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104705. */
  104706. export class KhronosTextureContainer {
  104707. /** contents of the KTX container file */
  104708. arrayBuffer: any;
  104709. private static HEADER_LEN;
  104710. private static COMPRESSED_2D;
  104711. private static COMPRESSED_3D;
  104712. private static TEX_2D;
  104713. private static TEX_3D;
  104714. /**
  104715. * Gets the openGL type
  104716. */
  104717. glType: number;
  104718. /**
  104719. * Gets the openGL type size
  104720. */
  104721. glTypeSize: number;
  104722. /**
  104723. * Gets the openGL format
  104724. */
  104725. glFormat: number;
  104726. /**
  104727. * Gets the openGL internal format
  104728. */
  104729. glInternalFormat: number;
  104730. /**
  104731. * Gets the base internal format
  104732. */
  104733. glBaseInternalFormat: number;
  104734. /**
  104735. * Gets image width in pixel
  104736. */
  104737. pixelWidth: number;
  104738. /**
  104739. * Gets image height in pixel
  104740. */
  104741. pixelHeight: number;
  104742. /**
  104743. * Gets image depth in pixels
  104744. */
  104745. pixelDepth: number;
  104746. /**
  104747. * Gets the number of array elements
  104748. */
  104749. numberOfArrayElements: number;
  104750. /**
  104751. * Gets the number of faces
  104752. */
  104753. numberOfFaces: number;
  104754. /**
  104755. * Gets the number of mipmap levels
  104756. */
  104757. numberOfMipmapLevels: number;
  104758. /**
  104759. * Gets the bytes of key value data
  104760. */
  104761. bytesOfKeyValueData: number;
  104762. /**
  104763. * Gets the load type
  104764. */
  104765. loadType: number;
  104766. /**
  104767. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  104768. */
  104769. isInvalid: boolean;
  104770. /**
  104771. * Creates a new KhronosTextureContainer
  104772. * @param arrayBuffer contents of the KTX container file
  104773. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  104774. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  104775. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  104776. */
  104777. constructor(
  104778. /** contents of the KTX container file */
  104779. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  104780. /**
  104781. * Uploads KTX content to a Babylon Texture.
  104782. * It is assumed that the texture has already been created & is currently bound
  104783. * @hidden
  104784. */
  104785. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  104786. private _upload2DCompressedLevels;
  104787. }
  104788. }
  104789. declare module BABYLON {
  104790. /**
  104791. * Implementation of the KTX Texture Loader.
  104792. * @hidden
  104793. */
  104794. export class _KTXTextureLoader implements IInternalTextureLoader {
  104795. /**
  104796. * Defines wether the loader supports cascade loading the different faces.
  104797. */
  104798. readonly supportCascades: boolean;
  104799. /**
  104800. * This returns if the loader support the current file information.
  104801. * @param extension defines the file extension of the file being loaded
  104802. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104803. * @param fallback defines the fallback internal texture if any
  104804. * @param isBase64 defines whether the texture is encoded as a base64
  104805. * @param isBuffer defines whether the texture data are stored as a buffer
  104806. * @returns true if the loader can load the specified file
  104807. */
  104808. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104809. /**
  104810. * Transform the url before loading if required.
  104811. * @param rootUrl the url of the texture
  104812. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104813. * @returns the transformed texture
  104814. */
  104815. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104816. /**
  104817. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104818. * @param rootUrl the url of the texture
  104819. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104820. * @returns the fallback texture
  104821. */
  104822. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104823. /**
  104824. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104825. * @param data contains the texture data
  104826. * @param texture defines the BabylonJS internal texture
  104827. * @param createPolynomials will be true if polynomials have been requested
  104828. * @param onLoad defines the callback to trigger once the texture is ready
  104829. * @param onError defines the callback to trigger in case of error
  104830. */
  104831. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104832. /**
  104833. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104834. * @param data contains the texture data
  104835. * @param texture defines the BabylonJS internal texture
  104836. * @param callback defines the method to call once ready to upload
  104837. */
  104838. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  104839. }
  104840. }
  104841. declare module BABYLON {
  104842. /** @hidden */
  104843. export var _forceSceneHelpersToBundle: boolean;
  104844. interface Scene {
  104845. /**
  104846. * Creates a default light for the scene.
  104847. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  104848. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  104849. */
  104850. createDefaultLight(replace?: boolean): void;
  104851. /**
  104852. * Creates a default camera for the scene.
  104853. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  104854. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  104855. * @param replace has default false, when true replaces the active camera in the scene
  104856. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  104857. */
  104858. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  104859. /**
  104860. * Creates a default camera and a default light.
  104861. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  104862. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  104863. * @param replace has the default false, when true replaces the active camera/light in the scene
  104864. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  104865. */
  104866. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  104867. /**
  104868. * Creates a new sky box
  104869. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  104870. * @param environmentTexture defines the texture to use as environment texture
  104871. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  104872. * @param scale defines the overall scale of the skybox
  104873. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  104874. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  104875. * @returns a new mesh holding the sky box
  104876. */
  104877. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  104878. /**
  104879. * Creates a new environment
  104880. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  104881. * @param options defines the options you can use to configure the environment
  104882. * @returns the new EnvironmentHelper
  104883. */
  104884. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  104885. /**
  104886. * Creates a new VREXperienceHelper
  104887. * @see http://doc.babylonjs.com/how_to/webvr_helper
  104888. * @param webVROptions defines the options used to create the new VREXperienceHelper
  104889. * @returns a new VREXperienceHelper
  104890. */
  104891. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  104892. /**
  104893. * Creates a new XREXperienceHelper
  104894. * @see http://doc.babylonjs.com/how_to/webxr
  104895. * @returns a promise for a new XREXperienceHelper
  104896. */
  104897. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  104898. }
  104899. }
  104900. declare module BABYLON {
  104901. /**
  104902. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  104903. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  104904. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  104905. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  104906. */
  104907. export class VideoDome extends TransformNode {
  104908. /**
  104909. * Define the video source as a Monoscopic panoramic 360 video.
  104910. */
  104911. static readonly MODE_MONOSCOPIC: number;
  104912. /**
  104913. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  104914. */
  104915. static readonly MODE_TOPBOTTOM: number;
  104916. /**
  104917. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  104918. */
  104919. static readonly MODE_SIDEBYSIDE: number;
  104920. private _useDirectMapping;
  104921. /**
  104922. * The video texture being displayed on the sphere
  104923. */
  104924. protected _videoTexture: VideoTexture;
  104925. /**
  104926. * Gets the video texture being displayed on the sphere
  104927. */
  104928. readonly videoTexture: VideoTexture;
  104929. /**
  104930. * The skybox material
  104931. */
  104932. protected _material: BackgroundMaterial;
  104933. /**
  104934. * The surface used for the skybox
  104935. */
  104936. protected _mesh: Mesh;
  104937. /**
  104938. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  104939. * Also see the options.resolution property.
  104940. */
  104941. fovMultiplier: number;
  104942. private _videoMode;
  104943. /**
  104944. * Gets or set the current video mode for the video. It can be:
  104945. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  104946. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  104947. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  104948. */
  104949. videoMode: number;
  104950. /**
  104951. * Oberserver used in Stereoscopic VR Mode.
  104952. */
  104953. private _onBeforeCameraRenderObserver;
  104954. /**
  104955. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  104956. * @param name Element's name, child elements will append suffixes for their own names.
  104957. * @param urlsOrVideo defines the url(s) or the video element to use
  104958. * @param options An object containing optional or exposed sub element properties
  104959. */
  104960. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  104961. resolution?: number;
  104962. clickToPlay?: boolean;
  104963. autoPlay?: boolean;
  104964. loop?: boolean;
  104965. size?: number;
  104966. poster?: string;
  104967. faceForward?: boolean;
  104968. useDirectMapping?: boolean;
  104969. }, scene: Scene);
  104970. private _changeVideoMode;
  104971. /**
  104972. * Releases resources associated with this node.
  104973. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  104974. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  104975. */
  104976. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  104977. }
  104978. }
  104979. declare module BABYLON {
  104980. /**
  104981. * This class can be used to get instrumentation data from a Babylon engine
  104982. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  104983. */
  104984. export class EngineInstrumentation implements IDisposable {
  104985. /**
  104986. * Define the instrumented engine.
  104987. */
  104988. engine: Engine;
  104989. private _captureGPUFrameTime;
  104990. private _gpuFrameTimeToken;
  104991. private _gpuFrameTime;
  104992. private _captureShaderCompilationTime;
  104993. private _shaderCompilationTime;
  104994. private _onBeginFrameObserver;
  104995. private _onEndFrameObserver;
  104996. private _onBeforeShaderCompilationObserver;
  104997. private _onAfterShaderCompilationObserver;
  104998. /**
  104999. * Gets the perf counter used for GPU frame time
  105000. */
  105001. readonly gpuFrameTimeCounter: PerfCounter;
  105002. /**
  105003. * Gets the GPU frame time capture status
  105004. */
  105005. /**
  105006. * Enable or disable the GPU frame time capture
  105007. */
  105008. captureGPUFrameTime: boolean;
  105009. /**
  105010. * Gets the perf counter used for shader compilation time
  105011. */
  105012. readonly shaderCompilationTimeCounter: PerfCounter;
  105013. /**
  105014. * Gets the shader compilation time capture status
  105015. */
  105016. /**
  105017. * Enable or disable the shader compilation time capture
  105018. */
  105019. captureShaderCompilationTime: boolean;
  105020. /**
  105021. * Instantiates a new engine instrumentation.
  105022. * This class can be used to get instrumentation data from a Babylon engine
  105023. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105024. * @param engine Defines the engine to instrument
  105025. */
  105026. constructor(
  105027. /**
  105028. * Define the instrumented engine.
  105029. */
  105030. engine: Engine);
  105031. /**
  105032. * Dispose and release associated resources.
  105033. */
  105034. dispose(): void;
  105035. }
  105036. }
  105037. declare module BABYLON {
  105038. /**
  105039. * This class can be used to get instrumentation data from a Babylon engine
  105040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105041. */
  105042. export class SceneInstrumentation implements IDisposable {
  105043. /**
  105044. * Defines the scene to instrument
  105045. */
  105046. scene: Scene;
  105047. private _captureActiveMeshesEvaluationTime;
  105048. private _activeMeshesEvaluationTime;
  105049. private _captureRenderTargetsRenderTime;
  105050. private _renderTargetsRenderTime;
  105051. private _captureFrameTime;
  105052. private _frameTime;
  105053. private _captureRenderTime;
  105054. private _renderTime;
  105055. private _captureInterFrameTime;
  105056. private _interFrameTime;
  105057. private _captureParticlesRenderTime;
  105058. private _particlesRenderTime;
  105059. private _captureSpritesRenderTime;
  105060. private _spritesRenderTime;
  105061. private _capturePhysicsTime;
  105062. private _physicsTime;
  105063. private _captureAnimationsTime;
  105064. private _animationsTime;
  105065. private _captureCameraRenderTime;
  105066. private _cameraRenderTime;
  105067. private _onBeforeActiveMeshesEvaluationObserver;
  105068. private _onAfterActiveMeshesEvaluationObserver;
  105069. private _onBeforeRenderTargetsRenderObserver;
  105070. private _onAfterRenderTargetsRenderObserver;
  105071. private _onAfterRenderObserver;
  105072. private _onBeforeDrawPhaseObserver;
  105073. private _onAfterDrawPhaseObserver;
  105074. private _onBeforeAnimationsObserver;
  105075. private _onBeforeParticlesRenderingObserver;
  105076. private _onAfterParticlesRenderingObserver;
  105077. private _onBeforeSpritesRenderingObserver;
  105078. private _onAfterSpritesRenderingObserver;
  105079. private _onBeforePhysicsObserver;
  105080. private _onAfterPhysicsObserver;
  105081. private _onAfterAnimationsObserver;
  105082. private _onBeforeCameraRenderObserver;
  105083. private _onAfterCameraRenderObserver;
  105084. /**
  105085. * Gets the perf counter used for active meshes evaluation time
  105086. */
  105087. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  105088. /**
  105089. * Gets the active meshes evaluation time capture status
  105090. */
  105091. /**
  105092. * Enable or disable the active meshes evaluation time capture
  105093. */
  105094. captureActiveMeshesEvaluationTime: boolean;
  105095. /**
  105096. * Gets the perf counter used for render targets render time
  105097. */
  105098. readonly renderTargetsRenderTimeCounter: PerfCounter;
  105099. /**
  105100. * Gets the render targets render time capture status
  105101. */
  105102. /**
  105103. * Enable or disable the render targets render time capture
  105104. */
  105105. captureRenderTargetsRenderTime: boolean;
  105106. /**
  105107. * Gets the perf counter used for particles render time
  105108. */
  105109. readonly particlesRenderTimeCounter: PerfCounter;
  105110. /**
  105111. * Gets the particles render time capture status
  105112. */
  105113. /**
  105114. * Enable or disable the particles render time capture
  105115. */
  105116. captureParticlesRenderTime: boolean;
  105117. /**
  105118. * Gets the perf counter used for sprites render time
  105119. */
  105120. readonly spritesRenderTimeCounter: PerfCounter;
  105121. /**
  105122. * Gets the sprites render time capture status
  105123. */
  105124. /**
  105125. * Enable or disable the sprites render time capture
  105126. */
  105127. captureSpritesRenderTime: boolean;
  105128. /**
  105129. * Gets the perf counter used for physics time
  105130. */
  105131. readonly physicsTimeCounter: PerfCounter;
  105132. /**
  105133. * Gets the physics time capture status
  105134. */
  105135. /**
  105136. * Enable or disable the physics time capture
  105137. */
  105138. capturePhysicsTime: boolean;
  105139. /**
  105140. * Gets the perf counter used for animations time
  105141. */
  105142. readonly animationsTimeCounter: PerfCounter;
  105143. /**
  105144. * Gets the animations time capture status
  105145. */
  105146. /**
  105147. * Enable or disable the animations time capture
  105148. */
  105149. captureAnimationsTime: boolean;
  105150. /**
  105151. * Gets the perf counter used for frame time capture
  105152. */
  105153. readonly frameTimeCounter: PerfCounter;
  105154. /**
  105155. * Gets the frame time capture status
  105156. */
  105157. /**
  105158. * Enable or disable the frame time capture
  105159. */
  105160. captureFrameTime: boolean;
  105161. /**
  105162. * Gets the perf counter used for inter-frames time capture
  105163. */
  105164. readonly interFrameTimeCounter: PerfCounter;
  105165. /**
  105166. * Gets the inter-frames time capture status
  105167. */
  105168. /**
  105169. * Enable or disable the inter-frames time capture
  105170. */
  105171. captureInterFrameTime: boolean;
  105172. /**
  105173. * Gets the perf counter used for render time capture
  105174. */
  105175. readonly renderTimeCounter: PerfCounter;
  105176. /**
  105177. * Gets the render time capture status
  105178. */
  105179. /**
  105180. * Enable or disable the render time capture
  105181. */
  105182. captureRenderTime: boolean;
  105183. /**
  105184. * Gets the perf counter used for camera render time capture
  105185. */
  105186. readonly cameraRenderTimeCounter: PerfCounter;
  105187. /**
  105188. * Gets the camera render time capture status
  105189. */
  105190. /**
  105191. * Enable or disable the camera render time capture
  105192. */
  105193. captureCameraRenderTime: boolean;
  105194. /**
  105195. * Gets the perf counter used for draw calls
  105196. */
  105197. readonly drawCallsCounter: PerfCounter;
  105198. /**
  105199. * Gets the perf counter used for texture collisions
  105200. */
  105201. readonly textureCollisionsCounter: PerfCounter;
  105202. /**
  105203. * Instantiates a new scene instrumentation.
  105204. * This class can be used to get instrumentation data from a Babylon engine
  105205. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105206. * @param scene Defines the scene to instrument
  105207. */
  105208. constructor(
  105209. /**
  105210. * Defines the scene to instrument
  105211. */
  105212. scene: Scene);
  105213. /**
  105214. * Dispose and release associated resources.
  105215. */
  105216. dispose(): void;
  105217. }
  105218. }
  105219. declare module BABYLON {
  105220. /** @hidden */
  105221. export var glowMapGenerationPixelShader: {
  105222. name: string;
  105223. shader: string;
  105224. };
  105225. }
  105226. declare module BABYLON {
  105227. /** @hidden */
  105228. export var glowMapGenerationVertexShader: {
  105229. name: string;
  105230. shader: string;
  105231. };
  105232. }
  105233. declare module BABYLON {
  105234. /**
  105235. * Effect layer options. This helps customizing the behaviour
  105236. * of the effect layer.
  105237. */
  105238. export interface IEffectLayerOptions {
  105239. /**
  105240. * Multiplication factor apply to the canvas size to compute the render target size
  105241. * used to generated the objects (the smaller the faster).
  105242. */
  105243. mainTextureRatio: number;
  105244. /**
  105245. * Enforces a fixed size texture to ensure effect stability across devices.
  105246. */
  105247. mainTextureFixedSize?: number;
  105248. /**
  105249. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  105250. */
  105251. alphaBlendingMode: number;
  105252. /**
  105253. * The camera attached to the layer.
  105254. */
  105255. camera: Nullable<Camera>;
  105256. /**
  105257. * The rendering group to draw the layer in.
  105258. */
  105259. renderingGroupId: number;
  105260. }
  105261. /**
  105262. * The effect layer Helps adding post process effect blended with the main pass.
  105263. *
  105264. * This can be for instance use to generate glow or higlight effects on the scene.
  105265. *
  105266. * The effect layer class can not be used directly and is intented to inherited from to be
  105267. * customized per effects.
  105268. */
  105269. export abstract class EffectLayer {
  105270. private _vertexBuffers;
  105271. private _indexBuffer;
  105272. private _cachedDefines;
  105273. private _effectLayerMapGenerationEffect;
  105274. private _effectLayerOptions;
  105275. private _mergeEffect;
  105276. protected _scene: Scene;
  105277. protected _engine: Engine;
  105278. protected _maxSize: number;
  105279. protected _mainTextureDesiredSize: ISize;
  105280. protected _mainTexture: RenderTargetTexture;
  105281. protected _shouldRender: boolean;
  105282. protected _postProcesses: PostProcess[];
  105283. protected _textures: BaseTexture[];
  105284. protected _emissiveTextureAndColor: {
  105285. texture: Nullable<BaseTexture>;
  105286. color: Color4;
  105287. };
  105288. /**
  105289. * The name of the layer
  105290. */
  105291. name: string;
  105292. /**
  105293. * The clear color of the texture used to generate the glow map.
  105294. */
  105295. neutralColor: Color4;
  105296. /**
  105297. * Specifies wether the highlight layer is enabled or not.
  105298. */
  105299. isEnabled: boolean;
  105300. /**
  105301. * Gets the camera attached to the layer.
  105302. */
  105303. readonly camera: Nullable<Camera>;
  105304. /**
  105305. * Gets the rendering group id the layer should render in.
  105306. */
  105307. readonly renderingGroupId: number;
  105308. /**
  105309. * An event triggered when the effect layer has been disposed.
  105310. */
  105311. onDisposeObservable: Observable<EffectLayer>;
  105312. /**
  105313. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  105314. */
  105315. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  105316. /**
  105317. * An event triggered when the generated texture is being merged in the scene.
  105318. */
  105319. onBeforeComposeObservable: Observable<EffectLayer>;
  105320. /**
  105321. * An event triggered when the generated texture has been merged in the scene.
  105322. */
  105323. onAfterComposeObservable: Observable<EffectLayer>;
  105324. /**
  105325. * An event triggered when the efffect layer changes its size.
  105326. */
  105327. onSizeChangedObservable: Observable<EffectLayer>;
  105328. /** @hidden */
  105329. static _SceneComponentInitialization: (scene: Scene) => void;
  105330. /**
  105331. * Instantiates a new effect Layer and references it in the scene.
  105332. * @param name The name of the layer
  105333. * @param scene The scene to use the layer in
  105334. */
  105335. constructor(
  105336. /** The Friendly of the effect in the scene */
  105337. name: string, scene: Scene);
  105338. /**
  105339. * Get the effect name of the layer.
  105340. * @return The effect name
  105341. */
  105342. abstract getEffectName(): string;
  105343. /**
  105344. * Checks for the readiness of the element composing the layer.
  105345. * @param subMesh the mesh to check for
  105346. * @param useInstances specify wether or not to use instances to render the mesh
  105347. * @return true if ready otherwise, false
  105348. */
  105349. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105350. /**
  105351. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105352. * @returns true if the effect requires stencil during the main canvas render pass.
  105353. */
  105354. abstract needStencil(): boolean;
  105355. /**
  105356. * Create the merge effect. This is the shader use to blit the information back
  105357. * to the main canvas at the end of the scene rendering.
  105358. * @returns The effect containing the shader used to merge the effect on the main canvas
  105359. */
  105360. protected abstract _createMergeEffect(): Effect;
  105361. /**
  105362. * Creates the render target textures and post processes used in the effect layer.
  105363. */
  105364. protected abstract _createTextureAndPostProcesses(): void;
  105365. /**
  105366. * Implementation specific of rendering the generating effect on the main canvas.
  105367. * @param effect The effect used to render through
  105368. */
  105369. protected abstract _internalRender(effect: Effect): void;
  105370. /**
  105371. * Sets the required values for both the emissive texture and and the main color.
  105372. */
  105373. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105374. /**
  105375. * Free any resources and references associated to a mesh.
  105376. * Internal use
  105377. * @param mesh The mesh to free.
  105378. */
  105379. abstract _disposeMesh(mesh: Mesh): void;
  105380. /**
  105381. * Serializes this layer (Glow or Highlight for example)
  105382. * @returns a serialized layer object
  105383. */
  105384. abstract serialize?(): any;
  105385. /**
  105386. * Initializes the effect layer with the required options.
  105387. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  105388. */
  105389. protected _init(options: Partial<IEffectLayerOptions>): void;
  105390. /**
  105391. * Generates the index buffer of the full screen quad blending to the main canvas.
  105392. */
  105393. private _generateIndexBuffer;
  105394. /**
  105395. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  105396. */
  105397. private _genrateVertexBuffer;
  105398. /**
  105399. * Sets the main texture desired size which is the closest power of two
  105400. * of the engine canvas size.
  105401. */
  105402. private _setMainTextureSize;
  105403. /**
  105404. * Creates the main texture for the effect layer.
  105405. */
  105406. protected _createMainTexture(): void;
  105407. /**
  105408. * Adds specific effects defines.
  105409. * @param defines The defines to add specifics to.
  105410. */
  105411. protected _addCustomEffectDefines(defines: string[]): void;
  105412. /**
  105413. * Checks for the readiness of the element composing the layer.
  105414. * @param subMesh the mesh to check for
  105415. * @param useInstances specify wether or not to use instances to render the mesh
  105416. * @param emissiveTexture the associated emissive texture used to generate the glow
  105417. * @return true if ready otherwise, false
  105418. */
  105419. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  105420. /**
  105421. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  105422. */
  105423. render(): void;
  105424. /**
  105425. * Determine if a given mesh will be used in the current effect.
  105426. * @param mesh mesh to test
  105427. * @returns true if the mesh will be used
  105428. */
  105429. hasMesh(mesh: AbstractMesh): boolean;
  105430. /**
  105431. * Returns true if the layer contains information to display, otherwise false.
  105432. * @returns true if the glow layer should be rendered
  105433. */
  105434. shouldRender(): boolean;
  105435. /**
  105436. * Returns true if the mesh should render, otherwise false.
  105437. * @param mesh The mesh to render
  105438. * @returns true if it should render otherwise false
  105439. */
  105440. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  105441. /**
  105442. * Returns true if the mesh can be rendered, otherwise false.
  105443. * @param mesh The mesh to render
  105444. * @param material The material used on the mesh
  105445. * @returns true if it can be rendered otherwise false
  105446. */
  105447. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  105448. /**
  105449. * Returns true if the mesh should render, otherwise false.
  105450. * @param mesh The mesh to render
  105451. * @returns true if it should render otherwise false
  105452. */
  105453. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  105454. /**
  105455. * Renders the submesh passed in parameter to the generation map.
  105456. */
  105457. protected _renderSubMesh(subMesh: SubMesh): void;
  105458. /**
  105459. * Rebuild the required buffers.
  105460. * @hidden Internal use only.
  105461. */
  105462. _rebuild(): void;
  105463. /**
  105464. * Dispose only the render target textures and post process.
  105465. */
  105466. private _disposeTextureAndPostProcesses;
  105467. /**
  105468. * Dispose the highlight layer and free resources.
  105469. */
  105470. dispose(): void;
  105471. /**
  105472. * Gets the class name of the effect layer
  105473. * @returns the string with the class name of the effect layer
  105474. */
  105475. getClassName(): string;
  105476. /**
  105477. * Creates an effect layer from parsed effect layer data
  105478. * @param parsedEffectLayer defines effect layer data
  105479. * @param scene defines the current scene
  105480. * @param rootUrl defines the root URL containing the effect layer information
  105481. * @returns a parsed effect Layer
  105482. */
  105483. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  105484. }
  105485. }
  105486. declare module BABYLON {
  105487. interface AbstractScene {
  105488. /**
  105489. * The list of effect layers (highlights/glow) added to the scene
  105490. * @see http://doc.babylonjs.com/how_to/highlight_layer
  105491. * @see http://doc.babylonjs.com/how_to/glow_layer
  105492. */
  105493. effectLayers: Array<EffectLayer>;
  105494. /**
  105495. * Removes the given effect layer from this scene.
  105496. * @param toRemove defines the effect layer to remove
  105497. * @returns the index of the removed effect layer
  105498. */
  105499. removeEffectLayer(toRemove: EffectLayer): number;
  105500. /**
  105501. * Adds the given effect layer to this scene
  105502. * @param newEffectLayer defines the effect layer to add
  105503. */
  105504. addEffectLayer(newEffectLayer: EffectLayer): void;
  105505. }
  105506. /**
  105507. * Defines the layer scene component responsible to manage any effect layers
  105508. * in a given scene.
  105509. */
  105510. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  105511. /**
  105512. * The component name helpfull to identify the component in the list of scene components.
  105513. */
  105514. readonly name: string;
  105515. /**
  105516. * The scene the component belongs to.
  105517. */
  105518. scene: Scene;
  105519. private _engine;
  105520. private _renderEffects;
  105521. private _needStencil;
  105522. private _previousStencilState;
  105523. /**
  105524. * Creates a new instance of the component for the given scene
  105525. * @param scene Defines the scene to register the component in
  105526. */
  105527. constructor(scene: Scene);
  105528. /**
  105529. * Registers the component in a given scene
  105530. */
  105531. register(): void;
  105532. /**
  105533. * Rebuilds the elements related to this component in case of
  105534. * context lost for instance.
  105535. */
  105536. rebuild(): void;
  105537. /**
  105538. * Serializes the component data to the specified json object
  105539. * @param serializationObject The object to serialize to
  105540. */
  105541. serialize(serializationObject: any): void;
  105542. /**
  105543. * Adds all the element from the container to the scene
  105544. * @param container the container holding the elements
  105545. */
  105546. addFromContainer(container: AbstractScene): void;
  105547. /**
  105548. * Removes all the elements in the container from the scene
  105549. * @param container contains the elements to remove
  105550. * @param dispose if the removed element should be disposed (default: false)
  105551. */
  105552. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  105553. /**
  105554. * Disposes the component and the associated ressources.
  105555. */
  105556. dispose(): void;
  105557. private _isReadyForMesh;
  105558. private _renderMainTexture;
  105559. private _setStencil;
  105560. private _setStencilBack;
  105561. private _draw;
  105562. private _drawCamera;
  105563. private _drawRenderingGroup;
  105564. }
  105565. }
  105566. declare module BABYLON {
  105567. /** @hidden */
  105568. export var glowMapMergePixelShader: {
  105569. name: string;
  105570. shader: string;
  105571. };
  105572. }
  105573. declare module BABYLON {
  105574. /** @hidden */
  105575. export var glowMapMergeVertexShader: {
  105576. name: string;
  105577. shader: string;
  105578. };
  105579. }
  105580. declare module BABYLON {
  105581. interface AbstractScene {
  105582. /**
  105583. * Return a the first highlight layer of the scene with a given name.
  105584. * @param name The name of the highlight layer to look for.
  105585. * @return The highlight layer if found otherwise null.
  105586. */
  105587. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  105588. }
  105589. /**
  105590. * Glow layer options. This helps customizing the behaviour
  105591. * of the glow layer.
  105592. */
  105593. export interface IGlowLayerOptions {
  105594. /**
  105595. * Multiplication factor apply to the canvas size to compute the render target size
  105596. * used to generated the glowing objects (the smaller the faster).
  105597. */
  105598. mainTextureRatio: number;
  105599. /**
  105600. * Enforces a fixed size texture to ensure resize independant blur.
  105601. */
  105602. mainTextureFixedSize?: number;
  105603. /**
  105604. * How big is the kernel of the blur texture.
  105605. */
  105606. blurKernelSize: number;
  105607. /**
  105608. * The camera attached to the layer.
  105609. */
  105610. camera: Nullable<Camera>;
  105611. /**
  105612. * Enable MSAA by chosing the number of samples.
  105613. */
  105614. mainTextureSamples?: number;
  105615. /**
  105616. * The rendering group to draw the layer in.
  105617. */
  105618. renderingGroupId: number;
  105619. }
  105620. /**
  105621. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  105622. *
  105623. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  105624. * glowy meshes to your scene.
  105625. *
  105626. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  105627. */
  105628. export class GlowLayer extends EffectLayer {
  105629. /**
  105630. * Effect Name of the layer.
  105631. */
  105632. static readonly EffectName: string;
  105633. /**
  105634. * The default blur kernel size used for the glow.
  105635. */
  105636. static DefaultBlurKernelSize: number;
  105637. /**
  105638. * The default texture size ratio used for the glow.
  105639. */
  105640. static DefaultTextureRatio: number;
  105641. /**
  105642. * Sets the kernel size of the blur.
  105643. */
  105644. /**
  105645. * Gets the kernel size of the blur.
  105646. */
  105647. blurKernelSize: number;
  105648. /**
  105649. * Sets the glow intensity.
  105650. */
  105651. /**
  105652. * Gets the glow intensity.
  105653. */
  105654. intensity: number;
  105655. private _options;
  105656. private _intensity;
  105657. private _horizontalBlurPostprocess1;
  105658. private _verticalBlurPostprocess1;
  105659. private _horizontalBlurPostprocess2;
  105660. private _verticalBlurPostprocess2;
  105661. private _blurTexture1;
  105662. private _blurTexture2;
  105663. private _postProcesses1;
  105664. private _postProcesses2;
  105665. private _includedOnlyMeshes;
  105666. private _excludedMeshes;
  105667. /**
  105668. * Callback used to let the user override the color selection on a per mesh basis
  105669. */
  105670. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  105671. /**
  105672. * Callback used to let the user override the texture selection on a per mesh basis
  105673. */
  105674. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  105675. /**
  105676. * Instantiates a new glow Layer and references it to the scene.
  105677. * @param name The name of the layer
  105678. * @param scene The scene to use the layer in
  105679. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  105680. */
  105681. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  105682. /**
  105683. * Get the effect name of the layer.
  105684. * @return The effect name
  105685. */
  105686. getEffectName(): string;
  105687. /**
  105688. * Create the merge effect. This is the shader use to blit the information back
  105689. * to the main canvas at the end of the scene rendering.
  105690. */
  105691. protected _createMergeEffect(): Effect;
  105692. /**
  105693. * Creates the render target textures and post processes used in the glow layer.
  105694. */
  105695. protected _createTextureAndPostProcesses(): void;
  105696. /**
  105697. * Checks for the readiness of the element composing the layer.
  105698. * @param subMesh the mesh to check for
  105699. * @param useInstances specify wether or not to use instances to render the mesh
  105700. * @param emissiveTexture the associated emissive texture used to generate the glow
  105701. * @return true if ready otherwise, false
  105702. */
  105703. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105704. /**
  105705. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105706. */
  105707. needStencil(): boolean;
  105708. /**
  105709. * Returns true if the mesh can be rendered, otherwise false.
  105710. * @param mesh The mesh to render
  105711. * @param material The material used on the mesh
  105712. * @returns true if it can be rendered otherwise false
  105713. */
  105714. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  105715. /**
  105716. * Implementation specific of rendering the generating effect on the main canvas.
  105717. * @param effect The effect used to render through
  105718. */
  105719. protected _internalRender(effect: Effect): void;
  105720. /**
  105721. * Sets the required values for both the emissive texture and and the main color.
  105722. */
  105723. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105724. /**
  105725. * Returns true if the mesh should render, otherwise false.
  105726. * @param mesh The mesh to render
  105727. * @returns true if it should render otherwise false
  105728. */
  105729. protected _shouldRenderMesh(mesh: Mesh): boolean;
  105730. /**
  105731. * Adds specific effects defines.
  105732. * @param defines The defines to add specifics to.
  105733. */
  105734. protected _addCustomEffectDefines(defines: string[]): void;
  105735. /**
  105736. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  105737. * @param mesh The mesh to exclude from the glow layer
  105738. */
  105739. addExcludedMesh(mesh: Mesh): void;
  105740. /**
  105741. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  105742. * @param mesh The mesh to remove
  105743. */
  105744. removeExcludedMesh(mesh: Mesh): void;
  105745. /**
  105746. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  105747. * @param mesh The mesh to include in the glow layer
  105748. */
  105749. addIncludedOnlyMesh(mesh: Mesh): void;
  105750. /**
  105751. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  105752. * @param mesh The mesh to remove
  105753. */
  105754. removeIncludedOnlyMesh(mesh: Mesh): void;
  105755. /**
  105756. * Determine if a given mesh will be used in the glow layer
  105757. * @param mesh The mesh to test
  105758. * @returns true if the mesh will be highlighted by the current glow layer
  105759. */
  105760. hasMesh(mesh: AbstractMesh): boolean;
  105761. /**
  105762. * Free any resources and references associated to a mesh.
  105763. * Internal use
  105764. * @param mesh The mesh to free.
  105765. * @hidden
  105766. */
  105767. _disposeMesh(mesh: Mesh): void;
  105768. /**
  105769. * Gets the class name of the effect layer
  105770. * @returns the string with the class name of the effect layer
  105771. */
  105772. getClassName(): string;
  105773. /**
  105774. * Serializes this glow layer
  105775. * @returns a serialized glow layer object
  105776. */
  105777. serialize(): any;
  105778. /**
  105779. * Creates a Glow Layer from parsed glow layer data
  105780. * @param parsedGlowLayer defines glow layer data
  105781. * @param scene defines the current scene
  105782. * @param rootUrl defines the root URL containing the glow layer information
  105783. * @returns a parsed Glow Layer
  105784. */
  105785. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  105786. }
  105787. }
  105788. declare module BABYLON {
  105789. /** @hidden */
  105790. export var glowBlurPostProcessPixelShader: {
  105791. name: string;
  105792. shader: string;
  105793. };
  105794. }
  105795. declare module BABYLON {
  105796. interface AbstractScene {
  105797. /**
  105798. * Return a the first highlight layer of the scene with a given name.
  105799. * @param name The name of the highlight layer to look for.
  105800. * @return The highlight layer if found otherwise null.
  105801. */
  105802. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  105803. }
  105804. /**
  105805. * Highlight layer options. This helps customizing the behaviour
  105806. * of the highlight layer.
  105807. */
  105808. export interface IHighlightLayerOptions {
  105809. /**
  105810. * Multiplication factor apply to the canvas size to compute the render target size
  105811. * used to generated the glowing objects (the smaller the faster).
  105812. */
  105813. mainTextureRatio: number;
  105814. /**
  105815. * Enforces a fixed size texture to ensure resize independant blur.
  105816. */
  105817. mainTextureFixedSize?: number;
  105818. /**
  105819. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  105820. * of the picture to blur (the smaller the faster).
  105821. */
  105822. blurTextureSizeRatio: number;
  105823. /**
  105824. * How big in texel of the blur texture is the vertical blur.
  105825. */
  105826. blurVerticalSize: number;
  105827. /**
  105828. * How big in texel of the blur texture is the horizontal blur.
  105829. */
  105830. blurHorizontalSize: number;
  105831. /**
  105832. * Alpha blending mode used to apply the blur. Default is combine.
  105833. */
  105834. alphaBlendingMode: number;
  105835. /**
  105836. * The camera attached to the layer.
  105837. */
  105838. camera: Nullable<Camera>;
  105839. /**
  105840. * Should we display highlight as a solid stroke?
  105841. */
  105842. isStroke?: boolean;
  105843. /**
  105844. * The rendering group to draw the layer in.
  105845. */
  105846. renderingGroupId: number;
  105847. }
  105848. /**
  105849. * The highlight layer Helps adding a glow effect around a mesh.
  105850. *
  105851. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  105852. * glowy meshes to your scene.
  105853. *
  105854. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  105855. */
  105856. export class HighlightLayer extends EffectLayer {
  105857. name: string;
  105858. /**
  105859. * Effect Name of the highlight layer.
  105860. */
  105861. static readonly EffectName: string;
  105862. /**
  105863. * The neutral color used during the preparation of the glow effect.
  105864. * This is black by default as the blend operation is a blend operation.
  105865. */
  105866. static NeutralColor: Color4;
  105867. /**
  105868. * Stencil value used for glowing meshes.
  105869. */
  105870. static GlowingMeshStencilReference: number;
  105871. /**
  105872. * Stencil value used for the other meshes in the scene.
  105873. */
  105874. static NormalMeshStencilReference: number;
  105875. /**
  105876. * Specifies whether or not the inner glow is ACTIVE in the layer.
  105877. */
  105878. innerGlow: boolean;
  105879. /**
  105880. * Specifies whether or not the outer glow is ACTIVE in the layer.
  105881. */
  105882. outerGlow: boolean;
  105883. /**
  105884. * Specifies the horizontal size of the blur.
  105885. */
  105886. /**
  105887. * Gets the horizontal size of the blur.
  105888. */
  105889. blurHorizontalSize: number;
  105890. /**
  105891. * Specifies the vertical size of the blur.
  105892. */
  105893. /**
  105894. * Gets the vertical size of the blur.
  105895. */
  105896. blurVerticalSize: number;
  105897. /**
  105898. * An event triggered when the highlight layer is being blurred.
  105899. */
  105900. onBeforeBlurObservable: Observable<HighlightLayer>;
  105901. /**
  105902. * An event triggered when the highlight layer has been blurred.
  105903. */
  105904. onAfterBlurObservable: Observable<HighlightLayer>;
  105905. private _instanceGlowingMeshStencilReference;
  105906. private _options;
  105907. private _downSamplePostprocess;
  105908. private _horizontalBlurPostprocess;
  105909. private _verticalBlurPostprocess;
  105910. private _blurTexture;
  105911. private _meshes;
  105912. private _excludedMeshes;
  105913. /**
  105914. * Instantiates a new highlight Layer and references it to the scene..
  105915. * @param name The name of the layer
  105916. * @param scene The scene to use the layer in
  105917. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  105918. */
  105919. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  105920. /**
  105921. * Get the effect name of the layer.
  105922. * @return The effect name
  105923. */
  105924. getEffectName(): string;
  105925. /**
  105926. * Create the merge effect. This is the shader use to blit the information back
  105927. * to the main canvas at the end of the scene rendering.
  105928. */
  105929. protected _createMergeEffect(): Effect;
  105930. /**
  105931. * Creates the render target textures and post processes used in the highlight layer.
  105932. */
  105933. protected _createTextureAndPostProcesses(): void;
  105934. /**
  105935. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105936. */
  105937. needStencil(): boolean;
  105938. /**
  105939. * Checks for the readiness of the element composing the layer.
  105940. * @param subMesh the mesh to check for
  105941. * @param useInstances specify wether or not to use instances to render the mesh
  105942. * @param emissiveTexture the associated emissive texture used to generate the glow
  105943. * @return true if ready otherwise, false
  105944. */
  105945. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105946. /**
  105947. * Implementation specific of rendering the generating effect on the main canvas.
  105948. * @param effect The effect used to render through
  105949. */
  105950. protected _internalRender(effect: Effect): void;
  105951. /**
  105952. * Returns true if the layer contains information to display, otherwise false.
  105953. */
  105954. shouldRender(): boolean;
  105955. /**
  105956. * Returns true if the mesh should render, otherwise false.
  105957. * @param mesh The mesh to render
  105958. * @returns true if it should render otherwise false
  105959. */
  105960. protected _shouldRenderMesh(mesh: Mesh): boolean;
  105961. /**
  105962. * Sets the required values for both the emissive texture and and the main color.
  105963. */
  105964. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105965. /**
  105966. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  105967. * @param mesh The mesh to exclude from the highlight layer
  105968. */
  105969. addExcludedMesh(mesh: Mesh): void;
  105970. /**
  105971. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  105972. * @param mesh The mesh to highlight
  105973. */
  105974. removeExcludedMesh(mesh: Mesh): void;
  105975. /**
  105976. * Determine if a given mesh will be highlighted by the current HighlightLayer
  105977. * @param mesh mesh to test
  105978. * @returns true if the mesh will be highlighted by the current HighlightLayer
  105979. */
  105980. hasMesh(mesh: AbstractMesh): boolean;
  105981. /**
  105982. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  105983. * @param mesh The mesh to highlight
  105984. * @param color The color of the highlight
  105985. * @param glowEmissiveOnly Extract the glow from the emissive texture
  105986. */
  105987. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  105988. /**
  105989. * Remove a mesh from the highlight layer in order to make it stop glowing.
  105990. * @param mesh The mesh to highlight
  105991. */
  105992. removeMesh(mesh: Mesh): void;
  105993. /**
  105994. * Force the stencil to the normal expected value for none glowing parts
  105995. */
  105996. private _defaultStencilReference;
  105997. /**
  105998. * Free any resources and references associated to a mesh.
  105999. * Internal use
  106000. * @param mesh The mesh to free.
  106001. * @hidden
  106002. */
  106003. _disposeMesh(mesh: Mesh): void;
  106004. /**
  106005. * Dispose the highlight layer and free resources.
  106006. */
  106007. dispose(): void;
  106008. /**
  106009. * Gets the class name of the effect layer
  106010. * @returns the string with the class name of the effect layer
  106011. */
  106012. getClassName(): string;
  106013. /**
  106014. * Serializes this Highlight layer
  106015. * @returns a serialized Highlight layer object
  106016. */
  106017. serialize(): any;
  106018. /**
  106019. * Creates a Highlight layer from parsed Highlight layer data
  106020. * @param parsedHightlightLayer defines the Highlight layer data
  106021. * @param scene defines the current scene
  106022. * @param rootUrl defines the root URL containing the Highlight layer information
  106023. * @returns a parsed Highlight layer
  106024. */
  106025. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  106026. }
  106027. }
  106028. declare module BABYLON {
  106029. /** @hidden */
  106030. export var lensFlarePixelShader: {
  106031. name: string;
  106032. shader: string;
  106033. };
  106034. }
  106035. declare module BABYLON {
  106036. /** @hidden */
  106037. export var lensFlareVertexShader: {
  106038. name: string;
  106039. shader: string;
  106040. };
  106041. }
  106042. declare module BABYLON {
  106043. /**
  106044. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106045. * It is usually composed of several `lensFlare`.
  106046. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106047. */
  106048. export class LensFlareSystem {
  106049. /**
  106050. * Define the name of the lens flare system
  106051. */
  106052. name: string;
  106053. /**
  106054. * List of lens flares used in this system.
  106055. */
  106056. lensFlares: LensFlare[];
  106057. /**
  106058. * Define a limit from the border the lens flare can be visible.
  106059. */
  106060. borderLimit: number;
  106061. /**
  106062. * Define a viewport border we do not want to see the lens flare in.
  106063. */
  106064. viewportBorder: number;
  106065. /**
  106066. * Define a predicate which could limit the list of meshes able to occlude the effect.
  106067. */
  106068. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106069. /**
  106070. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  106071. */
  106072. layerMask: number;
  106073. /**
  106074. * Define the id of the lens flare system in the scene.
  106075. * (equal to name by default)
  106076. */
  106077. id: string;
  106078. private _scene;
  106079. private _emitter;
  106080. private _vertexBuffers;
  106081. private _indexBuffer;
  106082. private _effect;
  106083. private _positionX;
  106084. private _positionY;
  106085. private _isEnabled;
  106086. /** @hidden */
  106087. static _SceneComponentInitialization: (scene: Scene) => void;
  106088. /**
  106089. * Instantiates a lens flare system.
  106090. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106091. * It is usually composed of several `lensFlare`.
  106092. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106093. * @param name Define the name of the lens flare system in the scene
  106094. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  106095. * @param scene Define the scene the lens flare system belongs to
  106096. */
  106097. constructor(
  106098. /**
  106099. * Define the name of the lens flare system
  106100. */
  106101. name: string, emitter: any, scene: Scene);
  106102. /**
  106103. * Define if the lens flare system is enabled.
  106104. */
  106105. isEnabled: boolean;
  106106. /**
  106107. * Get the scene the effects belongs to.
  106108. * @returns the scene holding the lens flare system
  106109. */
  106110. getScene(): Scene;
  106111. /**
  106112. * Get the emitter of the lens flare system.
  106113. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106114. * @returns the emitter of the lens flare system
  106115. */
  106116. getEmitter(): any;
  106117. /**
  106118. * Set the emitter of the lens flare system.
  106119. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106120. * @param newEmitter Define the new emitter of the system
  106121. */
  106122. setEmitter(newEmitter: any): void;
  106123. /**
  106124. * Get the lens flare system emitter position.
  106125. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  106126. * @returns the position
  106127. */
  106128. getEmitterPosition(): Vector3;
  106129. /**
  106130. * @hidden
  106131. */
  106132. computeEffectivePosition(globalViewport: Viewport): boolean;
  106133. /** @hidden */
  106134. _isVisible(): boolean;
  106135. /**
  106136. * @hidden
  106137. */
  106138. render(): boolean;
  106139. /**
  106140. * Dispose and release the lens flare with its associated resources.
  106141. */
  106142. dispose(): void;
  106143. /**
  106144. * Parse a lens flare system from a JSON repressentation
  106145. * @param parsedLensFlareSystem Define the JSON to parse
  106146. * @param scene Define the scene the parsed system should be instantiated in
  106147. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  106148. * @returns the parsed system
  106149. */
  106150. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  106151. /**
  106152. * Serialize the current Lens Flare System into a JSON representation.
  106153. * @returns the serialized JSON
  106154. */
  106155. serialize(): any;
  106156. }
  106157. }
  106158. declare module BABYLON {
  106159. /**
  106160. * This represents one of the lens effect in a `lensFlareSystem`.
  106161. * It controls one of the indiviual texture used in the effect.
  106162. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106163. */
  106164. export class LensFlare {
  106165. /**
  106166. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106167. */
  106168. size: number;
  106169. /**
  106170. * 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.
  106171. */
  106172. position: number;
  106173. /**
  106174. * Define the lens color.
  106175. */
  106176. color: Color3;
  106177. /**
  106178. * Define the lens texture.
  106179. */
  106180. texture: Nullable<Texture>;
  106181. /**
  106182. * Define the alpha mode to render this particular lens.
  106183. */
  106184. alphaMode: number;
  106185. private _system;
  106186. /**
  106187. * Creates a new Lens Flare.
  106188. * This represents one of the lens effect in a `lensFlareSystem`.
  106189. * It controls one of the indiviual texture used in the effect.
  106190. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106191. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  106192. * @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.
  106193. * @param color Define the lens color
  106194. * @param imgUrl Define the lens texture url
  106195. * @param system Define the `lensFlareSystem` this flare is part of
  106196. * @returns The newly created Lens Flare
  106197. */
  106198. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  106199. /**
  106200. * Instantiates a new Lens Flare.
  106201. * This represents one of the lens effect in a `lensFlareSystem`.
  106202. * It controls one of the indiviual texture used in the effect.
  106203. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106204. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  106205. * @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.
  106206. * @param color Define the lens color
  106207. * @param imgUrl Define the lens texture url
  106208. * @param system Define the `lensFlareSystem` this flare is part of
  106209. */
  106210. constructor(
  106211. /**
  106212. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106213. */
  106214. size: number,
  106215. /**
  106216. * 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.
  106217. */
  106218. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  106219. /**
  106220. * Dispose and release the lens flare with its associated resources.
  106221. */
  106222. dispose(): void;
  106223. }
  106224. }
  106225. declare module BABYLON {
  106226. interface AbstractScene {
  106227. /**
  106228. * The list of lens flare system added to the scene
  106229. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106230. */
  106231. lensFlareSystems: Array<LensFlareSystem>;
  106232. /**
  106233. * Removes the given lens flare system from this scene.
  106234. * @param toRemove The lens flare system to remove
  106235. * @returns The index of the removed lens flare system
  106236. */
  106237. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  106238. /**
  106239. * Adds the given lens flare system to this scene
  106240. * @param newLensFlareSystem The lens flare system to add
  106241. */
  106242. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  106243. /**
  106244. * Gets a lens flare system using its name
  106245. * @param name defines the name to look for
  106246. * @returns the lens flare system or null if not found
  106247. */
  106248. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  106249. /**
  106250. * Gets a lens flare system using its id
  106251. * @param id defines the id to look for
  106252. * @returns the lens flare system or null if not found
  106253. */
  106254. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  106255. }
  106256. /**
  106257. * Defines the lens flare scene component responsible to manage any lens flares
  106258. * in a given scene.
  106259. */
  106260. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  106261. /**
  106262. * The component name helpfull to identify the component in the list of scene components.
  106263. */
  106264. readonly name: string;
  106265. /**
  106266. * The scene the component belongs to.
  106267. */
  106268. scene: Scene;
  106269. /**
  106270. * Creates a new instance of the component for the given scene
  106271. * @param scene Defines the scene to register the component in
  106272. */
  106273. constructor(scene: Scene);
  106274. /**
  106275. * Registers the component in a given scene
  106276. */
  106277. register(): void;
  106278. /**
  106279. * Rebuilds the elements related to this component in case of
  106280. * context lost for instance.
  106281. */
  106282. rebuild(): void;
  106283. /**
  106284. * Adds all the element from the container to the scene
  106285. * @param container the container holding the elements
  106286. */
  106287. addFromContainer(container: AbstractScene): void;
  106288. /**
  106289. * Removes all the elements in the container from the scene
  106290. * @param container contains the elements to remove
  106291. * @param dispose if the removed element should be disposed (default: false)
  106292. */
  106293. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106294. /**
  106295. * Serializes the component data to the specified json object
  106296. * @param serializationObject The object to serialize to
  106297. */
  106298. serialize(serializationObject: any): void;
  106299. /**
  106300. * Disposes the component and the associated ressources.
  106301. */
  106302. dispose(): void;
  106303. private _draw;
  106304. }
  106305. }
  106306. declare module BABYLON {
  106307. /**
  106308. * Defines the shadow generator component responsible to manage any shadow generators
  106309. * in a given scene.
  106310. */
  106311. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  106312. /**
  106313. * The component name helpfull to identify the component in the list of scene components.
  106314. */
  106315. readonly name: string;
  106316. /**
  106317. * The scene the component belongs to.
  106318. */
  106319. scene: Scene;
  106320. /**
  106321. * Creates a new instance of the component for the given scene
  106322. * @param scene Defines the scene to register the component in
  106323. */
  106324. constructor(scene: Scene);
  106325. /**
  106326. * Registers the component in a given scene
  106327. */
  106328. register(): void;
  106329. /**
  106330. * Rebuilds the elements related to this component in case of
  106331. * context lost for instance.
  106332. */
  106333. rebuild(): void;
  106334. /**
  106335. * Serializes the component data to the specified json object
  106336. * @param serializationObject The object to serialize to
  106337. */
  106338. serialize(serializationObject: any): void;
  106339. /**
  106340. * Adds all the element from the container to the scene
  106341. * @param container the container holding the elements
  106342. */
  106343. addFromContainer(container: AbstractScene): void;
  106344. /**
  106345. * Removes all the elements in the container from the scene
  106346. * @param container contains the elements to remove
  106347. * @param dispose if the removed element should be disposed (default: false)
  106348. */
  106349. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106350. /**
  106351. * Rebuilds the elements related to this component in case of
  106352. * context lost for instance.
  106353. */
  106354. dispose(): void;
  106355. private _gatherRenderTargets;
  106356. }
  106357. }
  106358. declare module BABYLON {
  106359. /**
  106360. * A point light is a light defined by an unique point in world space.
  106361. * The light is emitted in every direction from this point.
  106362. * A good example of a point light is a standard light bulb.
  106363. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106364. */
  106365. export class PointLight extends ShadowLight {
  106366. private _shadowAngle;
  106367. /**
  106368. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106369. * This specifies what angle the shadow will use to be created.
  106370. *
  106371. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106372. */
  106373. /**
  106374. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106375. * This specifies what angle the shadow will use to be created.
  106376. *
  106377. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106378. */
  106379. shadowAngle: number;
  106380. /**
  106381. * Gets the direction if it has been set.
  106382. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106383. */
  106384. /**
  106385. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106386. */
  106387. direction: Vector3;
  106388. /**
  106389. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  106390. * A PointLight emits the light in every direction.
  106391. * It can cast shadows.
  106392. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  106393. * ```javascript
  106394. * var pointLight = new PointLight("pl", camera.position, scene);
  106395. * ```
  106396. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106397. * @param name The light friendly name
  106398. * @param position The position of the point light in the scene
  106399. * @param scene The scene the lights belongs to
  106400. */
  106401. constructor(name: string, position: Vector3, scene: Scene);
  106402. /**
  106403. * Returns the string "PointLight"
  106404. * @returns the class name
  106405. */
  106406. getClassName(): string;
  106407. /**
  106408. * Returns the integer 0.
  106409. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106410. */
  106411. getTypeID(): number;
  106412. /**
  106413. * Specifies wether or not the shadowmap should be a cube texture.
  106414. * @returns true if the shadowmap needs to be a cube texture.
  106415. */
  106416. needCube(): boolean;
  106417. /**
  106418. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  106419. * @param faceIndex The index of the face we are computed the direction to generate shadow
  106420. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  106421. */
  106422. getShadowDirection(faceIndex?: number): Vector3;
  106423. /**
  106424. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  106425. * - fov = PI / 2
  106426. * - aspect ratio : 1.0
  106427. * - z-near and far equal to the active camera minZ and maxZ.
  106428. * Returns the PointLight.
  106429. */
  106430. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106431. protected _buildUniformLayout(): void;
  106432. /**
  106433. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  106434. * @param effect The effect to update
  106435. * @param lightIndex The index of the light in the effect to update
  106436. * @returns The point light
  106437. */
  106438. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  106439. /**
  106440. * Prepares the list of defines specific to the light type.
  106441. * @param defines the list of defines
  106442. * @param lightIndex defines the index of the light for the effect
  106443. */
  106444. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106445. }
  106446. }
  106447. declare module BABYLON {
  106448. /**
  106449. * Header information of HDR texture files.
  106450. */
  106451. export interface HDRInfo {
  106452. /**
  106453. * The height of the texture in pixels.
  106454. */
  106455. height: number;
  106456. /**
  106457. * The width of the texture in pixels.
  106458. */
  106459. width: number;
  106460. /**
  106461. * The index of the beginning of the data in the binary file.
  106462. */
  106463. dataPosition: number;
  106464. }
  106465. /**
  106466. * This groups tools to convert HDR texture to native colors array.
  106467. */
  106468. export class HDRTools {
  106469. private static Ldexp;
  106470. private static Rgbe2float;
  106471. private static readStringLine;
  106472. /**
  106473. * Reads header information from an RGBE texture stored in a native array.
  106474. * More information on this format are available here:
  106475. * https://en.wikipedia.org/wiki/RGBE_image_format
  106476. *
  106477. * @param uint8array The binary file stored in native array.
  106478. * @return The header information.
  106479. */
  106480. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  106481. /**
  106482. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  106483. * This RGBE texture needs to store the information as a panorama.
  106484. *
  106485. * More information on this format are available here:
  106486. * https://en.wikipedia.org/wiki/RGBE_image_format
  106487. *
  106488. * @param buffer The binary file stored in an array buffer.
  106489. * @param size The expected size of the extracted cubemap.
  106490. * @return The Cube Map information.
  106491. */
  106492. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  106493. /**
  106494. * Returns the pixels data extracted from an RGBE texture.
  106495. * This pixels will be stored left to right up to down in the R G B order in one array.
  106496. *
  106497. * More information on this format are available here:
  106498. * https://en.wikipedia.org/wiki/RGBE_image_format
  106499. *
  106500. * @param uint8array The binary file stored in an array buffer.
  106501. * @param hdrInfo The header information of the file.
  106502. * @return The pixels data in RGB right to left up to down order.
  106503. */
  106504. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  106505. private static RGBE_ReadPixels_RLE;
  106506. }
  106507. }
  106508. declare module BABYLON {
  106509. /**
  106510. * This represents a texture coming from an HDR input.
  106511. *
  106512. * The only supported format is currently panorama picture stored in RGBE format.
  106513. * Example of such files can be found on HDRLib: http://hdrlib.com/
  106514. */
  106515. export class HDRCubeTexture extends BaseTexture {
  106516. private static _facesMapping;
  106517. private _generateHarmonics;
  106518. private _noMipmap;
  106519. private _textureMatrix;
  106520. private _size;
  106521. private _onLoad;
  106522. private _onError;
  106523. /**
  106524. * The texture URL.
  106525. */
  106526. url: string;
  106527. /**
  106528. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  106529. */
  106530. coordinatesMode: number;
  106531. protected _isBlocking: boolean;
  106532. /**
  106533. * Sets wether or not the texture is blocking during loading.
  106534. */
  106535. /**
  106536. * Gets wether or not the texture is blocking during loading.
  106537. */
  106538. isBlocking: boolean;
  106539. protected _rotationY: number;
  106540. /**
  106541. * Sets texture matrix rotation angle around Y axis in radians.
  106542. */
  106543. /**
  106544. * Gets texture matrix rotation angle around Y axis radians.
  106545. */
  106546. rotationY: number;
  106547. /**
  106548. * Gets or sets the center of the bounding box associated with the cube texture
  106549. * It must define where the camera used to render the texture was set
  106550. */
  106551. boundingBoxPosition: Vector3;
  106552. private _boundingBoxSize;
  106553. /**
  106554. * Gets or sets the size of the bounding box associated with the cube texture
  106555. * When defined, the cubemap will switch to local mode
  106556. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  106557. * @example https://www.babylonjs-playground.com/#RNASML
  106558. */
  106559. boundingBoxSize: Vector3;
  106560. /**
  106561. * Instantiates an HDRTexture from the following parameters.
  106562. *
  106563. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  106564. * @param scene The scene the texture will be used in
  106565. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  106566. * @param noMipmap Forces to not generate the mipmap if true
  106567. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  106568. * @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)
  106569. * @param reserved Reserved flag for internal use.
  106570. */
  106571. 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>);
  106572. /**
  106573. * Get the current class name of the texture useful for serialization or dynamic coding.
  106574. * @returns "HDRCubeTexture"
  106575. */
  106576. getClassName(): string;
  106577. /**
  106578. * Occurs when the file is raw .hdr file.
  106579. */
  106580. private loadTexture;
  106581. clone(): HDRCubeTexture;
  106582. delayLoad(): void;
  106583. /**
  106584. * Get the texture reflection matrix used to rotate/transform the reflection.
  106585. * @returns the reflection matrix
  106586. */
  106587. getReflectionTextureMatrix(): Matrix;
  106588. /**
  106589. * Set the texture reflection matrix used to rotate/transform the reflection.
  106590. * @param value Define the reflection matrix to set
  106591. */
  106592. setReflectionTextureMatrix(value: Matrix): void;
  106593. /**
  106594. * Parses a JSON representation of an HDR Texture in order to create the texture
  106595. * @param parsedTexture Define the JSON representation
  106596. * @param scene Define the scene the texture should be created in
  106597. * @param rootUrl Define the root url in case we need to load relative dependencies
  106598. * @returns the newly created texture after parsing
  106599. */
  106600. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  106601. serialize(): any;
  106602. }
  106603. }
  106604. declare module BABYLON {
  106605. /**
  106606. * Class used to control physics engine
  106607. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  106608. */
  106609. export class PhysicsEngine implements IPhysicsEngine {
  106610. private _physicsPlugin;
  106611. /**
  106612. * Global value used to control the smallest number supported by the simulation
  106613. */
  106614. static Epsilon: number;
  106615. private _impostors;
  106616. private _joints;
  106617. /**
  106618. * Gets the gravity vector used by the simulation
  106619. */
  106620. gravity: Vector3;
  106621. /**
  106622. * Factory used to create the default physics plugin.
  106623. * @returns The default physics plugin
  106624. */
  106625. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  106626. /**
  106627. * Creates a new Physics Engine
  106628. * @param gravity defines the gravity vector used by the simulation
  106629. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  106630. */
  106631. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  106632. /**
  106633. * Sets the gravity vector used by the simulation
  106634. * @param gravity defines the gravity vector to use
  106635. */
  106636. setGravity(gravity: Vector3): void;
  106637. /**
  106638. * Set the time step of the physics engine.
  106639. * Default is 1/60.
  106640. * To slow it down, enter 1/600 for example.
  106641. * To speed it up, 1/30
  106642. * @param newTimeStep defines the new timestep to apply to this world.
  106643. */
  106644. setTimeStep(newTimeStep?: number): void;
  106645. /**
  106646. * Get the time step of the physics engine.
  106647. * @returns the current time step
  106648. */
  106649. getTimeStep(): number;
  106650. /**
  106651. * Release all resources
  106652. */
  106653. dispose(): void;
  106654. /**
  106655. * Gets the name of the current physics plugin
  106656. * @returns the name of the plugin
  106657. */
  106658. getPhysicsPluginName(): string;
  106659. /**
  106660. * Adding a new impostor for the impostor tracking.
  106661. * This will be done by the impostor itself.
  106662. * @param impostor the impostor to add
  106663. */
  106664. addImpostor(impostor: PhysicsImpostor): void;
  106665. /**
  106666. * Remove an impostor from the engine.
  106667. * This impostor and its mesh will not longer be updated by the physics engine.
  106668. * @param impostor the impostor to remove
  106669. */
  106670. removeImpostor(impostor: PhysicsImpostor): void;
  106671. /**
  106672. * Add a joint to the physics engine
  106673. * @param mainImpostor defines the main impostor to which the joint is added.
  106674. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  106675. * @param joint defines the joint that will connect both impostors.
  106676. */
  106677. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106678. /**
  106679. * Removes a joint from the simulation
  106680. * @param mainImpostor defines the impostor used with the joint
  106681. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  106682. * @param joint defines the joint to remove
  106683. */
  106684. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106685. /**
  106686. * Called by the scene. No need to call it.
  106687. * @param delta defines the timespam between frames
  106688. */
  106689. _step(delta: number): void;
  106690. /**
  106691. * Gets the current plugin used to run the simulation
  106692. * @returns current plugin
  106693. */
  106694. getPhysicsPlugin(): IPhysicsEnginePlugin;
  106695. /**
  106696. * Gets the list of physic impostors
  106697. * @returns an array of PhysicsImpostor
  106698. */
  106699. getImpostors(): Array<PhysicsImpostor>;
  106700. /**
  106701. * Gets the impostor for a physics enabled object
  106702. * @param object defines the object impersonated by the impostor
  106703. * @returns the PhysicsImpostor or null if not found
  106704. */
  106705. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106706. /**
  106707. * Gets the impostor for a physics body object
  106708. * @param body defines physics body used by the impostor
  106709. * @returns the PhysicsImpostor or null if not found
  106710. */
  106711. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  106712. /**
  106713. * Does a raycast in the physics world
  106714. * @param from when should the ray start?
  106715. * @param to when should the ray end?
  106716. * @returns PhysicsRaycastResult
  106717. */
  106718. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106719. }
  106720. }
  106721. declare module BABYLON {
  106722. /** @hidden */
  106723. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  106724. private _useDeltaForWorldStep;
  106725. world: any;
  106726. name: string;
  106727. private _physicsMaterials;
  106728. private _fixedTimeStep;
  106729. private _cannonRaycastResult;
  106730. private _raycastResult;
  106731. BJSCANNON: any;
  106732. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  106733. setGravity(gravity: Vector3): void;
  106734. setTimeStep(timeStep: number): void;
  106735. getTimeStep(): number;
  106736. executeStep(delta: number): void;
  106737. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106738. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106739. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106740. private _processChildMeshes;
  106741. removePhysicsBody(impostor: PhysicsImpostor): void;
  106742. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  106743. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  106744. private _addMaterial;
  106745. private _checkWithEpsilon;
  106746. private _createShape;
  106747. private _createHeightmap;
  106748. private _minus90X;
  106749. private _plus90X;
  106750. private _tmpPosition;
  106751. private _tmpDeltaPosition;
  106752. private _tmpUnityRotation;
  106753. private _updatePhysicsBodyTransformation;
  106754. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106755. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106756. isSupported(): boolean;
  106757. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106758. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106759. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106760. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106761. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106762. getBodyMass(impostor: PhysicsImpostor): number;
  106763. getBodyFriction(impostor: PhysicsImpostor): number;
  106764. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106765. getBodyRestitution(impostor: PhysicsImpostor): number;
  106766. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106767. sleepBody(impostor: PhysicsImpostor): void;
  106768. wakeUpBody(impostor: PhysicsImpostor): void;
  106769. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  106770. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  106771. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  106772. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106773. getRadius(impostor: PhysicsImpostor): number;
  106774. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106775. dispose(): void;
  106776. private _extendNamespace;
  106777. /**
  106778. * Does a raycast in the physics world
  106779. * @param from when should the ray start?
  106780. * @param to when should the ray end?
  106781. * @returns PhysicsRaycastResult
  106782. */
  106783. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106784. }
  106785. }
  106786. declare module BABYLON {
  106787. /** @hidden */
  106788. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  106789. world: any;
  106790. name: string;
  106791. BJSOIMO: any;
  106792. private _raycastResult;
  106793. constructor(iterations?: number, oimoInjection?: any);
  106794. setGravity(gravity: Vector3): void;
  106795. setTimeStep(timeStep: number): void;
  106796. getTimeStep(): number;
  106797. private _tmpImpostorsArray;
  106798. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106799. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106800. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106801. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106802. private _tmpPositionVector;
  106803. removePhysicsBody(impostor: PhysicsImpostor): void;
  106804. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  106805. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  106806. isSupported(): boolean;
  106807. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106808. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106809. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106810. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106811. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106812. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106813. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106814. getBodyMass(impostor: PhysicsImpostor): number;
  106815. getBodyFriction(impostor: PhysicsImpostor): number;
  106816. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106817. getBodyRestitution(impostor: PhysicsImpostor): number;
  106818. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106819. sleepBody(impostor: PhysicsImpostor): void;
  106820. wakeUpBody(impostor: PhysicsImpostor): void;
  106821. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106822. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  106823. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106824. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106825. getRadius(impostor: PhysicsImpostor): number;
  106826. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106827. dispose(): void;
  106828. /**
  106829. * Does a raycast in the physics world
  106830. * @param from when should the ray start?
  106831. * @param to when should the ray end?
  106832. * @returns PhysicsRaycastResult
  106833. */
  106834. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106835. }
  106836. }
  106837. declare module BABYLON {
  106838. /**
  106839. * Class containing static functions to help procedurally build meshes
  106840. */
  106841. export class RibbonBuilder {
  106842. /**
  106843. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106844. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106845. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106846. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106847. * * 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
  106848. * * 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
  106849. * * 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
  106850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106852. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106853. * * 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
  106854. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106855. * * 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
  106856. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106858. * @param name defines the name of the mesh
  106859. * @param options defines the options used to create the mesh
  106860. * @param scene defines the hosting scene
  106861. * @returns the ribbon mesh
  106862. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106863. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106864. */
  106865. static CreateRibbon(name: string, options: {
  106866. pathArray: Vector3[][];
  106867. closeArray?: boolean;
  106868. closePath?: boolean;
  106869. offset?: number;
  106870. updatable?: boolean;
  106871. sideOrientation?: number;
  106872. frontUVs?: Vector4;
  106873. backUVs?: Vector4;
  106874. instance?: Mesh;
  106875. invertUV?: boolean;
  106876. uvs?: Vector2[];
  106877. colors?: Color4[];
  106878. }, scene?: Nullable<Scene>): Mesh;
  106879. }
  106880. }
  106881. declare module BABYLON {
  106882. /**
  106883. * Class containing static functions to help procedurally build meshes
  106884. */
  106885. export class ShapeBuilder {
  106886. /**
  106887. * 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.
  106888. * * 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.
  106889. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106890. * * 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.
  106891. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106892. * * 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
  106893. * * 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
  106894. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106897. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106899. * @param name defines the name of the mesh
  106900. * @param options defines the options used to create the mesh
  106901. * @param scene defines the hosting scene
  106902. * @returns the extruded shape mesh
  106903. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106904. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106905. */
  106906. static ExtrudeShape(name: string, options: {
  106907. shape: Vector3[];
  106908. path: Vector3[];
  106909. scale?: number;
  106910. rotation?: number;
  106911. cap?: number;
  106912. updatable?: boolean;
  106913. sideOrientation?: number;
  106914. frontUVs?: Vector4;
  106915. backUVs?: Vector4;
  106916. instance?: Mesh;
  106917. invertUV?: boolean;
  106918. }, scene?: Nullable<Scene>): Mesh;
  106919. /**
  106920. * Creates an custom extruded shape mesh.
  106921. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106922. * * 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.
  106923. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106924. * * 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
  106925. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106926. * * 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
  106927. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106928. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106929. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106930. * * 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
  106931. * * 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
  106932. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106935. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106937. * @param name defines the name of the mesh
  106938. * @param options defines the options used to create the mesh
  106939. * @param scene defines the hosting scene
  106940. * @returns the custom extruded shape mesh
  106941. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106942. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106944. */
  106945. static ExtrudeShapeCustom(name: string, options: {
  106946. shape: Vector3[];
  106947. path: Vector3[];
  106948. scaleFunction?: any;
  106949. rotationFunction?: any;
  106950. ribbonCloseArray?: boolean;
  106951. ribbonClosePath?: boolean;
  106952. cap?: number;
  106953. updatable?: boolean;
  106954. sideOrientation?: number;
  106955. frontUVs?: Vector4;
  106956. backUVs?: Vector4;
  106957. instance?: Mesh;
  106958. invertUV?: boolean;
  106959. }, scene: Scene): Mesh;
  106960. private static _ExtrudeShapeGeneric;
  106961. }
  106962. }
  106963. declare module BABYLON {
  106964. /**
  106965. * AmmoJS Physics plugin
  106966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106967. * @see https://github.com/kripken/ammo.js/
  106968. */
  106969. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  106970. private _useDeltaForWorldStep;
  106971. /**
  106972. * Reference to the Ammo library
  106973. */
  106974. bjsAMMO: any;
  106975. /**
  106976. * Created ammoJS world which physics bodies are added to
  106977. */
  106978. world: any;
  106979. /**
  106980. * Name of the plugin
  106981. */
  106982. name: string;
  106983. private _timeStep;
  106984. private _fixedTimeStep;
  106985. private _maxSteps;
  106986. private _tmpQuaternion;
  106987. private _tmpAmmoTransform;
  106988. private _tmpAmmoQuaternion;
  106989. private _tmpAmmoConcreteContactResultCallback;
  106990. private _collisionConfiguration;
  106991. private _dispatcher;
  106992. private _overlappingPairCache;
  106993. private _solver;
  106994. private _softBodySolver;
  106995. private _tmpAmmoVectorA;
  106996. private _tmpAmmoVectorB;
  106997. private _tmpAmmoVectorC;
  106998. private _tmpAmmoVectorD;
  106999. private _tmpContactCallbackResult;
  107000. private _tmpAmmoVectorRCA;
  107001. private _tmpAmmoVectorRCB;
  107002. private _raycastResult;
  107003. private static readonly DISABLE_COLLISION_FLAG;
  107004. private static readonly KINEMATIC_FLAG;
  107005. private static readonly DISABLE_DEACTIVATION_FLAG;
  107006. /**
  107007. * Initializes the ammoJS plugin
  107008. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107009. * @param ammoInjection can be used to inject your own ammo reference
  107010. */
  107011. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107012. /**
  107013. * Sets the gravity of the physics world (m/(s^2))
  107014. * @param gravity Gravity to set
  107015. */
  107016. setGravity(gravity: Vector3): void;
  107017. /**
  107018. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107019. * @param timeStep timestep to use in seconds
  107020. */
  107021. setTimeStep(timeStep: number): void;
  107022. /**
  107023. * 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)
  107024. * @param fixedTimeStep fixedTimeStep to use in seconds
  107025. */
  107026. setFixedTimeStep(fixedTimeStep: number): void;
  107027. /**
  107028. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107029. * @param maxSteps the maximum number of steps by the physics engine per frame
  107030. */
  107031. setMaxSteps(maxSteps: number): void;
  107032. /**
  107033. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107034. * @returns the current timestep in seconds
  107035. */
  107036. getTimeStep(): number;
  107037. private _isImpostorInContact;
  107038. private _isImpostorPairInContact;
  107039. private _stepSimulation;
  107040. /**
  107041. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107042. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107043. * After the step the babylon meshes are set to the position of the physics imposters
  107044. * @param delta amount of time to step forward
  107045. * @param impostors array of imposters to update before/after the step
  107046. */
  107047. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107048. /**
  107049. * Update babylon mesh to match physics world object
  107050. * @param impostor imposter to match
  107051. */
  107052. private _afterSoftStep;
  107053. /**
  107054. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107055. * @param impostor imposter to match
  107056. */
  107057. private _ropeStep;
  107058. /**
  107059. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107060. * @param impostor imposter to match
  107061. */
  107062. private _softbodyOrClothStep;
  107063. private _tmpVector;
  107064. private _tmpMatrix;
  107065. /**
  107066. * Applies an impulse on the imposter
  107067. * @param impostor imposter to apply impulse to
  107068. * @param force amount of force to be applied to the imposter
  107069. * @param contactPoint the location to apply the impulse on the imposter
  107070. */
  107071. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107072. /**
  107073. * Applies a force on the imposter
  107074. * @param impostor imposter to apply force
  107075. * @param force amount of force to be applied to the imposter
  107076. * @param contactPoint the location to apply the force on the imposter
  107077. */
  107078. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107079. /**
  107080. * Creates a physics body using the plugin
  107081. * @param impostor the imposter to create the physics body on
  107082. */
  107083. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107084. /**
  107085. * Removes the physics body from the imposter and disposes of the body's memory
  107086. * @param impostor imposter to remove the physics body from
  107087. */
  107088. removePhysicsBody(impostor: PhysicsImpostor): void;
  107089. /**
  107090. * Generates a joint
  107091. * @param impostorJoint the imposter joint to create the joint with
  107092. */
  107093. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107094. /**
  107095. * Removes a joint
  107096. * @param impostorJoint the imposter joint to remove the joint from
  107097. */
  107098. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107099. private _addMeshVerts;
  107100. /**
  107101. * Initialise the soft body vertices to match its object's (mesh) vertices
  107102. * Softbody vertices (nodes) are in world space and to match this
  107103. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  107104. * @param impostor to create the softbody for
  107105. */
  107106. private _softVertexData;
  107107. /**
  107108. * Create an impostor's soft body
  107109. * @param impostor to create the softbody for
  107110. */
  107111. private _createSoftbody;
  107112. /**
  107113. * Create cloth for an impostor
  107114. * @param impostor to create the softbody for
  107115. */
  107116. private _createCloth;
  107117. /**
  107118. * Create rope for an impostor
  107119. * @param impostor to create the softbody for
  107120. */
  107121. private _createRope;
  107122. private _addHullVerts;
  107123. private _createShape;
  107124. /**
  107125. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107126. * @param impostor imposter containing the physics body and babylon object
  107127. */
  107128. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107129. /**
  107130. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107131. * @param impostor imposter containing the physics body and babylon object
  107132. * @param newPosition new position
  107133. * @param newRotation new rotation
  107134. */
  107135. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107136. /**
  107137. * If this plugin is supported
  107138. * @returns true if its supported
  107139. */
  107140. isSupported(): boolean;
  107141. /**
  107142. * Sets the linear velocity of the physics body
  107143. * @param impostor imposter to set the velocity on
  107144. * @param velocity velocity to set
  107145. */
  107146. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107147. /**
  107148. * Sets the angular velocity of the physics body
  107149. * @param impostor imposter to set the velocity on
  107150. * @param velocity velocity to set
  107151. */
  107152. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107153. /**
  107154. * gets the linear velocity
  107155. * @param impostor imposter to get linear velocity from
  107156. * @returns linear velocity
  107157. */
  107158. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107159. /**
  107160. * gets the angular velocity
  107161. * @param impostor imposter to get angular velocity from
  107162. * @returns angular velocity
  107163. */
  107164. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107165. /**
  107166. * Sets the mass of physics body
  107167. * @param impostor imposter to set the mass on
  107168. * @param mass mass to set
  107169. */
  107170. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107171. /**
  107172. * Gets the mass of the physics body
  107173. * @param impostor imposter to get the mass from
  107174. * @returns mass
  107175. */
  107176. getBodyMass(impostor: PhysicsImpostor): number;
  107177. /**
  107178. * Gets friction of the impostor
  107179. * @param impostor impostor to get friction from
  107180. * @returns friction value
  107181. */
  107182. getBodyFriction(impostor: PhysicsImpostor): number;
  107183. /**
  107184. * Sets friction of the impostor
  107185. * @param impostor impostor to set friction on
  107186. * @param friction friction value
  107187. */
  107188. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107189. /**
  107190. * Gets restitution of the impostor
  107191. * @param impostor impostor to get restitution from
  107192. * @returns restitution value
  107193. */
  107194. getBodyRestitution(impostor: PhysicsImpostor): number;
  107195. /**
  107196. * Sets resitution of the impostor
  107197. * @param impostor impostor to set resitution on
  107198. * @param restitution resitution value
  107199. */
  107200. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107201. /**
  107202. * Gets pressure inside the impostor
  107203. * @param impostor impostor to get pressure from
  107204. * @returns pressure value
  107205. */
  107206. getBodyPressure(impostor: PhysicsImpostor): number;
  107207. /**
  107208. * Sets pressure inside a soft body impostor
  107209. * Cloth and rope must remain 0 pressure
  107210. * @param impostor impostor to set pressure on
  107211. * @param pressure pressure value
  107212. */
  107213. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  107214. /**
  107215. * Gets stiffness of the impostor
  107216. * @param impostor impostor to get stiffness from
  107217. * @returns pressure value
  107218. */
  107219. getBodyStiffness(impostor: PhysicsImpostor): number;
  107220. /**
  107221. * Sets stiffness of the impostor
  107222. * @param impostor impostor to set stiffness on
  107223. * @param stiffness stiffness value from 0 to 1
  107224. */
  107225. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  107226. /**
  107227. * Gets velocityIterations of the impostor
  107228. * @param impostor impostor to get velocity iterations from
  107229. * @returns velocityIterations value
  107230. */
  107231. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  107232. /**
  107233. * Sets velocityIterations of the impostor
  107234. * @param impostor impostor to set velocity iterations on
  107235. * @param velocityIterations velocityIterations value
  107236. */
  107237. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  107238. /**
  107239. * Gets positionIterations of the impostor
  107240. * @param impostor impostor to get position iterations from
  107241. * @returns positionIterations value
  107242. */
  107243. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  107244. /**
  107245. * Sets positionIterations of the impostor
  107246. * @param impostor impostor to set position on
  107247. * @param positionIterations positionIterations value
  107248. */
  107249. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  107250. /**
  107251. * Append an anchor to a cloth object
  107252. * @param impostor is the cloth impostor to add anchor to
  107253. * @param otherImpostor is the rigid impostor to anchor to
  107254. * @param width ratio across width from 0 to 1
  107255. * @param height ratio up height from 0 to 1
  107256. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107257. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107258. */
  107259. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107260. /**
  107261. * Append an hook to a rope object
  107262. * @param impostor is the rope impostor to add hook to
  107263. * @param otherImpostor is the rigid impostor to hook to
  107264. * @param length ratio along the rope from 0 to 1
  107265. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  107266. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107267. */
  107268. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107269. /**
  107270. * Sleeps the physics body and stops it from being active
  107271. * @param impostor impostor to sleep
  107272. */
  107273. sleepBody(impostor: PhysicsImpostor): void;
  107274. /**
  107275. * Activates the physics body
  107276. * @param impostor impostor to activate
  107277. */
  107278. wakeUpBody(impostor: PhysicsImpostor): void;
  107279. /**
  107280. * Updates the distance parameters of the joint
  107281. * @param joint joint to update
  107282. * @param maxDistance maximum distance of the joint
  107283. * @param minDistance minimum distance of the joint
  107284. */
  107285. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107286. /**
  107287. * Sets a motor on the joint
  107288. * @param joint joint to set motor on
  107289. * @param speed speed of the motor
  107290. * @param maxForce maximum force of the motor
  107291. * @param motorIndex index of the motor
  107292. */
  107293. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107294. /**
  107295. * Sets the motors limit
  107296. * @param joint joint to set limit on
  107297. * @param upperLimit upper limit
  107298. * @param lowerLimit lower limit
  107299. */
  107300. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107301. /**
  107302. * Syncs the position and rotation of a mesh with the impostor
  107303. * @param mesh mesh to sync
  107304. * @param impostor impostor to update the mesh with
  107305. */
  107306. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107307. /**
  107308. * Gets the radius of the impostor
  107309. * @param impostor impostor to get radius from
  107310. * @returns the radius
  107311. */
  107312. getRadius(impostor: PhysicsImpostor): number;
  107313. /**
  107314. * Gets the box size of the impostor
  107315. * @param impostor impostor to get box size from
  107316. * @param result the resulting box size
  107317. */
  107318. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107319. /**
  107320. * Disposes of the impostor
  107321. */
  107322. dispose(): void;
  107323. /**
  107324. * Does a raycast in the physics world
  107325. * @param from when should the ray start?
  107326. * @param to when should the ray end?
  107327. * @returns PhysicsRaycastResult
  107328. */
  107329. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107330. }
  107331. }
  107332. declare module BABYLON {
  107333. interface AbstractScene {
  107334. /**
  107335. * The list of reflection probes added to the scene
  107336. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107337. */
  107338. reflectionProbes: Array<ReflectionProbe>;
  107339. /**
  107340. * Removes the given reflection probe from this scene.
  107341. * @param toRemove The reflection probe to remove
  107342. * @returns The index of the removed reflection probe
  107343. */
  107344. removeReflectionProbe(toRemove: ReflectionProbe): number;
  107345. /**
  107346. * Adds the given reflection probe to this scene.
  107347. * @param newReflectionProbe The reflection probe to add
  107348. */
  107349. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  107350. }
  107351. /**
  107352. * Class used to generate realtime reflection / refraction cube textures
  107353. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107354. */
  107355. export class ReflectionProbe {
  107356. /** defines the name of the probe */
  107357. name: string;
  107358. private _scene;
  107359. private _renderTargetTexture;
  107360. private _projectionMatrix;
  107361. private _viewMatrix;
  107362. private _target;
  107363. private _add;
  107364. private _attachedMesh;
  107365. private _invertYAxis;
  107366. /** Gets or sets probe position (center of the cube map) */
  107367. position: Vector3;
  107368. /**
  107369. * Creates a new reflection probe
  107370. * @param name defines the name of the probe
  107371. * @param size defines the texture resolution (for each face)
  107372. * @param scene defines the hosting scene
  107373. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  107374. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  107375. */
  107376. constructor(
  107377. /** defines the name of the probe */
  107378. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  107379. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  107380. samples: number;
  107381. /** Gets or sets the refresh rate to use (on every frame by default) */
  107382. refreshRate: number;
  107383. /**
  107384. * Gets the hosting scene
  107385. * @returns a Scene
  107386. */
  107387. getScene(): Scene;
  107388. /** Gets the internal CubeTexture used to render to */
  107389. readonly cubeTexture: RenderTargetTexture;
  107390. /** Gets the list of meshes to render */
  107391. readonly renderList: Nullable<AbstractMesh[]>;
  107392. /**
  107393. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  107394. * @param mesh defines the mesh to attach to
  107395. */
  107396. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107397. /**
  107398. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  107399. * @param renderingGroupId The rendering group id corresponding to its index
  107400. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107401. */
  107402. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  107403. /**
  107404. * Clean all associated resources
  107405. */
  107406. dispose(): void;
  107407. /**
  107408. * Converts the reflection probe information to a readable string for debug purpose.
  107409. * @param fullDetails Supports for multiple levels of logging within scene loading
  107410. * @returns the human readable reflection probe info
  107411. */
  107412. toString(fullDetails?: boolean): string;
  107413. /**
  107414. * Get the class name of the relfection probe.
  107415. * @returns "ReflectionProbe"
  107416. */
  107417. getClassName(): string;
  107418. /**
  107419. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  107420. * @returns The JSON representation of the texture
  107421. */
  107422. serialize(): any;
  107423. /**
  107424. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  107425. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  107426. * @param scene Define the scene the parsed reflection probe should be instantiated in
  107427. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  107428. * @returns The parsed reflection probe if successful
  107429. */
  107430. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  107431. }
  107432. }
  107433. declare module BABYLON {
  107434. /** @hidden */
  107435. export var _BabylonLoaderRegistered: boolean;
  107436. }
  107437. declare module BABYLON {
  107438. /**
  107439. * The Physically based simple base material of BJS.
  107440. *
  107441. * This enables better naming and convention enforcements on top of the pbrMaterial.
  107442. * It is used as the base class for both the specGloss and metalRough conventions.
  107443. */
  107444. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  107445. /**
  107446. * Number of Simultaneous lights allowed on the material.
  107447. */
  107448. maxSimultaneousLights: number;
  107449. /**
  107450. * If sets to true, disables all the lights affecting the material.
  107451. */
  107452. disableLighting: boolean;
  107453. /**
  107454. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  107455. */
  107456. environmentTexture: BaseTexture;
  107457. /**
  107458. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107459. */
  107460. invertNormalMapX: boolean;
  107461. /**
  107462. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107463. */
  107464. invertNormalMapY: boolean;
  107465. /**
  107466. * Normal map used in the model.
  107467. */
  107468. normalTexture: BaseTexture;
  107469. /**
  107470. * Emissivie color used to self-illuminate the model.
  107471. */
  107472. emissiveColor: Color3;
  107473. /**
  107474. * Emissivie texture used to self-illuminate the model.
  107475. */
  107476. emissiveTexture: BaseTexture;
  107477. /**
  107478. * Occlusion Channel Strenght.
  107479. */
  107480. occlusionStrength: number;
  107481. /**
  107482. * Occlusion Texture of the material (adding extra occlusion effects).
  107483. */
  107484. occlusionTexture: BaseTexture;
  107485. /**
  107486. * Defines the alpha limits in alpha test mode.
  107487. */
  107488. alphaCutOff: number;
  107489. /**
  107490. * Gets the current double sided mode.
  107491. */
  107492. /**
  107493. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107494. */
  107495. doubleSided: boolean;
  107496. /**
  107497. * Stores the pre-calculated light information of a mesh in a texture.
  107498. */
  107499. lightmapTexture: BaseTexture;
  107500. /**
  107501. * If true, the light map contains occlusion information instead of lighting info.
  107502. */
  107503. useLightmapAsShadowmap: boolean;
  107504. /**
  107505. * Instantiates a new PBRMaterial instance.
  107506. *
  107507. * @param name The material name
  107508. * @param scene The scene the material will be use in.
  107509. */
  107510. constructor(name: string, scene: Scene);
  107511. getClassName(): string;
  107512. }
  107513. }
  107514. declare module BABYLON {
  107515. /**
  107516. * The PBR material of BJS following the metal roughness convention.
  107517. *
  107518. * This fits to the PBR convention in the GLTF definition:
  107519. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  107520. */
  107521. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  107522. /**
  107523. * The base color has two different interpretations depending on the value of metalness.
  107524. * When the material is a metal, the base color is the specific measured reflectance value
  107525. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  107526. * of the material.
  107527. */
  107528. baseColor: Color3;
  107529. /**
  107530. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  107531. * well as opacity information in the alpha channel.
  107532. */
  107533. baseTexture: BaseTexture;
  107534. /**
  107535. * Specifies the metallic scalar value of the material.
  107536. * Can also be used to scale the metalness values of the metallic texture.
  107537. */
  107538. metallic: number;
  107539. /**
  107540. * Specifies the roughness scalar value of the material.
  107541. * Can also be used to scale the roughness values of the metallic texture.
  107542. */
  107543. roughness: number;
  107544. /**
  107545. * Texture containing both the metallic value in the B channel and the
  107546. * roughness value in the G channel to keep better precision.
  107547. */
  107548. metallicRoughnessTexture: BaseTexture;
  107549. /**
  107550. * Instantiates a new PBRMetalRoughnessMaterial instance.
  107551. *
  107552. * @param name The material name
  107553. * @param scene The scene the material will be use in.
  107554. */
  107555. constructor(name: string, scene: Scene);
  107556. /**
  107557. * Return the currrent class name of the material.
  107558. */
  107559. getClassName(): string;
  107560. /**
  107561. * Makes a duplicate of the current material.
  107562. * @param name - name to use for the new material.
  107563. */
  107564. clone(name: string): PBRMetallicRoughnessMaterial;
  107565. /**
  107566. * Serialize the material to a parsable JSON object.
  107567. */
  107568. serialize(): any;
  107569. /**
  107570. * Parses a JSON object correponding to the serialize function.
  107571. */
  107572. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  107573. }
  107574. }
  107575. declare module BABYLON {
  107576. /**
  107577. * The PBR material of BJS following the specular glossiness convention.
  107578. *
  107579. * This fits to the PBR convention in the GLTF definition:
  107580. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  107581. */
  107582. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  107583. /**
  107584. * Specifies the diffuse color of the material.
  107585. */
  107586. diffuseColor: Color3;
  107587. /**
  107588. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  107589. * channel.
  107590. */
  107591. diffuseTexture: BaseTexture;
  107592. /**
  107593. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  107594. */
  107595. specularColor: Color3;
  107596. /**
  107597. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  107598. */
  107599. glossiness: number;
  107600. /**
  107601. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  107602. */
  107603. specularGlossinessTexture: BaseTexture;
  107604. /**
  107605. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  107606. *
  107607. * @param name The material name
  107608. * @param scene The scene the material will be use in.
  107609. */
  107610. constructor(name: string, scene: Scene);
  107611. /**
  107612. * Return the currrent class name of the material.
  107613. */
  107614. getClassName(): string;
  107615. /**
  107616. * Makes a duplicate of the current material.
  107617. * @param name - name to use for the new material.
  107618. */
  107619. clone(name: string): PBRSpecularGlossinessMaterial;
  107620. /**
  107621. * Serialize the material to a parsable JSON object.
  107622. */
  107623. serialize(): any;
  107624. /**
  107625. * Parses a JSON object correponding to the serialize function.
  107626. */
  107627. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  107628. }
  107629. }
  107630. declare module BABYLON {
  107631. /**
  107632. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  107633. * It can help converting any input color in a desired output one. This can then be used to create effects
  107634. * from sepia, black and white to sixties or futuristic rendering...
  107635. *
  107636. * The only supported format is currently 3dl.
  107637. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  107638. */
  107639. export class ColorGradingTexture extends BaseTexture {
  107640. /**
  107641. * The current texture matrix. (will always be identity in color grading texture)
  107642. */
  107643. private _textureMatrix;
  107644. /**
  107645. * The texture URL.
  107646. */
  107647. url: string;
  107648. /**
  107649. * Empty line regex stored for GC.
  107650. */
  107651. private static _noneEmptyLineRegex;
  107652. private _engine;
  107653. /**
  107654. * Instantiates a ColorGradingTexture from the following parameters.
  107655. *
  107656. * @param url The location of the color gradind data (currently only supporting 3dl)
  107657. * @param scene The scene the texture will be used in
  107658. */
  107659. constructor(url: string, scene: Scene);
  107660. /**
  107661. * Returns the texture matrix used in most of the material.
  107662. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  107663. */
  107664. getTextureMatrix(): Matrix;
  107665. /**
  107666. * Occurs when the file being loaded is a .3dl LUT file.
  107667. */
  107668. private load3dlTexture;
  107669. /**
  107670. * Starts the loading process of the texture.
  107671. */
  107672. private loadTexture;
  107673. /**
  107674. * Clones the color gradind texture.
  107675. */
  107676. clone(): ColorGradingTexture;
  107677. /**
  107678. * Called during delayed load for textures.
  107679. */
  107680. delayLoad(): void;
  107681. /**
  107682. * Parses a color grading texture serialized by Babylon.
  107683. * @param parsedTexture The texture information being parsedTexture
  107684. * @param scene The scene to load the texture in
  107685. * @param rootUrl The root url of the data assets to load
  107686. * @return A color gradind texture
  107687. */
  107688. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  107689. /**
  107690. * Serializes the LUT texture to json format.
  107691. */
  107692. serialize(): any;
  107693. }
  107694. }
  107695. declare module BABYLON {
  107696. /**
  107697. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  107698. */
  107699. export class EquiRectangularCubeTexture extends BaseTexture {
  107700. /** The six faces of the cube. */
  107701. private static _FacesMapping;
  107702. private _noMipmap;
  107703. private _onLoad;
  107704. private _onError;
  107705. /** The size of the cubemap. */
  107706. private _size;
  107707. /** The buffer of the image. */
  107708. private _buffer;
  107709. /** The width of the input image. */
  107710. private _width;
  107711. /** The height of the input image. */
  107712. private _height;
  107713. /** The URL to the image. */
  107714. url: string;
  107715. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  107716. coordinatesMode: number;
  107717. /**
  107718. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  107719. * @param url The location of the image
  107720. * @param scene The scene the texture will be used in
  107721. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107722. * @param noMipmap Forces to not generate the mipmap if true
  107723. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  107724. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  107725. * @param onLoad — defines a callback called when texture is loaded
  107726. * @param onError — defines a callback called if there is an error
  107727. */
  107728. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  107729. /**
  107730. * Load the image data, by putting the image on a canvas and extracting its buffer.
  107731. */
  107732. private loadImage;
  107733. /**
  107734. * Convert the image buffer into a cubemap and create a CubeTexture.
  107735. */
  107736. private loadTexture;
  107737. /**
  107738. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  107739. * @param buffer The ArrayBuffer that should be converted.
  107740. * @returns The buffer as Float32Array.
  107741. */
  107742. private getFloat32ArrayFromArrayBuffer;
  107743. /**
  107744. * Get the current class name of the texture useful for serialization or dynamic coding.
  107745. * @returns "EquiRectangularCubeTexture"
  107746. */
  107747. getClassName(): string;
  107748. /**
  107749. * Create a clone of the current EquiRectangularCubeTexture and return it.
  107750. * @returns A clone of the current EquiRectangularCubeTexture.
  107751. */
  107752. clone(): EquiRectangularCubeTexture;
  107753. }
  107754. }
  107755. declare module BABYLON {
  107756. /**
  107757. * Based on jsTGALoader - Javascript loader for TGA file
  107758. * By Vincent Thibault
  107759. * @see http://blog.robrowser.com/javascript-tga-loader.html
  107760. */
  107761. export class TGATools {
  107762. private static _TYPE_INDEXED;
  107763. private static _TYPE_RGB;
  107764. private static _TYPE_GREY;
  107765. private static _TYPE_RLE_INDEXED;
  107766. private static _TYPE_RLE_RGB;
  107767. private static _TYPE_RLE_GREY;
  107768. private static _ORIGIN_MASK;
  107769. private static _ORIGIN_SHIFT;
  107770. private static _ORIGIN_BL;
  107771. private static _ORIGIN_BR;
  107772. private static _ORIGIN_UL;
  107773. private static _ORIGIN_UR;
  107774. /**
  107775. * Gets the header of a TGA file
  107776. * @param data defines the TGA data
  107777. * @returns the header
  107778. */
  107779. static GetTGAHeader(data: Uint8Array): any;
  107780. /**
  107781. * Uploads TGA content to a Babylon Texture
  107782. * @hidden
  107783. */
  107784. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  107785. /** @hidden */
  107786. 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;
  107787. /** @hidden */
  107788. 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;
  107789. /** @hidden */
  107790. 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;
  107791. /** @hidden */
  107792. 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;
  107793. /** @hidden */
  107794. 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;
  107795. /** @hidden */
  107796. 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;
  107797. }
  107798. }
  107799. declare module BABYLON {
  107800. /**
  107801. * Implementation of the TGA Texture Loader.
  107802. * @hidden
  107803. */
  107804. export class _TGATextureLoader implements IInternalTextureLoader {
  107805. /**
  107806. * Defines wether the loader supports cascade loading the different faces.
  107807. */
  107808. readonly supportCascades: boolean;
  107809. /**
  107810. * This returns if the loader support the current file information.
  107811. * @param extension defines the file extension of the file being loaded
  107812. * @param textureFormatInUse defines the current compressed format in use iun the engine
  107813. * @param fallback defines the fallback internal texture if any
  107814. * @param isBase64 defines whether the texture is encoded as a base64
  107815. * @param isBuffer defines whether the texture data are stored as a buffer
  107816. * @returns true if the loader can load the specified file
  107817. */
  107818. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  107819. /**
  107820. * Transform the url before loading if required.
  107821. * @param rootUrl the url of the texture
  107822. * @param textureFormatInUse defines the current compressed format in use iun the engine
  107823. * @returns the transformed texture
  107824. */
  107825. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  107826. /**
  107827. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  107828. * @param rootUrl the url of the texture
  107829. * @param textureFormatInUse defines the current compressed format in use iun the engine
  107830. * @returns the fallback texture
  107831. */
  107832. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  107833. /**
  107834. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  107835. * @param data contains the texture data
  107836. * @param texture defines the BabylonJS internal texture
  107837. * @param createPolynomials will be true if polynomials have been requested
  107838. * @param onLoad defines the callback to trigger once the texture is ready
  107839. * @param onError defines the callback to trigger in case of error
  107840. */
  107841. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  107842. /**
  107843. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  107844. * @param data contains the texture data
  107845. * @param texture defines the BabylonJS internal texture
  107846. * @param callback defines the method to call once ready to upload
  107847. */
  107848. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  107849. }
  107850. }
  107851. declare module BABYLON {
  107852. /**
  107853. * 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.
  107854. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  107855. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  107856. */
  107857. export class CustomProceduralTexture extends ProceduralTexture {
  107858. private _animate;
  107859. private _time;
  107860. private _config;
  107861. private _texturePath;
  107862. /**
  107863. * Instantiates a new Custom Procedural Texture.
  107864. * 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.
  107865. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  107866. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  107867. * @param name Define the name of the texture
  107868. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  107869. * @param size Define the size of the texture to create
  107870. * @param scene Define the scene the texture belongs to
  107871. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  107872. * @param generateMipMaps Define if the texture should creates mip maps or not
  107873. */
  107874. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  107875. private _loadJson;
  107876. /**
  107877. * Is the texture ready to be used ? (rendered at least once)
  107878. * @returns true if ready, otherwise, false.
  107879. */
  107880. isReady(): boolean;
  107881. /**
  107882. * Render the texture to its associated render target.
  107883. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  107884. */
  107885. render(useCameraPostProcess?: boolean): void;
  107886. /**
  107887. * Update the list of dependant textures samplers in the shader.
  107888. */
  107889. updateTextures(): void;
  107890. /**
  107891. * Update the uniform values of the procedural texture in the shader.
  107892. */
  107893. updateShaderUniforms(): void;
  107894. /**
  107895. * Define if the texture animates or not.
  107896. */
  107897. animate: boolean;
  107898. }
  107899. }
  107900. declare module BABYLON {
  107901. /** @hidden */
  107902. export var noisePixelShader: {
  107903. name: string;
  107904. shader: string;
  107905. };
  107906. }
  107907. declare module BABYLON {
  107908. /**
  107909. * Class used to generate noise procedural textures
  107910. */
  107911. export class NoiseProceduralTexture extends ProceduralTexture {
  107912. private _time;
  107913. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  107914. brightness: number;
  107915. /** Defines the number of octaves to process */
  107916. octaves: number;
  107917. /** Defines the level of persistence (0.8 by default) */
  107918. persistence: number;
  107919. /** Gets or sets animation speed factor (default is 1) */
  107920. animationSpeedFactor: number;
  107921. /**
  107922. * Creates a new NoiseProceduralTexture
  107923. * @param name defines the name fo the texture
  107924. * @param size defines the size of the texture (default is 256)
  107925. * @param scene defines the hosting scene
  107926. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  107927. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  107928. */
  107929. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  107930. private _updateShaderUniforms;
  107931. protected _getDefines(): string;
  107932. /** Generate the current state of the procedural texture */
  107933. render(useCameraPostProcess?: boolean): void;
  107934. /**
  107935. * Serializes this noise procedural texture
  107936. * @returns a serialized noise procedural texture object
  107937. */
  107938. serialize(): any;
  107939. /**
  107940. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  107941. * @param parsedTexture defines parsed texture data
  107942. * @param scene defines the current scene
  107943. * @param rootUrl defines the root URL containing noise procedural texture information
  107944. * @returns a parsed NoiseProceduralTexture
  107945. */
  107946. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  107947. }
  107948. }
  107949. declare module BABYLON {
  107950. /**
  107951. * Raw cube texture where the raw buffers are passed in
  107952. */
  107953. export class RawCubeTexture extends CubeTexture {
  107954. /**
  107955. * Creates a cube texture where the raw buffers are passed in.
  107956. * @param scene defines the scene the texture is attached to
  107957. * @param data defines the array of data to use to create each face
  107958. * @param size defines the size of the textures
  107959. * @param format defines the format of the data
  107960. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  107961. * @param generateMipMaps defines if the engine should generate the mip levels
  107962. * @param invertY defines if data must be stored with Y axis inverted
  107963. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  107964. * @param compression defines the compression used (null by default)
  107965. */
  107966. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  107967. /**
  107968. * Updates the raw cube texture.
  107969. * @param data defines the data to store
  107970. * @param format defines the data format
  107971. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  107972. * @param invertY defines if data must be stored with Y axis inverted
  107973. * @param compression defines the compression used (null by default)
  107974. * @param level defines which level of the texture to update
  107975. */
  107976. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  107977. /**
  107978. * Updates a raw cube texture with RGBD encoded data.
  107979. * @param data defines the array of data [mipmap][face] to use to create each face
  107980. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  107981. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  107982. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  107983. * @returns a promsie that resolves when the operation is complete
  107984. */
  107985. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  107986. /**
  107987. * Clones the raw cube texture.
  107988. * @return a new cube texture
  107989. */
  107990. clone(): CubeTexture;
  107991. /** @hidden */
  107992. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  107993. }
  107994. }
  107995. declare module BABYLON {
  107996. /**
  107997. * Class used to store 3D textures containing user data
  107998. */
  107999. export class RawTexture3D extends Texture {
  108000. /** Gets or sets the texture format to use */
  108001. format: number;
  108002. private _engine;
  108003. /**
  108004. * Create a new RawTexture3D
  108005. * @param data defines the data of the texture
  108006. * @param width defines the width of the texture
  108007. * @param height defines the height of the texture
  108008. * @param depth defines the depth of the texture
  108009. * @param format defines the texture format to use
  108010. * @param scene defines the hosting scene
  108011. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  108012. * @param invertY defines if texture must be stored with Y axis inverted
  108013. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108014. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  108015. */
  108016. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  108017. /** Gets or sets the texture format to use */
  108018. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  108019. /**
  108020. * Update the texture with new data
  108021. * @param data defines the data to store in the texture
  108022. */
  108023. update(data: ArrayBufferView): void;
  108024. }
  108025. }
  108026. declare module BABYLON {
  108027. /**
  108028. * Creates a refraction texture used by refraction channel of the standard material.
  108029. * It is like a mirror but to see through a material.
  108030. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108031. */
  108032. export class RefractionTexture extends RenderTargetTexture {
  108033. /**
  108034. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  108035. * 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.
  108036. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108037. */
  108038. refractionPlane: Plane;
  108039. /**
  108040. * Define how deep under the surface we should see.
  108041. */
  108042. depth: number;
  108043. /**
  108044. * Creates a refraction texture used by refraction channel of the standard material.
  108045. * It is like a mirror but to see through a material.
  108046. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108047. * @param name Define the texture name
  108048. * @param size Define the size of the underlying texture
  108049. * @param scene Define the scene the refraction belongs to
  108050. * @param generateMipMaps Define if we need to generate mips level for the refraction
  108051. */
  108052. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  108053. /**
  108054. * Clone the refraction texture.
  108055. * @returns the cloned texture
  108056. */
  108057. clone(): RefractionTexture;
  108058. /**
  108059. * Serialize the texture to a JSON representation you could use in Parse later on
  108060. * @returns the serialized JSON representation
  108061. */
  108062. serialize(): any;
  108063. }
  108064. }
  108065. declare module BABYLON {
  108066. /**
  108067. * Configuration for Draco compression
  108068. */
  108069. export interface IDracoCompressionConfiguration {
  108070. /**
  108071. * Configuration for the decoder.
  108072. */
  108073. decoder?: {
  108074. /**
  108075. * The url to the WebAssembly module.
  108076. */
  108077. wasmUrl?: string;
  108078. /**
  108079. * The url to the WebAssembly binary.
  108080. */
  108081. wasmBinaryUrl?: string;
  108082. /**
  108083. * The url to the fallback JavaScript module.
  108084. */
  108085. fallbackUrl?: string;
  108086. };
  108087. }
  108088. /**
  108089. * Draco compression (https://google.github.io/draco/)
  108090. *
  108091. * This class wraps the Draco module.
  108092. *
  108093. * **Encoder**
  108094. *
  108095. * The encoder is not currently implemented.
  108096. *
  108097. * **Decoder**
  108098. *
  108099. * 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.
  108100. *
  108101. * To update the configuration, use the following code:
  108102. * ```javascript
  108103. * DracoCompression.Configuration = {
  108104. * decoder: {
  108105. * wasmUrl: "<url to the WebAssembly library>",
  108106. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  108107. * fallbackUrl: "<url to the fallback JavaScript library>",
  108108. * }
  108109. * };
  108110. * ```
  108111. *
  108112. * 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.
  108113. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  108114. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  108115. *
  108116. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  108117. * ```javascript
  108118. * var dracoCompression = new DracoCompression();
  108119. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  108120. * [VertexBuffer.PositionKind]: 0
  108121. * });
  108122. * ```
  108123. *
  108124. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  108125. */
  108126. export class DracoCompression implements IDisposable {
  108127. private static _DecoderModulePromise;
  108128. /**
  108129. * The configuration. Defaults to the following urls:
  108130. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  108131. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  108132. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  108133. */
  108134. static Configuration: IDracoCompressionConfiguration;
  108135. /**
  108136. * Returns true if the decoder is available.
  108137. */
  108138. static readonly DecoderAvailable: boolean;
  108139. /**
  108140. * Constructor
  108141. */
  108142. constructor();
  108143. /**
  108144. * Stop all async operations and release resources.
  108145. */
  108146. dispose(): void;
  108147. /**
  108148. * Decode Draco compressed mesh data to vertex data.
  108149. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  108150. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  108151. * @returns A promise that resolves with the decoded vertex data
  108152. */
  108153. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  108154. [kind: string]: number;
  108155. }): Promise<VertexData>;
  108156. private static _GetDecoderModule;
  108157. private static _LoadScriptAsync;
  108158. private static _LoadFileAsync;
  108159. }
  108160. }
  108161. declare module BABYLON {
  108162. /**
  108163. * Class for building Constructive Solid Geometry
  108164. */
  108165. export class CSG {
  108166. private polygons;
  108167. /**
  108168. * The world matrix
  108169. */
  108170. matrix: Matrix;
  108171. /**
  108172. * Stores the position
  108173. */
  108174. position: Vector3;
  108175. /**
  108176. * Stores the rotation
  108177. */
  108178. rotation: Vector3;
  108179. /**
  108180. * Stores the rotation quaternion
  108181. */
  108182. rotationQuaternion: Nullable<Quaternion>;
  108183. /**
  108184. * Stores the scaling vector
  108185. */
  108186. scaling: Vector3;
  108187. /**
  108188. * Convert the Mesh to CSG
  108189. * @param mesh The Mesh to convert to CSG
  108190. * @returns A new CSG from the Mesh
  108191. */
  108192. static FromMesh(mesh: Mesh): CSG;
  108193. /**
  108194. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  108195. * @param polygons Polygons used to construct a CSG solid
  108196. */
  108197. private static FromPolygons;
  108198. /**
  108199. * Clones, or makes a deep copy, of the CSG
  108200. * @returns A new CSG
  108201. */
  108202. clone(): CSG;
  108203. /**
  108204. * Unions this CSG with another CSG
  108205. * @param csg The CSG to union against this CSG
  108206. * @returns The unioned CSG
  108207. */
  108208. union(csg: CSG): CSG;
  108209. /**
  108210. * Unions this CSG with another CSG in place
  108211. * @param csg The CSG to union against this CSG
  108212. */
  108213. unionInPlace(csg: CSG): void;
  108214. /**
  108215. * Subtracts this CSG with another CSG
  108216. * @param csg The CSG to subtract against this CSG
  108217. * @returns A new CSG
  108218. */
  108219. subtract(csg: CSG): CSG;
  108220. /**
  108221. * Subtracts this CSG with another CSG in place
  108222. * @param csg The CSG to subtact against this CSG
  108223. */
  108224. subtractInPlace(csg: CSG): void;
  108225. /**
  108226. * Intersect this CSG with another CSG
  108227. * @param csg The CSG to intersect against this CSG
  108228. * @returns A new CSG
  108229. */
  108230. intersect(csg: CSG): CSG;
  108231. /**
  108232. * Intersects this CSG with another CSG in place
  108233. * @param csg The CSG to intersect against this CSG
  108234. */
  108235. intersectInPlace(csg: CSG): void;
  108236. /**
  108237. * Return a new CSG solid with solid and empty space switched. This solid is
  108238. * not modified.
  108239. * @returns A new CSG solid with solid and empty space switched
  108240. */
  108241. inverse(): CSG;
  108242. /**
  108243. * Inverses the CSG in place
  108244. */
  108245. inverseInPlace(): void;
  108246. /**
  108247. * This is used to keep meshes transformations so they can be restored
  108248. * when we build back a Babylon Mesh
  108249. * NB : All CSG operations are performed in world coordinates
  108250. * @param csg The CSG to copy the transform attributes from
  108251. * @returns This CSG
  108252. */
  108253. copyTransformAttributes(csg: CSG): CSG;
  108254. /**
  108255. * Build Raw mesh from CSG
  108256. * Coordinates here are in world space
  108257. * @param name The name of the mesh geometry
  108258. * @param scene The Scene
  108259. * @param keepSubMeshes Specifies if the submeshes should be kept
  108260. * @returns A new Mesh
  108261. */
  108262. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  108263. /**
  108264. * Build Mesh from CSG taking material and transforms into account
  108265. * @param name The name of the Mesh
  108266. * @param material The material of the Mesh
  108267. * @param scene The Scene
  108268. * @param keepSubMeshes Specifies if submeshes should be kept
  108269. * @returns The new Mesh
  108270. */
  108271. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  108272. }
  108273. }
  108274. declare module BABYLON {
  108275. /**
  108276. * Class used to create a trail following a mesh
  108277. */
  108278. export class TrailMesh extends Mesh {
  108279. private _generator;
  108280. private _autoStart;
  108281. private _running;
  108282. private _diameter;
  108283. private _length;
  108284. private _sectionPolygonPointsCount;
  108285. private _sectionVectors;
  108286. private _sectionNormalVectors;
  108287. private _beforeRenderObserver;
  108288. /**
  108289. * @constructor
  108290. * @param name The value used by scene.getMeshByName() to do a lookup.
  108291. * @param generator The mesh to generate a trail.
  108292. * @param scene The scene to add this mesh to.
  108293. * @param diameter Diameter of trailing mesh. Default is 1.
  108294. * @param length Length of trailing mesh. Default is 60.
  108295. * @param autoStart Automatically start trailing mesh. Default true.
  108296. */
  108297. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  108298. /**
  108299. * "TrailMesh"
  108300. * @returns "TrailMesh"
  108301. */
  108302. getClassName(): string;
  108303. private _createMesh;
  108304. /**
  108305. * Start trailing mesh.
  108306. */
  108307. start(): void;
  108308. /**
  108309. * Stop trailing mesh.
  108310. */
  108311. stop(): void;
  108312. /**
  108313. * Update trailing mesh geometry.
  108314. */
  108315. update(): void;
  108316. /**
  108317. * Returns a new TrailMesh object.
  108318. * @param name is a string, the name given to the new mesh
  108319. * @param newGenerator use new generator object for cloned trail mesh
  108320. * @returns a new mesh
  108321. */
  108322. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  108323. /**
  108324. * Serializes this trail mesh
  108325. * @param serializationObject object to write serialization to
  108326. */
  108327. serialize(serializationObject: any): void;
  108328. /**
  108329. * Parses a serialized trail mesh
  108330. * @param parsedMesh the serialized mesh
  108331. * @param scene the scene to create the trail mesh in
  108332. * @returns the created trail mesh
  108333. */
  108334. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  108335. }
  108336. }
  108337. declare module BABYLON {
  108338. /**
  108339. * Class containing static functions to help procedurally build meshes
  108340. */
  108341. export class TorusKnotBuilder {
  108342. /**
  108343. * Creates a torus knot mesh
  108344. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  108345. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  108346. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  108347. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  108348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108351. * @param name defines the name of the mesh
  108352. * @param options defines the options used to create the mesh
  108353. * @param scene defines the hosting scene
  108354. * @returns the torus knot mesh
  108355. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  108356. */
  108357. static CreateTorusKnot(name: string, options: {
  108358. radius?: number;
  108359. tube?: number;
  108360. radialSegments?: number;
  108361. tubularSegments?: number;
  108362. p?: number;
  108363. q?: number;
  108364. updatable?: boolean;
  108365. sideOrientation?: number;
  108366. frontUVs?: Vector4;
  108367. backUVs?: Vector4;
  108368. }, scene: any): Mesh;
  108369. }
  108370. }
  108371. declare module BABYLON {
  108372. /**
  108373. * Polygon
  108374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108375. */
  108376. export class Polygon {
  108377. /**
  108378. * Creates a rectangle
  108379. * @param xmin bottom X coord
  108380. * @param ymin bottom Y coord
  108381. * @param xmax top X coord
  108382. * @param ymax top Y coord
  108383. * @returns points that make the resulting rectation
  108384. */
  108385. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  108386. /**
  108387. * Creates a circle
  108388. * @param radius radius of circle
  108389. * @param cx scale in x
  108390. * @param cy scale in y
  108391. * @param numberOfSides number of sides that make up the circle
  108392. * @returns points that make the resulting circle
  108393. */
  108394. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  108395. /**
  108396. * Creates a polygon from input string
  108397. * @param input Input polygon data
  108398. * @returns the parsed points
  108399. */
  108400. static Parse(input: string): Vector2[];
  108401. /**
  108402. * Starts building a polygon from x and y coordinates
  108403. * @param x x coordinate
  108404. * @param y y coordinate
  108405. * @returns the started path2
  108406. */
  108407. static StartingAt(x: number, y: number): Path2;
  108408. }
  108409. /**
  108410. * Builds a polygon
  108411. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  108412. */
  108413. export class PolygonMeshBuilder {
  108414. private _points;
  108415. private _outlinepoints;
  108416. private _holes;
  108417. private _name;
  108418. private _scene;
  108419. private _epoints;
  108420. private _eholes;
  108421. private _addToepoint;
  108422. /**
  108423. * Babylon reference to the earcut plugin.
  108424. */
  108425. bjsEarcut: any;
  108426. /**
  108427. * Creates a PolygonMeshBuilder
  108428. * @param name name of the builder
  108429. * @param contours Path of the polygon
  108430. * @param scene scene to add to when creating the mesh
  108431. * @param earcutInjection can be used to inject your own earcut reference
  108432. */
  108433. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  108434. /**
  108435. * Adds a whole within the polygon
  108436. * @param hole Array of points defining the hole
  108437. * @returns this
  108438. */
  108439. addHole(hole: Vector2[]): PolygonMeshBuilder;
  108440. /**
  108441. * Creates the polygon
  108442. * @param updatable If the mesh should be updatable
  108443. * @param depth The depth of the mesh created
  108444. * @returns the created mesh
  108445. */
  108446. build(updatable?: boolean, depth?: number): Mesh;
  108447. /**
  108448. * Creates the polygon
  108449. * @param depth The depth of the mesh created
  108450. * @returns the created VertexData
  108451. */
  108452. buildVertexData(depth?: number): VertexData;
  108453. /**
  108454. * Adds a side to the polygon
  108455. * @param positions points that make the polygon
  108456. * @param normals normals of the polygon
  108457. * @param uvs uvs of the polygon
  108458. * @param indices indices of the polygon
  108459. * @param bounds bounds of the polygon
  108460. * @param points points of the polygon
  108461. * @param depth depth of the polygon
  108462. * @param flip flip of the polygon
  108463. */
  108464. private addSide;
  108465. }
  108466. }
  108467. declare module BABYLON {
  108468. /**
  108469. * Class containing static functions to help procedurally build meshes
  108470. */
  108471. export class PolygonBuilder {
  108472. /**
  108473. * Creates a polygon mesh
  108474. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  108475. * * 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
  108476. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  108479. * * Remember you can only change the shape positions, not their number when updating a polygon
  108480. * @param name defines the name of the mesh
  108481. * @param options defines the options used to create the mesh
  108482. * @param scene defines the hosting scene
  108483. * @param earcutInjection can be used to inject your own earcut reference
  108484. * @returns the polygon mesh
  108485. */
  108486. static CreatePolygon(name: string, options: {
  108487. shape: Vector3[];
  108488. holes?: Vector3[][];
  108489. depth?: number;
  108490. faceUV?: Vector4[];
  108491. faceColors?: Color4[];
  108492. updatable?: boolean;
  108493. sideOrientation?: number;
  108494. frontUVs?: Vector4;
  108495. backUVs?: Vector4;
  108496. }, scene: Scene, earcutInjection?: any): Mesh;
  108497. /**
  108498. * Creates an extruded polygon mesh, with depth in the Y direction.
  108499. * * 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)
  108500. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108501. * @param name defines the name of the mesh
  108502. * @param options defines the options used to create the mesh
  108503. * @param scene defines the hosting scene
  108504. * @param earcutInjection can be used to inject your own earcut reference
  108505. * @returns the polygon mesh
  108506. */
  108507. static ExtrudePolygon(name: string, options: {
  108508. shape: Vector3[];
  108509. holes?: Vector3[][];
  108510. depth?: number;
  108511. faceUV?: Vector4[];
  108512. faceColors?: Color4[];
  108513. updatable?: boolean;
  108514. sideOrientation?: number;
  108515. frontUVs?: Vector4;
  108516. backUVs?: Vector4;
  108517. }, scene: Scene, earcutInjection?: any): Mesh;
  108518. }
  108519. }
  108520. declare module BABYLON {
  108521. /**
  108522. * Class containing static functions to help procedurally build meshes
  108523. */
  108524. export class LatheBuilder {
  108525. /**
  108526. * Creates lathe mesh.
  108527. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  108528. * * 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
  108529. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  108530. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  108531. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  108532. * * 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
  108533. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  108534. * * 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
  108535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108536. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108537. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108539. * @param name defines the name of the mesh
  108540. * @param options defines the options used to create the mesh
  108541. * @param scene defines the hosting scene
  108542. * @returns the lathe mesh
  108543. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  108544. */
  108545. static CreateLathe(name: string, options: {
  108546. shape: Vector3[];
  108547. radius?: number;
  108548. tessellation?: number;
  108549. clip?: number;
  108550. arc?: number;
  108551. closed?: boolean;
  108552. updatable?: boolean;
  108553. sideOrientation?: number;
  108554. frontUVs?: Vector4;
  108555. backUVs?: Vector4;
  108556. cap?: number;
  108557. invertUV?: boolean;
  108558. }, scene: Scene): Mesh;
  108559. }
  108560. }
  108561. declare module BABYLON {
  108562. /**
  108563. * Class containing static functions to help procedurally build meshes
  108564. */
  108565. export class TubeBuilder {
  108566. /**
  108567. * Creates a tube mesh.
  108568. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108569. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  108570. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  108571. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  108572. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  108573. * * 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)
  108574. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  108575. * * 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
  108576. * * 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
  108577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108579. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108581. * @param name defines the name of the mesh
  108582. * @param options defines the options used to create the mesh
  108583. * @param scene defines the hosting scene
  108584. * @returns the tube mesh
  108585. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108586. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  108587. */
  108588. static CreateTube(name: string, options: {
  108589. path: Vector3[];
  108590. radius?: number;
  108591. tessellation?: number;
  108592. radiusFunction?: {
  108593. (i: number, distance: number): number;
  108594. };
  108595. cap?: number;
  108596. arc?: number;
  108597. updatable?: boolean;
  108598. sideOrientation?: number;
  108599. frontUVs?: Vector4;
  108600. backUVs?: Vector4;
  108601. instance?: Mesh;
  108602. invertUV?: boolean;
  108603. }, scene: Scene): Mesh;
  108604. }
  108605. }
  108606. declare module BABYLON {
  108607. /**
  108608. * Class containing static functions to help procedurally build meshes
  108609. */
  108610. export class IcoSphereBuilder {
  108611. /**
  108612. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  108613. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  108614. * * 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`)
  108615. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  108616. * * 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
  108617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108620. * @param name defines the name of the mesh
  108621. * @param options defines the options used to create the mesh
  108622. * @param scene defines the hosting scene
  108623. * @returns the icosahedron mesh
  108624. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  108625. */
  108626. static CreateIcoSphere(name: string, options: {
  108627. radius?: number;
  108628. radiusX?: number;
  108629. radiusY?: number;
  108630. radiusZ?: number;
  108631. flat?: boolean;
  108632. subdivisions?: number;
  108633. sideOrientation?: number;
  108634. frontUVs?: Vector4;
  108635. backUVs?: Vector4;
  108636. updatable?: boolean;
  108637. }, scene: Scene): Mesh;
  108638. }
  108639. }
  108640. declare module BABYLON {
  108641. /**
  108642. * Class containing static functions to help procedurally build meshes
  108643. */
  108644. export class DecalBuilder {
  108645. /**
  108646. * Creates a decal mesh.
  108647. * 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
  108648. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  108649. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  108650. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  108651. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  108652. * @param name defines the name of the mesh
  108653. * @param sourceMesh defines the mesh where the decal must be applied
  108654. * @param options defines the options used to create the mesh
  108655. * @param scene defines the hosting scene
  108656. * @returns the decal mesh
  108657. * @see https://doc.babylonjs.com/how_to/decals
  108658. */
  108659. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  108660. position?: Vector3;
  108661. normal?: Vector3;
  108662. size?: Vector3;
  108663. angle?: number;
  108664. }): Mesh;
  108665. }
  108666. }
  108667. declare module BABYLON {
  108668. /**
  108669. * Class containing static functions to help procedurally build meshes
  108670. */
  108671. export class MeshBuilder {
  108672. /**
  108673. * Creates a box mesh
  108674. * * The parameter `size` sets the size (float) of each box side (default 1)
  108675. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108676. * * 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)
  108677. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108681. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108682. * @param name defines the name of the mesh
  108683. * @param options defines the options used to create the mesh
  108684. * @param scene defines the hosting scene
  108685. * @returns the box mesh
  108686. */
  108687. static CreateBox(name: string, options: {
  108688. size?: number;
  108689. width?: number;
  108690. height?: number;
  108691. depth?: number;
  108692. faceUV?: Vector4[];
  108693. faceColors?: Color4[];
  108694. sideOrientation?: number;
  108695. frontUVs?: Vector4;
  108696. backUVs?: Vector4;
  108697. updatable?: boolean;
  108698. }, scene?: Nullable<Scene>): Mesh;
  108699. /**
  108700. * Creates a sphere mesh
  108701. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108702. * * 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`)
  108703. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108704. * * 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
  108705. * * 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)
  108706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108709. * @param name defines the name of the mesh
  108710. * @param options defines the options used to create the mesh
  108711. * @param scene defines the hosting scene
  108712. * @returns the sphere mesh
  108713. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108714. */
  108715. static CreateSphere(name: string, options: {
  108716. segments?: number;
  108717. diameter?: number;
  108718. diameterX?: number;
  108719. diameterY?: number;
  108720. diameterZ?: number;
  108721. arc?: number;
  108722. slice?: number;
  108723. sideOrientation?: number;
  108724. frontUVs?: Vector4;
  108725. backUVs?: Vector4;
  108726. updatable?: boolean;
  108727. }, scene: any): Mesh;
  108728. /**
  108729. * Creates a plane polygonal mesh. By default, this is a disc
  108730. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  108731. * * 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
  108732. * * 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
  108733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108736. * @param name defines the name of the mesh
  108737. * @param options defines the options used to create the mesh
  108738. * @param scene defines the hosting scene
  108739. * @returns the plane polygonal mesh
  108740. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  108741. */
  108742. static CreateDisc(name: string, options: {
  108743. radius?: number;
  108744. tessellation?: number;
  108745. arc?: number;
  108746. updatable?: boolean;
  108747. sideOrientation?: number;
  108748. frontUVs?: Vector4;
  108749. backUVs?: Vector4;
  108750. }, scene?: Nullable<Scene>): Mesh;
  108751. /**
  108752. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  108753. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  108754. * * 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`)
  108755. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  108756. * * 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
  108757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108760. * @param name defines the name of the mesh
  108761. * @param options defines the options used to create the mesh
  108762. * @param scene defines the hosting scene
  108763. * @returns the icosahedron mesh
  108764. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  108765. */
  108766. static CreateIcoSphere(name: string, options: {
  108767. radius?: number;
  108768. radiusX?: number;
  108769. radiusY?: number;
  108770. radiusZ?: number;
  108771. flat?: boolean;
  108772. subdivisions?: number;
  108773. sideOrientation?: number;
  108774. frontUVs?: Vector4;
  108775. backUVs?: Vector4;
  108776. updatable?: boolean;
  108777. }, scene: Scene): Mesh;
  108778. /**
  108779. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108780. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108781. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108782. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108783. * * 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
  108784. * * 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
  108785. * * 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
  108786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108788. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108789. * * 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
  108790. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108791. * * 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
  108792. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108794. * @param name defines the name of the mesh
  108795. * @param options defines the options used to create the mesh
  108796. * @param scene defines the hosting scene
  108797. * @returns the ribbon mesh
  108798. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108799. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108800. */
  108801. static CreateRibbon(name: string, options: {
  108802. pathArray: Vector3[][];
  108803. closeArray?: boolean;
  108804. closePath?: boolean;
  108805. offset?: number;
  108806. updatable?: boolean;
  108807. sideOrientation?: number;
  108808. frontUVs?: Vector4;
  108809. backUVs?: Vector4;
  108810. instance?: Mesh;
  108811. invertUV?: boolean;
  108812. uvs?: Vector2[];
  108813. colors?: Color4[];
  108814. }, scene?: Nullable<Scene>): Mesh;
  108815. /**
  108816. * Creates a cylinder or a cone mesh
  108817. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  108818. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  108819. * * 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.
  108820. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  108821. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  108822. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  108823. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  108824. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  108825. * * 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).
  108826. * * 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
  108827. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  108828. * * 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
  108829. * * 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.
  108830. * * If `enclose` is false, a ring surface is one element.
  108831. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  108832. * * 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
  108833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108836. * @param name defines the name of the mesh
  108837. * @param options defines the options used to create the mesh
  108838. * @param scene defines the hosting scene
  108839. * @returns the cylinder mesh
  108840. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  108841. */
  108842. static CreateCylinder(name: string, options: {
  108843. height?: number;
  108844. diameterTop?: number;
  108845. diameterBottom?: number;
  108846. diameter?: number;
  108847. tessellation?: number;
  108848. subdivisions?: number;
  108849. arc?: number;
  108850. faceColors?: Color4[];
  108851. faceUV?: Vector4[];
  108852. updatable?: boolean;
  108853. hasRings?: boolean;
  108854. enclose?: boolean;
  108855. sideOrientation?: number;
  108856. frontUVs?: Vector4;
  108857. backUVs?: Vector4;
  108858. }, scene: any): Mesh;
  108859. /**
  108860. * Creates a torus mesh
  108861. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  108862. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  108863. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  108864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108865. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108867. * @param name defines the name of the mesh
  108868. * @param options defines the options used to create the mesh
  108869. * @param scene defines the hosting scene
  108870. * @returns the torus mesh
  108871. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  108872. */
  108873. static CreateTorus(name: string, options: {
  108874. diameter?: number;
  108875. thickness?: number;
  108876. tessellation?: number;
  108877. updatable?: boolean;
  108878. sideOrientation?: number;
  108879. frontUVs?: Vector4;
  108880. backUVs?: Vector4;
  108881. }, scene: any): Mesh;
  108882. /**
  108883. * Creates a torus knot mesh
  108884. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  108885. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  108886. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  108887. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  108888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108891. * @param name defines the name of the mesh
  108892. * @param options defines the options used to create the mesh
  108893. * @param scene defines the hosting scene
  108894. * @returns the torus knot mesh
  108895. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  108896. */
  108897. static CreateTorusKnot(name: string, options: {
  108898. radius?: number;
  108899. tube?: number;
  108900. radialSegments?: number;
  108901. tubularSegments?: number;
  108902. p?: number;
  108903. q?: number;
  108904. updatable?: boolean;
  108905. sideOrientation?: number;
  108906. frontUVs?: Vector4;
  108907. backUVs?: Vector4;
  108908. }, scene: any): Mesh;
  108909. /**
  108910. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  108911. * * 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
  108912. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  108913. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  108914. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  108915. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  108916. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  108917. * * 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
  108918. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  108919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  108921. * @param name defines the name of the new line system
  108922. * @param options defines the options used to create the line system
  108923. * @param scene defines the hosting scene
  108924. * @returns a new line system mesh
  108925. */
  108926. static CreateLineSystem(name: string, options: {
  108927. lines: Vector3[][];
  108928. updatable?: boolean;
  108929. instance?: Nullable<LinesMesh>;
  108930. colors?: Nullable<Color4[][]>;
  108931. useVertexAlpha?: boolean;
  108932. }, scene: Nullable<Scene>): LinesMesh;
  108933. /**
  108934. * Creates a line mesh
  108935. * 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
  108936. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108937. * * The parameter `points` is an array successive Vector3
  108938. * * 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
  108939. * * The optional parameter `colors` is an array of successive Color4, one per line point
  108940. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  108941. * * When updating an instance, remember that only point positions can change, not the number of points
  108942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  108944. * @param name defines the name of the new line system
  108945. * @param options defines the options used to create the line system
  108946. * @param scene defines the hosting scene
  108947. * @returns a new line mesh
  108948. */
  108949. static CreateLines(name: string, options: {
  108950. points: Vector3[];
  108951. updatable?: boolean;
  108952. instance?: Nullable<LinesMesh>;
  108953. colors?: Color4[];
  108954. useVertexAlpha?: boolean;
  108955. }, scene?: Nullable<Scene>): LinesMesh;
  108956. /**
  108957. * Creates a dashed line mesh
  108958. * * 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
  108959. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108960. * * The parameter `points` is an array successive Vector3
  108961. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  108962. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  108963. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108964. * * 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
  108965. * * When updating an instance, remember that only point positions can change, not the number of points
  108966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108967. * @param name defines the name of the mesh
  108968. * @param options defines the options used to create the mesh
  108969. * @param scene defines the hosting scene
  108970. * @returns the dashed line mesh
  108971. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  108972. */
  108973. static CreateDashedLines(name: string, options: {
  108974. points: Vector3[];
  108975. dashSize?: number;
  108976. gapSize?: number;
  108977. dashNb?: number;
  108978. updatable?: boolean;
  108979. instance?: LinesMesh;
  108980. }, scene?: Nullable<Scene>): LinesMesh;
  108981. /**
  108982. * 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.
  108983. * * 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.
  108984. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108985. * * 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.
  108986. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  108987. * * 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
  108988. * * 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
  108989. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  108990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108992. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108994. * @param name defines the name of the mesh
  108995. * @param options defines the options used to create the mesh
  108996. * @param scene defines the hosting scene
  108997. * @returns the extruded shape mesh
  108998. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108999. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109000. */
  109001. static ExtrudeShape(name: string, options: {
  109002. shape: Vector3[];
  109003. path: Vector3[];
  109004. scale?: number;
  109005. rotation?: number;
  109006. cap?: number;
  109007. updatable?: boolean;
  109008. sideOrientation?: number;
  109009. frontUVs?: Vector4;
  109010. backUVs?: Vector4;
  109011. instance?: Mesh;
  109012. invertUV?: boolean;
  109013. }, scene?: Nullable<Scene>): Mesh;
  109014. /**
  109015. * Creates an custom extruded shape mesh.
  109016. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  109017. * * 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.
  109018. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109019. * * 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
  109020. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  109021. * * 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
  109022. * * It must returns a float value that will be the scale value applied to the shape on each path point
  109023. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109024. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  109025. * * 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
  109026. * * 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
  109027. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  109028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109030. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109032. * @param name defines the name of the mesh
  109033. * @param options defines the options used to create the mesh
  109034. * @param scene defines the hosting scene
  109035. * @returns the custom extruded shape mesh
  109036. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  109037. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109039. */
  109040. static ExtrudeShapeCustom(name: string, options: {
  109041. shape: Vector3[];
  109042. path: Vector3[];
  109043. scaleFunction?: any;
  109044. rotationFunction?: any;
  109045. ribbonCloseArray?: boolean;
  109046. ribbonClosePath?: boolean;
  109047. cap?: number;
  109048. updatable?: boolean;
  109049. sideOrientation?: number;
  109050. frontUVs?: Vector4;
  109051. backUVs?: Vector4;
  109052. instance?: Mesh;
  109053. invertUV?: boolean;
  109054. }, scene: Scene): Mesh;
  109055. /**
  109056. * Creates lathe mesh.
  109057. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109058. * * 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
  109059. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109060. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109061. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109062. * * 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
  109063. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109064. * * 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
  109065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109067. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109069. * @param name defines the name of the mesh
  109070. * @param options defines the options used to create the mesh
  109071. * @param scene defines the hosting scene
  109072. * @returns the lathe mesh
  109073. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109074. */
  109075. static CreateLathe(name: string, options: {
  109076. shape: Vector3[];
  109077. radius?: number;
  109078. tessellation?: number;
  109079. clip?: number;
  109080. arc?: number;
  109081. closed?: boolean;
  109082. updatable?: boolean;
  109083. sideOrientation?: number;
  109084. frontUVs?: Vector4;
  109085. backUVs?: Vector4;
  109086. cap?: number;
  109087. invertUV?: boolean;
  109088. }, scene: Scene): Mesh;
  109089. /**
  109090. * Creates a plane mesh
  109091. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109092. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109093. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109097. * @param name defines the name of the mesh
  109098. * @param options defines the options used to create the mesh
  109099. * @param scene defines the hosting scene
  109100. * @returns the plane mesh
  109101. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109102. */
  109103. static CreatePlane(name: string, options: {
  109104. size?: number;
  109105. width?: number;
  109106. height?: number;
  109107. sideOrientation?: number;
  109108. frontUVs?: Vector4;
  109109. backUVs?: Vector4;
  109110. updatable?: boolean;
  109111. sourcePlane?: Plane;
  109112. }, scene: Scene): Mesh;
  109113. /**
  109114. * Creates a ground mesh
  109115. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109116. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109118. * @param name defines the name of the mesh
  109119. * @param options defines the options used to create the mesh
  109120. * @param scene defines the hosting scene
  109121. * @returns the ground mesh
  109122. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109123. */
  109124. static CreateGround(name: string, options: {
  109125. width?: number;
  109126. height?: number;
  109127. subdivisions?: number;
  109128. subdivisionsX?: number;
  109129. subdivisionsY?: number;
  109130. updatable?: boolean;
  109131. }, scene: any): Mesh;
  109132. /**
  109133. * Creates a tiled ground mesh
  109134. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109135. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109136. * * 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
  109137. * * 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
  109138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109139. * @param name defines the name of the mesh
  109140. * @param options defines the options used to create the mesh
  109141. * @param scene defines the hosting scene
  109142. * @returns the tiled ground mesh
  109143. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109144. */
  109145. static CreateTiledGround(name: string, options: {
  109146. xmin: number;
  109147. zmin: number;
  109148. xmax: number;
  109149. zmax: number;
  109150. subdivisions?: {
  109151. w: number;
  109152. h: number;
  109153. };
  109154. precision?: {
  109155. w: number;
  109156. h: number;
  109157. };
  109158. updatable?: boolean;
  109159. }, scene: Scene): Mesh;
  109160. /**
  109161. * Creates a ground mesh from a height map
  109162. * * The parameter `url` sets the URL of the height map image resource.
  109163. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109164. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109165. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109166. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109167. * * 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.
  109168. * * 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).
  109169. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109171. * @param name defines the name of the mesh
  109172. * @param url defines the url to the height map
  109173. * @param options defines the options used to create the mesh
  109174. * @param scene defines the hosting scene
  109175. * @returns the ground mesh
  109176. * @see https://doc.babylonjs.com/babylon101/height_map
  109177. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109178. */
  109179. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109180. width?: number;
  109181. height?: number;
  109182. subdivisions?: number;
  109183. minHeight?: number;
  109184. maxHeight?: number;
  109185. colorFilter?: Color3;
  109186. alphaFilter?: number;
  109187. updatable?: boolean;
  109188. onReady?: (mesh: GroundMesh) => void;
  109189. }, scene: Scene): GroundMesh;
  109190. /**
  109191. * Creates a polygon mesh
  109192. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109193. * * 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
  109194. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109197. * * Remember you can only change the shape positions, not their number when updating a polygon
  109198. * @param name defines the name of the mesh
  109199. * @param options defines the options used to create the mesh
  109200. * @param scene defines the hosting scene
  109201. * @param earcutInjection can be used to inject your own earcut reference
  109202. * @returns the polygon mesh
  109203. */
  109204. static CreatePolygon(name: string, options: {
  109205. shape: Vector3[];
  109206. holes?: Vector3[][];
  109207. depth?: number;
  109208. faceUV?: Vector4[];
  109209. faceColors?: Color4[];
  109210. updatable?: boolean;
  109211. sideOrientation?: number;
  109212. frontUVs?: Vector4;
  109213. backUVs?: Vector4;
  109214. }, scene: Scene, earcutInjection?: any): Mesh;
  109215. /**
  109216. * Creates an extruded polygon mesh, with depth in the Y direction.
  109217. * * 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)
  109218. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109219. * @param name defines the name of the mesh
  109220. * @param options defines the options used to create the mesh
  109221. * @param scene defines the hosting scene
  109222. * @param earcutInjection can be used to inject your own earcut reference
  109223. * @returns the polygon mesh
  109224. */
  109225. static ExtrudePolygon(name: string, options: {
  109226. shape: Vector3[];
  109227. holes?: Vector3[][];
  109228. depth?: number;
  109229. faceUV?: Vector4[];
  109230. faceColors?: Color4[];
  109231. updatable?: boolean;
  109232. sideOrientation?: number;
  109233. frontUVs?: Vector4;
  109234. backUVs?: Vector4;
  109235. }, scene: Scene, earcutInjection?: any): Mesh;
  109236. /**
  109237. * Creates a tube mesh.
  109238. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109239. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109240. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109241. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109242. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109243. * * 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)
  109244. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109245. * * 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
  109246. * * 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
  109247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109248. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109251. * @param name defines the name of the mesh
  109252. * @param options defines the options used to create the mesh
  109253. * @param scene defines the hosting scene
  109254. * @returns the tube mesh
  109255. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109256. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109257. */
  109258. static CreateTube(name: string, options: {
  109259. path: Vector3[];
  109260. radius?: number;
  109261. tessellation?: number;
  109262. radiusFunction?: {
  109263. (i: number, distance: number): number;
  109264. };
  109265. cap?: number;
  109266. arc?: number;
  109267. updatable?: boolean;
  109268. sideOrientation?: number;
  109269. frontUVs?: Vector4;
  109270. backUVs?: Vector4;
  109271. instance?: Mesh;
  109272. invertUV?: boolean;
  109273. }, scene: Scene): Mesh;
  109274. /**
  109275. * Creates a polyhedron mesh
  109276. * * 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
  109277. * * The parameter `size` (positive float, default 1) sets the polygon size
  109278. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109279. * * 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`
  109280. * * 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
  109281. * * 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)`)
  109282. * * 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
  109283. * * 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
  109284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109285. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109287. * @param name defines the name of the mesh
  109288. * @param options defines the options used to create the mesh
  109289. * @param scene defines the hosting scene
  109290. * @returns the polyhedron mesh
  109291. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  109292. */
  109293. static CreatePolyhedron(name: string, options: {
  109294. type?: number;
  109295. size?: number;
  109296. sizeX?: number;
  109297. sizeY?: number;
  109298. sizeZ?: number;
  109299. custom?: any;
  109300. faceUV?: Vector4[];
  109301. faceColors?: Color4[];
  109302. flat?: boolean;
  109303. updatable?: boolean;
  109304. sideOrientation?: number;
  109305. frontUVs?: Vector4;
  109306. backUVs?: Vector4;
  109307. }, scene: Scene): Mesh;
  109308. /**
  109309. * Creates a decal mesh.
  109310. * 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
  109311. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109312. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109313. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109314. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109315. * @param name defines the name of the mesh
  109316. * @param sourceMesh defines the mesh where the decal must be applied
  109317. * @param options defines the options used to create the mesh
  109318. * @param scene defines the hosting scene
  109319. * @returns the decal mesh
  109320. * @see https://doc.babylonjs.com/how_to/decals
  109321. */
  109322. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109323. position?: Vector3;
  109324. normal?: Vector3;
  109325. size?: Vector3;
  109326. angle?: number;
  109327. }): Mesh;
  109328. }
  109329. }
  109330. declare module BABYLON {
  109331. /**
  109332. * A simplifier interface for future simplification implementations
  109333. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109334. */
  109335. export interface ISimplifier {
  109336. /**
  109337. * Simplification of a given mesh according to the given settings.
  109338. * Since this requires computation, it is assumed that the function runs async.
  109339. * @param settings The settings of the simplification, including quality and distance
  109340. * @param successCallback A callback that will be called after the mesh was simplified.
  109341. * @param errorCallback in case of an error, this callback will be called. optional.
  109342. */
  109343. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  109344. }
  109345. /**
  109346. * Expected simplification settings.
  109347. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  109348. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109349. */
  109350. export interface ISimplificationSettings {
  109351. /**
  109352. * Gets or sets the expected quality
  109353. */
  109354. quality: number;
  109355. /**
  109356. * Gets or sets the distance when this optimized version should be used
  109357. */
  109358. distance: number;
  109359. /**
  109360. * Gets an already optimized mesh
  109361. */
  109362. optimizeMesh?: boolean;
  109363. }
  109364. /**
  109365. * Class used to specify simplification options
  109366. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109367. */
  109368. export class SimplificationSettings implements ISimplificationSettings {
  109369. /** expected quality */
  109370. quality: number;
  109371. /** distance when this optimized version should be used */
  109372. distance: number;
  109373. /** already optimized mesh */
  109374. optimizeMesh?: boolean | undefined;
  109375. /**
  109376. * Creates a SimplificationSettings
  109377. * @param quality expected quality
  109378. * @param distance distance when this optimized version should be used
  109379. * @param optimizeMesh already optimized mesh
  109380. */
  109381. constructor(
  109382. /** expected quality */
  109383. quality: number,
  109384. /** distance when this optimized version should be used */
  109385. distance: number,
  109386. /** already optimized mesh */
  109387. optimizeMesh?: boolean | undefined);
  109388. }
  109389. /**
  109390. * Interface used to define a simplification task
  109391. */
  109392. export interface ISimplificationTask {
  109393. /**
  109394. * Array of settings
  109395. */
  109396. settings: Array<ISimplificationSettings>;
  109397. /**
  109398. * Simplification type
  109399. */
  109400. simplificationType: SimplificationType;
  109401. /**
  109402. * Mesh to simplify
  109403. */
  109404. mesh: Mesh;
  109405. /**
  109406. * Callback called on success
  109407. */
  109408. successCallback?: () => void;
  109409. /**
  109410. * Defines if parallel processing can be used
  109411. */
  109412. parallelProcessing: boolean;
  109413. }
  109414. /**
  109415. * Queue used to order the simplification tasks
  109416. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109417. */
  109418. export class SimplificationQueue {
  109419. private _simplificationArray;
  109420. /**
  109421. * Gets a boolean indicating that the process is still running
  109422. */
  109423. running: boolean;
  109424. /**
  109425. * Creates a new queue
  109426. */
  109427. constructor();
  109428. /**
  109429. * Adds a new simplification task
  109430. * @param task defines a task to add
  109431. */
  109432. addTask(task: ISimplificationTask): void;
  109433. /**
  109434. * Execute next task
  109435. */
  109436. executeNext(): void;
  109437. /**
  109438. * Execute a simplification task
  109439. * @param task defines the task to run
  109440. */
  109441. runSimplification(task: ISimplificationTask): void;
  109442. private getSimplifier;
  109443. }
  109444. /**
  109445. * The implemented types of simplification
  109446. * At the moment only Quadratic Error Decimation is implemented
  109447. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109448. */
  109449. export enum SimplificationType {
  109450. /** Quadratic error decimation */
  109451. QUADRATIC = 0
  109452. }
  109453. }
  109454. declare module BABYLON {
  109455. interface Scene {
  109456. /** @hidden (Backing field) */
  109457. _simplificationQueue: SimplificationQueue;
  109458. /**
  109459. * Gets or sets the simplification queue attached to the scene
  109460. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109461. */
  109462. simplificationQueue: SimplificationQueue;
  109463. }
  109464. interface Mesh {
  109465. /**
  109466. * Simplify the mesh according to the given array of settings.
  109467. * Function will return immediately and will simplify async
  109468. * @param settings a collection of simplification settings
  109469. * @param parallelProcessing should all levels calculate parallel or one after the other
  109470. * @param simplificationType the type of simplification to run
  109471. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  109472. * @returns the current mesh
  109473. */
  109474. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  109475. }
  109476. /**
  109477. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  109478. * created in a scene
  109479. */
  109480. export class SimplicationQueueSceneComponent implements ISceneComponent {
  109481. /**
  109482. * The component name helpfull to identify the component in the list of scene components.
  109483. */
  109484. readonly name: string;
  109485. /**
  109486. * The scene the component belongs to.
  109487. */
  109488. scene: Scene;
  109489. /**
  109490. * Creates a new instance of the component for the given scene
  109491. * @param scene Defines the scene to register the component in
  109492. */
  109493. constructor(scene: Scene);
  109494. /**
  109495. * Registers the component in a given scene
  109496. */
  109497. register(): void;
  109498. /**
  109499. * Rebuilds the elements related to this component in case of
  109500. * context lost for instance.
  109501. */
  109502. rebuild(): void;
  109503. /**
  109504. * Disposes the component and the associated ressources
  109505. */
  109506. dispose(): void;
  109507. private _beforeCameraUpdate;
  109508. }
  109509. }
  109510. declare module BABYLON {
  109511. /**
  109512. * Class used to enable access to IndexedDB
  109513. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  109514. */
  109515. export class Database implements IOfflineProvider {
  109516. private _callbackManifestChecked;
  109517. private _currentSceneUrl;
  109518. private _db;
  109519. private _enableSceneOffline;
  109520. private _enableTexturesOffline;
  109521. private _manifestVersionFound;
  109522. private _mustUpdateRessources;
  109523. private _hasReachedQuota;
  109524. private _isSupported;
  109525. private _idbFactory;
  109526. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  109527. private static IsUASupportingBlobStorage;
  109528. /**
  109529. * Gets a boolean indicating if Database storate is enabled (off by default)
  109530. */
  109531. static IDBStorageEnabled: boolean;
  109532. /**
  109533. * Gets a boolean indicating if scene must be saved in the database
  109534. */
  109535. readonly enableSceneOffline: boolean;
  109536. /**
  109537. * Gets a boolean indicating if textures must be saved in the database
  109538. */
  109539. readonly enableTexturesOffline: boolean;
  109540. /**
  109541. * Creates a new Database
  109542. * @param urlToScene defines the url to load the scene
  109543. * @param callbackManifestChecked defines the callback to use when manifest is checked
  109544. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  109545. */
  109546. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  109547. private static _ParseURL;
  109548. private static _ReturnFullUrlLocation;
  109549. private _checkManifestFile;
  109550. /**
  109551. * Open the database and make it available
  109552. * @param successCallback defines the callback to call on success
  109553. * @param errorCallback defines the callback to call on error
  109554. */
  109555. open(successCallback: () => void, errorCallback: () => void): void;
  109556. /**
  109557. * Loads an image from the database
  109558. * @param url defines the url to load from
  109559. * @param image defines the target DOM image
  109560. */
  109561. loadImage(url: string, image: HTMLImageElement): void;
  109562. private _loadImageFromDBAsync;
  109563. private _saveImageIntoDBAsync;
  109564. private _checkVersionFromDB;
  109565. private _loadVersionFromDBAsync;
  109566. private _saveVersionIntoDBAsync;
  109567. /**
  109568. * Loads a file from database
  109569. * @param url defines the URL to load from
  109570. * @param sceneLoaded defines a callback to call on success
  109571. * @param progressCallBack defines a callback to call when progress changed
  109572. * @param errorCallback defines a callback to call on error
  109573. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  109574. */
  109575. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  109576. private _loadFileAsync;
  109577. private _saveFileAsync;
  109578. /**
  109579. * Validates if xhr data is correct
  109580. * @param xhr defines the request to validate
  109581. * @param dataType defines the expected data type
  109582. * @returns true if data is correct
  109583. */
  109584. private static _ValidateXHRData;
  109585. }
  109586. }
  109587. declare module BABYLON {
  109588. /** @hidden */
  109589. export var gpuUpdateParticlesPixelShader: {
  109590. name: string;
  109591. shader: string;
  109592. };
  109593. }
  109594. declare module BABYLON {
  109595. /** @hidden */
  109596. export var gpuUpdateParticlesVertexShader: {
  109597. name: string;
  109598. shader: string;
  109599. };
  109600. }
  109601. declare module BABYLON {
  109602. /** @hidden */
  109603. export var clipPlaneFragmentDeclaration2: {
  109604. name: string;
  109605. shader: string;
  109606. };
  109607. }
  109608. declare module BABYLON {
  109609. /** @hidden */
  109610. export var gpuRenderParticlesPixelShader: {
  109611. name: string;
  109612. shader: string;
  109613. };
  109614. }
  109615. declare module BABYLON {
  109616. /** @hidden */
  109617. export var clipPlaneVertexDeclaration2: {
  109618. name: string;
  109619. shader: string;
  109620. };
  109621. }
  109622. declare module BABYLON {
  109623. /** @hidden */
  109624. export var gpuRenderParticlesVertexShader: {
  109625. name: string;
  109626. shader: string;
  109627. };
  109628. }
  109629. declare module BABYLON {
  109630. /**
  109631. * This represents a GPU particle system in Babylon
  109632. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  109633. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  109634. */
  109635. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  109636. /**
  109637. * The layer mask we are rendering the particles through.
  109638. */
  109639. layerMask: number;
  109640. private _capacity;
  109641. private _activeCount;
  109642. private _currentActiveCount;
  109643. private _accumulatedCount;
  109644. private _renderEffect;
  109645. private _updateEffect;
  109646. private _buffer0;
  109647. private _buffer1;
  109648. private _spriteBuffer;
  109649. private _updateVAO;
  109650. private _renderVAO;
  109651. private _targetIndex;
  109652. private _sourceBuffer;
  109653. private _targetBuffer;
  109654. private _engine;
  109655. private _currentRenderId;
  109656. private _started;
  109657. private _stopped;
  109658. private _timeDelta;
  109659. private _randomTexture;
  109660. private _randomTexture2;
  109661. private _attributesStrideSize;
  109662. private _updateEffectOptions;
  109663. private _randomTextureSize;
  109664. private _actualFrame;
  109665. private readonly _rawTextureWidth;
  109666. /**
  109667. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  109668. */
  109669. static readonly IsSupported: boolean;
  109670. /**
  109671. * An event triggered when the system is disposed.
  109672. */
  109673. onDisposeObservable: Observable<GPUParticleSystem>;
  109674. /**
  109675. * Gets the maximum number of particles active at the same time.
  109676. * @returns The max number of active particles.
  109677. */
  109678. getCapacity(): number;
  109679. /**
  109680. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  109681. * to override the particles.
  109682. */
  109683. forceDepthWrite: boolean;
  109684. /**
  109685. * Gets or set the number of active particles
  109686. */
  109687. activeParticleCount: number;
  109688. private _preWarmDone;
  109689. /**
  109690. * Is this system ready to be used/rendered
  109691. * @return true if the system is ready
  109692. */
  109693. isReady(): boolean;
  109694. /**
  109695. * Gets if the system has been started. (Note: this will still be true after stop is called)
  109696. * @returns True if it has been started, otherwise false.
  109697. */
  109698. isStarted(): boolean;
  109699. /**
  109700. * Starts the particle system and begins to emit
  109701. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  109702. */
  109703. start(delay?: number): void;
  109704. /**
  109705. * Stops the particle system.
  109706. */
  109707. stop(): void;
  109708. /**
  109709. * Remove all active particles
  109710. */
  109711. reset(): void;
  109712. /**
  109713. * Returns the string "GPUParticleSystem"
  109714. * @returns a string containing the class name
  109715. */
  109716. getClassName(): string;
  109717. private _colorGradientsTexture;
  109718. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  109719. /**
  109720. * Adds a new color gradient
  109721. * @param gradient defines the gradient to use (between 0 and 1)
  109722. * @param color1 defines the color to affect to the specified gradient
  109723. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  109724. * @returns the current particle system
  109725. */
  109726. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  109727. /**
  109728. * Remove a specific color gradient
  109729. * @param gradient defines the gradient to remove
  109730. * @returns the current particle system
  109731. */
  109732. removeColorGradient(gradient: number): GPUParticleSystem;
  109733. private _angularSpeedGradientsTexture;
  109734. private _sizeGradientsTexture;
  109735. private _velocityGradientsTexture;
  109736. private _limitVelocityGradientsTexture;
  109737. private _dragGradientsTexture;
  109738. private _addFactorGradient;
  109739. /**
  109740. * Adds a new size gradient
  109741. * @param gradient defines the gradient to use (between 0 and 1)
  109742. * @param factor defines the size factor to affect to the specified gradient
  109743. * @returns the current particle system
  109744. */
  109745. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  109746. /**
  109747. * Remove a specific size gradient
  109748. * @param gradient defines the gradient to remove
  109749. * @returns the current particle system
  109750. */
  109751. removeSizeGradient(gradient: number): GPUParticleSystem;
  109752. /**
  109753. * Adds a new angular speed gradient
  109754. * @param gradient defines the gradient to use (between 0 and 1)
  109755. * @param factor defines the angular speed to affect to the specified gradient
  109756. * @returns the current particle system
  109757. */
  109758. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  109759. /**
  109760. * Remove a specific angular speed gradient
  109761. * @param gradient defines the gradient to remove
  109762. * @returns the current particle system
  109763. */
  109764. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  109765. /**
  109766. * Adds a new velocity gradient
  109767. * @param gradient defines the gradient to use (between 0 and 1)
  109768. * @param factor defines the velocity to affect to the specified gradient
  109769. * @returns the current particle system
  109770. */
  109771. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  109772. /**
  109773. * Remove a specific velocity gradient
  109774. * @param gradient defines the gradient to remove
  109775. * @returns the current particle system
  109776. */
  109777. removeVelocityGradient(gradient: number): GPUParticleSystem;
  109778. /**
  109779. * Adds a new limit velocity gradient
  109780. * @param gradient defines the gradient to use (between 0 and 1)
  109781. * @param factor defines the limit velocity value to affect to the specified gradient
  109782. * @returns the current particle system
  109783. */
  109784. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  109785. /**
  109786. * Remove a specific limit velocity gradient
  109787. * @param gradient defines the gradient to remove
  109788. * @returns the current particle system
  109789. */
  109790. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  109791. /**
  109792. * Adds a new drag gradient
  109793. * @param gradient defines the gradient to use (between 0 and 1)
  109794. * @param factor defines the drag value to affect to the specified gradient
  109795. * @returns the current particle system
  109796. */
  109797. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  109798. /**
  109799. * Remove a specific drag gradient
  109800. * @param gradient defines the gradient to remove
  109801. * @returns the current particle system
  109802. */
  109803. removeDragGradient(gradient: number): GPUParticleSystem;
  109804. /**
  109805. * Not supported by GPUParticleSystem
  109806. * @param gradient defines the gradient to use (between 0 and 1)
  109807. * @param factor defines the emit rate value to affect to the specified gradient
  109808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109809. * @returns the current particle system
  109810. */
  109811. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  109812. /**
  109813. * Not supported by GPUParticleSystem
  109814. * @param gradient defines the gradient to remove
  109815. * @returns the current particle system
  109816. */
  109817. removeEmitRateGradient(gradient: number): IParticleSystem;
  109818. /**
  109819. * Not supported by GPUParticleSystem
  109820. * @param gradient defines the gradient to use (between 0 and 1)
  109821. * @param factor defines the start size value to affect to the specified gradient
  109822. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109823. * @returns the current particle system
  109824. */
  109825. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  109826. /**
  109827. * Not supported by GPUParticleSystem
  109828. * @param gradient defines the gradient to remove
  109829. * @returns the current particle system
  109830. */
  109831. removeStartSizeGradient(gradient: number): IParticleSystem;
  109832. /**
  109833. * Not supported by GPUParticleSystem
  109834. * @param gradient defines the gradient to use (between 0 and 1)
  109835. * @param min defines the color remap minimal range
  109836. * @param max defines the color remap maximal range
  109837. * @returns the current particle system
  109838. */
  109839. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  109840. /**
  109841. * Not supported by GPUParticleSystem
  109842. * @param gradient defines the gradient to remove
  109843. * @returns the current particle system
  109844. */
  109845. removeColorRemapGradient(): IParticleSystem;
  109846. /**
  109847. * Not supported by GPUParticleSystem
  109848. * @param gradient defines the gradient to use (between 0 and 1)
  109849. * @param min defines the alpha remap minimal range
  109850. * @param max defines the alpha remap maximal range
  109851. * @returns the current particle system
  109852. */
  109853. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  109854. /**
  109855. * Not supported by GPUParticleSystem
  109856. * @param gradient defines the gradient to remove
  109857. * @returns the current particle system
  109858. */
  109859. removeAlphaRemapGradient(): IParticleSystem;
  109860. /**
  109861. * Not supported by GPUParticleSystem
  109862. * @param gradient defines the gradient to use (between 0 and 1)
  109863. * @param color defines the color to affect to the specified gradient
  109864. * @returns the current particle system
  109865. */
  109866. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  109867. /**
  109868. * Not supported by GPUParticleSystem
  109869. * @param gradient defines the gradient to remove
  109870. * @returns the current particle system
  109871. */
  109872. removeRampGradient(): IParticleSystem;
  109873. /**
  109874. * Not supported by GPUParticleSystem
  109875. * @returns the list of ramp gradients
  109876. */
  109877. getRampGradients(): Nullable<Array<Color3Gradient>>;
  109878. /**
  109879. * Not supported by GPUParticleSystem
  109880. * Gets or sets a boolean indicating that ramp gradients must be used
  109881. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  109882. */
  109883. useRampGradients: boolean;
  109884. /**
  109885. * Not supported by GPUParticleSystem
  109886. * @param gradient defines the gradient to use (between 0 and 1)
  109887. * @param factor defines the life time factor to affect to the specified gradient
  109888. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109889. * @returns the current particle system
  109890. */
  109891. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  109892. /**
  109893. * Not supported by GPUParticleSystem
  109894. * @param gradient defines the gradient to remove
  109895. * @returns the current particle system
  109896. */
  109897. removeLifeTimeGradient(gradient: number): IParticleSystem;
  109898. /**
  109899. * Instantiates a GPU particle system.
  109900. * 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.
  109901. * @param name The name of the particle system
  109902. * @param options The options used to create the system
  109903. * @param scene The scene the particle system belongs to
  109904. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  109905. */
  109906. constructor(name: string, options: Partial<{
  109907. capacity: number;
  109908. randomTextureSize: number;
  109909. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  109910. protected _reset(): void;
  109911. private _createUpdateVAO;
  109912. private _createRenderVAO;
  109913. private _initialize;
  109914. /** @hidden */
  109915. _recreateUpdateEffect(): void;
  109916. /** @hidden */
  109917. _recreateRenderEffect(): void;
  109918. /**
  109919. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  109920. * @param preWarm defines if we are in the pre-warmimg phase
  109921. */
  109922. animate(preWarm?: boolean): void;
  109923. private _createFactorGradientTexture;
  109924. private _createSizeGradientTexture;
  109925. private _createAngularSpeedGradientTexture;
  109926. private _createVelocityGradientTexture;
  109927. private _createLimitVelocityGradientTexture;
  109928. private _createDragGradientTexture;
  109929. private _createColorGradientTexture;
  109930. /**
  109931. * Renders the particle system in its current state
  109932. * @param preWarm defines if the system should only update the particles but not render them
  109933. * @returns the current number of particles
  109934. */
  109935. render(preWarm?: boolean): number;
  109936. /**
  109937. * Rebuilds the particle system
  109938. */
  109939. rebuild(): void;
  109940. private _releaseBuffers;
  109941. private _releaseVAOs;
  109942. /**
  109943. * Disposes the particle system and free the associated resources
  109944. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  109945. */
  109946. dispose(disposeTexture?: boolean): void;
  109947. /**
  109948. * Clones the particle system.
  109949. * @param name The name of the cloned object
  109950. * @param newEmitter The new emitter to use
  109951. * @returns the cloned particle system
  109952. */
  109953. clone(name: string, newEmitter: any): GPUParticleSystem;
  109954. /**
  109955. * Serializes the particle system to a JSON object.
  109956. * @returns the JSON object
  109957. */
  109958. serialize(): any;
  109959. /**
  109960. * Parses a JSON object to create a GPU particle system.
  109961. * @param parsedParticleSystem The JSON object to parse
  109962. * @param scene The scene to create the particle system in
  109963. * @param rootUrl The root url to use to load external dependencies like texture
  109964. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  109965. * @returns the parsed GPU particle system
  109966. */
  109967. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  109968. }
  109969. }
  109970. declare module BABYLON {
  109971. /**
  109972. * Represents a set of particle systems working together to create a specific effect
  109973. */
  109974. export class ParticleSystemSet implements IDisposable {
  109975. private _emitterCreationOptions;
  109976. private _emitterNode;
  109977. /**
  109978. * Gets the particle system list
  109979. */
  109980. systems: IParticleSystem[];
  109981. /**
  109982. * Gets the emitter node used with this set
  109983. */
  109984. readonly emitterNode: Nullable<TransformNode>;
  109985. /**
  109986. * Creates a new emitter mesh as a sphere
  109987. * @param options defines the options used to create the sphere
  109988. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  109989. * @param scene defines the hosting scene
  109990. */
  109991. setEmitterAsSphere(options: {
  109992. diameter: number;
  109993. segments: number;
  109994. color: Color3;
  109995. }, renderingGroupId: number, scene: Scene): void;
  109996. /**
  109997. * Starts all particle systems of the set
  109998. * @param emitter defines an optional mesh to use as emitter for the particle systems
  109999. */
  110000. start(emitter?: AbstractMesh): void;
  110001. /**
  110002. * Release all associated resources
  110003. */
  110004. dispose(): void;
  110005. /**
  110006. * Serialize the set into a JSON compatible object
  110007. * @returns a JSON compatible representation of the set
  110008. */
  110009. serialize(): any;
  110010. /**
  110011. * Parse a new ParticleSystemSet from a serialized source
  110012. * @param data defines a JSON compatible representation of the set
  110013. * @param scene defines the hosting scene
  110014. * @param gpu defines if we want GPU particles or CPU particles
  110015. * @returns a new ParticleSystemSet
  110016. */
  110017. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  110018. }
  110019. }
  110020. declare module BABYLON {
  110021. /**
  110022. * This class is made for on one-liner static method to help creating particle system set.
  110023. */
  110024. export class ParticleHelper {
  110025. /**
  110026. * Gets or sets base Assets URL
  110027. */
  110028. static BaseAssetsUrl: string;
  110029. /**
  110030. * Create a default particle system that you can tweak
  110031. * @param emitter defines the emitter to use
  110032. * @param capacity defines the system capacity (default is 500 particles)
  110033. * @param scene defines the hosting scene
  110034. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  110035. * @returns the new Particle system
  110036. */
  110037. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  110038. /**
  110039. * This is the main static method (one-liner) of this helper to create different particle systems
  110040. * @param type This string represents the type to the particle system to create
  110041. * @param scene The scene where the particle system should live
  110042. * @param gpu If the system will use gpu
  110043. * @returns the ParticleSystemSet created
  110044. */
  110045. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  110046. /**
  110047. * Static function used to export a particle system to a ParticleSystemSet variable.
  110048. * Please note that the emitter shape is not exported
  110049. * @param systems defines the particle systems to export
  110050. * @returns the created particle system set
  110051. */
  110052. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  110053. }
  110054. }
  110055. declare module BABYLON {
  110056. interface Engine {
  110057. /**
  110058. * Create an effect to use with particle systems.
  110059. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  110060. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  110061. * @param uniformsNames defines a list of attribute names
  110062. * @param samplers defines an array of string used to represent textures
  110063. * @param defines defines the string containing the defines to use to compile the shaders
  110064. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  110065. * @param onCompiled defines a function to call when the effect creation is successful
  110066. * @param onError defines a function to call when the effect creation has failed
  110067. * @returns the new Effect
  110068. */
  110069. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  110070. }
  110071. interface Mesh {
  110072. /**
  110073. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  110074. * @returns an array of IParticleSystem
  110075. */
  110076. getEmittedParticleSystems(): IParticleSystem[];
  110077. /**
  110078. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  110079. * @returns an array of IParticleSystem
  110080. */
  110081. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  110082. }
  110083. /**
  110084. * @hidden
  110085. */
  110086. export var _IDoNeedToBeInTheBuild: number;
  110087. }
  110088. declare module BABYLON {
  110089. interface Scene {
  110090. /** @hidden (Backing field) */
  110091. _physicsEngine: Nullable<IPhysicsEngine>;
  110092. /**
  110093. * Gets the current physics engine
  110094. * @returns a IPhysicsEngine or null if none attached
  110095. */
  110096. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  110097. /**
  110098. * Enables physics to the current scene
  110099. * @param gravity defines the scene's gravity for the physics engine
  110100. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  110101. * @return a boolean indicating if the physics engine was initialized
  110102. */
  110103. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  110104. /**
  110105. * Disables and disposes the physics engine associated with the scene
  110106. */
  110107. disablePhysicsEngine(): void;
  110108. /**
  110109. * Gets a boolean indicating if there is an active physics engine
  110110. * @returns a boolean indicating if there is an active physics engine
  110111. */
  110112. isPhysicsEnabled(): boolean;
  110113. /**
  110114. * Deletes a physics compound impostor
  110115. * @param compound defines the compound to delete
  110116. */
  110117. deleteCompoundImpostor(compound: any): void;
  110118. /**
  110119. * An event triggered when physic simulation is about to be run
  110120. */
  110121. onBeforePhysicsObservable: Observable<Scene>;
  110122. /**
  110123. * An event triggered when physic simulation has been done
  110124. */
  110125. onAfterPhysicsObservable: Observable<Scene>;
  110126. }
  110127. interface AbstractMesh {
  110128. /** @hidden */
  110129. _physicsImpostor: Nullable<PhysicsImpostor>;
  110130. /**
  110131. * Gets or sets impostor used for physic simulation
  110132. * @see http://doc.babylonjs.com/features/physics_engine
  110133. */
  110134. physicsImpostor: Nullable<PhysicsImpostor>;
  110135. /**
  110136. * Gets the current physics impostor
  110137. * @see http://doc.babylonjs.com/features/physics_engine
  110138. * @returns a physics impostor or null
  110139. */
  110140. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  110141. /** Apply a physic impulse to the mesh
  110142. * @param force defines the force to apply
  110143. * @param contactPoint defines where to apply the force
  110144. * @returns the current mesh
  110145. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110146. */
  110147. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  110148. /**
  110149. * Creates a physic joint between two meshes
  110150. * @param otherMesh defines the other mesh to use
  110151. * @param pivot1 defines the pivot to use on this mesh
  110152. * @param pivot2 defines the pivot to use on the other mesh
  110153. * @param options defines additional options (can be plugin dependent)
  110154. * @returns the current mesh
  110155. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  110156. */
  110157. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  110158. /** @hidden */
  110159. _disposePhysicsObserver: Nullable<Observer<Node>>;
  110160. }
  110161. /**
  110162. * Defines the physics engine scene component responsible to manage a physics engine
  110163. */
  110164. export class PhysicsEngineSceneComponent implements ISceneComponent {
  110165. /**
  110166. * The component name helpful to identify the component in the list of scene components.
  110167. */
  110168. readonly name: string;
  110169. /**
  110170. * The scene the component belongs to.
  110171. */
  110172. scene: Scene;
  110173. /**
  110174. * Creates a new instance of the component for the given scene
  110175. * @param scene Defines the scene to register the component in
  110176. */
  110177. constructor(scene: Scene);
  110178. /**
  110179. * Registers the component in a given scene
  110180. */
  110181. register(): void;
  110182. /**
  110183. * Rebuilds the elements related to this component in case of
  110184. * context lost for instance.
  110185. */
  110186. rebuild(): void;
  110187. /**
  110188. * Disposes the component and the associated ressources
  110189. */
  110190. dispose(): void;
  110191. }
  110192. }
  110193. declare module BABYLON {
  110194. /**
  110195. * A helper for physics simulations
  110196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110197. */
  110198. export class PhysicsHelper {
  110199. private _scene;
  110200. private _physicsEngine;
  110201. /**
  110202. * Initializes the Physics helper
  110203. * @param scene Babylon.js scene
  110204. */
  110205. constructor(scene: Scene);
  110206. /**
  110207. * Applies a radial explosion impulse
  110208. * @param origin the origin of the explosion
  110209. * @param radiusOrEventOptions the radius or the options of radial explosion
  110210. * @param strength the explosion strength
  110211. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110212. * @returns A physics radial explosion event, or null
  110213. */
  110214. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110215. /**
  110216. * Applies a radial explosion force
  110217. * @param origin the origin of the explosion
  110218. * @param radiusOrEventOptions the radius or the options of radial explosion
  110219. * @param strength the explosion strength
  110220. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110221. * @returns A physics radial explosion event, or null
  110222. */
  110223. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110224. /**
  110225. * Creates a gravitational field
  110226. * @param origin the origin of the explosion
  110227. * @param radiusOrEventOptions the radius or the options of radial explosion
  110228. * @param strength the explosion strength
  110229. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110230. * @returns A physics gravitational field event, or null
  110231. */
  110232. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  110233. /**
  110234. * Creates a physics updraft event
  110235. * @param origin the origin of the updraft
  110236. * @param radiusOrEventOptions the radius or the options of the updraft
  110237. * @param strength the strength of the updraft
  110238. * @param height the height of the updraft
  110239. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  110240. * @returns A physics updraft event, or null
  110241. */
  110242. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  110243. /**
  110244. * Creates a physics vortex event
  110245. * @param origin the of the vortex
  110246. * @param radiusOrEventOptions the radius or the options of the vortex
  110247. * @param strength the strength of the vortex
  110248. * @param height the height of the vortex
  110249. * @returns a Physics vortex event, or null
  110250. * A physics vortex event or null
  110251. */
  110252. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  110253. }
  110254. /**
  110255. * Represents a physics radial explosion event
  110256. */
  110257. class PhysicsRadialExplosionEvent {
  110258. private _scene;
  110259. private _options;
  110260. private _sphere;
  110261. private _dataFetched;
  110262. /**
  110263. * Initializes a radial explosioin event
  110264. * @param _scene BabylonJS scene
  110265. * @param _options The options for the vortex event
  110266. */
  110267. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  110268. /**
  110269. * Returns the data related to the radial explosion event (sphere).
  110270. * @returns The radial explosion event data
  110271. */
  110272. getData(): PhysicsRadialExplosionEventData;
  110273. /**
  110274. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  110275. * @param impostor A physics imposter
  110276. * @param origin the origin of the explosion
  110277. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  110278. */
  110279. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  110280. /**
  110281. * Triggers affecterd impostors callbacks
  110282. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  110283. */
  110284. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  110285. /**
  110286. * Disposes the sphere.
  110287. * @param force Specifies if the sphere should be disposed by force
  110288. */
  110289. dispose(force?: boolean): void;
  110290. /*** Helpers ***/
  110291. private _prepareSphere;
  110292. private _intersectsWithSphere;
  110293. }
  110294. /**
  110295. * Represents a gravitational field event
  110296. */
  110297. class PhysicsGravitationalFieldEvent {
  110298. private _physicsHelper;
  110299. private _scene;
  110300. private _origin;
  110301. private _options;
  110302. private _tickCallback;
  110303. private _sphere;
  110304. private _dataFetched;
  110305. /**
  110306. * Initializes the physics gravitational field event
  110307. * @param _physicsHelper A physics helper
  110308. * @param _scene BabylonJS scene
  110309. * @param _origin The origin position of the gravitational field event
  110310. * @param _options The options for the vortex event
  110311. */
  110312. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  110313. /**
  110314. * Returns the data related to the gravitational field event (sphere).
  110315. * @returns A gravitational field event
  110316. */
  110317. getData(): PhysicsGravitationalFieldEventData;
  110318. /**
  110319. * Enables the gravitational field.
  110320. */
  110321. enable(): void;
  110322. /**
  110323. * Disables the gravitational field.
  110324. */
  110325. disable(): void;
  110326. /**
  110327. * Disposes the sphere.
  110328. * @param force The force to dispose from the gravitational field event
  110329. */
  110330. dispose(force?: boolean): void;
  110331. private _tick;
  110332. }
  110333. /**
  110334. * Represents a physics updraft event
  110335. */
  110336. class PhysicsUpdraftEvent {
  110337. private _scene;
  110338. private _origin;
  110339. private _options;
  110340. private _physicsEngine;
  110341. private _originTop;
  110342. private _originDirection;
  110343. private _tickCallback;
  110344. private _cylinder;
  110345. private _cylinderPosition;
  110346. private _dataFetched;
  110347. /**
  110348. * Initializes the physics updraft event
  110349. * @param _scene BabylonJS scene
  110350. * @param _origin The origin position of the updraft
  110351. * @param _options The options for the updraft event
  110352. */
  110353. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  110354. /**
  110355. * Returns the data related to the updraft event (cylinder).
  110356. * @returns A physics updraft event
  110357. */
  110358. getData(): PhysicsUpdraftEventData;
  110359. /**
  110360. * Enables the updraft.
  110361. */
  110362. enable(): void;
  110363. /**
  110364. * Disables the updraft.
  110365. */
  110366. disable(): void;
  110367. /**
  110368. * Disposes the cylinder.
  110369. * @param force Specifies if the updraft should be disposed by force
  110370. */
  110371. dispose(force?: boolean): void;
  110372. private getImpostorHitData;
  110373. private _tick;
  110374. /*** Helpers ***/
  110375. private _prepareCylinder;
  110376. private _intersectsWithCylinder;
  110377. }
  110378. /**
  110379. * Represents a physics vortex event
  110380. */
  110381. class PhysicsVortexEvent {
  110382. private _scene;
  110383. private _origin;
  110384. private _options;
  110385. private _physicsEngine;
  110386. private _originTop;
  110387. private _tickCallback;
  110388. private _cylinder;
  110389. private _cylinderPosition;
  110390. private _dataFetched;
  110391. /**
  110392. * Initializes the physics vortex event
  110393. * @param _scene The BabylonJS scene
  110394. * @param _origin The origin position of the vortex
  110395. * @param _options The options for the vortex event
  110396. */
  110397. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  110398. /**
  110399. * Returns the data related to the vortex event (cylinder).
  110400. * @returns The physics vortex event data
  110401. */
  110402. getData(): PhysicsVortexEventData;
  110403. /**
  110404. * Enables the vortex.
  110405. */
  110406. enable(): void;
  110407. /**
  110408. * Disables the cortex.
  110409. */
  110410. disable(): void;
  110411. /**
  110412. * Disposes the sphere.
  110413. * @param force
  110414. */
  110415. dispose(force?: boolean): void;
  110416. private getImpostorHitData;
  110417. private _tick;
  110418. /*** Helpers ***/
  110419. private _prepareCylinder;
  110420. private _intersectsWithCylinder;
  110421. }
  110422. /**
  110423. * Options fot the radial explosion event
  110424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110425. */
  110426. export class PhysicsRadialExplosionEventOptions {
  110427. /**
  110428. * The radius of the sphere for the radial explosion.
  110429. */
  110430. radius: number;
  110431. /**
  110432. * The strenth of the explosion.
  110433. */
  110434. strength: number;
  110435. /**
  110436. * The strenght of the force in correspondence to the distance of the affected object
  110437. */
  110438. falloff: PhysicsRadialImpulseFalloff;
  110439. /**
  110440. * Sphere options for the radial explosion.
  110441. */
  110442. sphere: {
  110443. segments: number;
  110444. diameter: number;
  110445. };
  110446. /**
  110447. * Sphere options for the radial explosion.
  110448. */
  110449. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  110450. }
  110451. /**
  110452. * Options fot the updraft event
  110453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110454. */
  110455. export class PhysicsUpdraftEventOptions {
  110456. /**
  110457. * The radius of the cylinder for the vortex
  110458. */
  110459. radius: number;
  110460. /**
  110461. * The strenth of the updraft.
  110462. */
  110463. strength: number;
  110464. /**
  110465. * The height of the cylinder for the updraft.
  110466. */
  110467. height: number;
  110468. /**
  110469. * The mode for the the updraft.
  110470. */
  110471. updraftMode: PhysicsUpdraftMode;
  110472. }
  110473. /**
  110474. * Options fot the vortex event
  110475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110476. */
  110477. export class PhysicsVortexEventOptions {
  110478. /**
  110479. * The radius of the cylinder for the vortex
  110480. */
  110481. radius: number;
  110482. /**
  110483. * The strenth of the vortex.
  110484. */
  110485. strength: number;
  110486. /**
  110487. * The height of the cylinder for the vortex.
  110488. */
  110489. height: number;
  110490. /**
  110491. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  110492. */
  110493. centripetalForceThreshold: number;
  110494. /**
  110495. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  110496. */
  110497. centripetalForceMultiplier: number;
  110498. /**
  110499. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  110500. */
  110501. centrifugalForceMultiplier: number;
  110502. /**
  110503. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  110504. */
  110505. updraftForceMultiplier: number;
  110506. }
  110507. /**
  110508. * The strenght of the force in correspondence to the distance of the affected object
  110509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110510. */
  110511. export enum PhysicsRadialImpulseFalloff {
  110512. /** Defines that impulse is constant in strength across it's whole radius */
  110513. Constant = 0,
  110514. /** Defines that impulse gets weaker if it's further from the origin */
  110515. Linear = 1
  110516. }
  110517. /**
  110518. * The strength of the force in correspondence to the distance of the affected object
  110519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110520. */
  110521. export enum PhysicsUpdraftMode {
  110522. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  110523. Center = 0,
  110524. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  110525. Perpendicular = 1
  110526. }
  110527. /**
  110528. * Interface for a physics hit data
  110529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110530. */
  110531. export interface PhysicsHitData {
  110532. /**
  110533. * The force applied at the contact point
  110534. */
  110535. force: Vector3;
  110536. /**
  110537. * The contact point
  110538. */
  110539. contactPoint: Vector3;
  110540. /**
  110541. * The distance from the origin to the contact point
  110542. */
  110543. distanceFromOrigin: number;
  110544. }
  110545. /**
  110546. * Interface for radial explosion event data
  110547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110548. */
  110549. export interface PhysicsRadialExplosionEventData {
  110550. /**
  110551. * A sphere used for the radial explosion event
  110552. */
  110553. sphere: Mesh;
  110554. }
  110555. /**
  110556. * Interface for gravitational field event data
  110557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110558. */
  110559. export interface PhysicsGravitationalFieldEventData {
  110560. /**
  110561. * A sphere mesh used for the gravitational field event
  110562. */
  110563. sphere: Mesh;
  110564. }
  110565. /**
  110566. * Interface for updraft event data
  110567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110568. */
  110569. export interface PhysicsUpdraftEventData {
  110570. /**
  110571. * A cylinder used for the updraft event
  110572. */
  110573. cylinder: Mesh;
  110574. }
  110575. /**
  110576. * Interface for vortex event data
  110577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110578. */
  110579. export interface PhysicsVortexEventData {
  110580. /**
  110581. * A cylinder used for the vortex event
  110582. */
  110583. cylinder: Mesh;
  110584. }
  110585. /**
  110586. * Interface for an affected physics impostor
  110587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110588. */
  110589. export interface PhysicsAffectedImpostorWithData {
  110590. /**
  110591. * The impostor affected by the effect
  110592. */
  110593. impostor: PhysicsImpostor;
  110594. /**
  110595. * The data about the hit/horce from the explosion
  110596. */
  110597. hitData: PhysicsHitData;
  110598. }
  110599. }
  110600. declare module BABYLON {
  110601. /** @hidden */
  110602. export var blackAndWhitePixelShader: {
  110603. name: string;
  110604. shader: string;
  110605. };
  110606. }
  110607. declare module BABYLON {
  110608. /**
  110609. * Post process used to render in black and white
  110610. */
  110611. export class BlackAndWhitePostProcess extends PostProcess {
  110612. /**
  110613. * Linear about to convert he result to black and white (default: 1)
  110614. */
  110615. degree: number;
  110616. /**
  110617. * Creates a black and white post process
  110618. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  110619. * @param name The name of the effect.
  110620. * @param options The required width/height ratio to downsize to before computing the render pass.
  110621. * @param camera The camera to apply the render pass to.
  110622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110623. * @param engine The engine which the post process will be applied. (default: current engine)
  110624. * @param reusable If the post process can be reused on the same frame. (default: false)
  110625. */
  110626. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110627. }
  110628. }
  110629. declare module BABYLON {
  110630. /**
  110631. * This represents a set of one or more post processes in Babylon.
  110632. * A post process can be used to apply a shader to a texture after it is rendered.
  110633. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110634. */
  110635. export class PostProcessRenderEffect {
  110636. private _postProcesses;
  110637. private _getPostProcesses;
  110638. private _singleInstance;
  110639. private _cameras;
  110640. private _indicesForCamera;
  110641. /**
  110642. * Name of the effect
  110643. * @hidden
  110644. */
  110645. _name: string;
  110646. /**
  110647. * Instantiates a post process render effect.
  110648. * A post process can be used to apply a shader to a texture after it is rendered.
  110649. * @param engine The engine the effect is tied to
  110650. * @param name The name of the effect
  110651. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  110652. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  110653. */
  110654. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  110655. /**
  110656. * Checks if all the post processes in the effect are supported.
  110657. */
  110658. readonly isSupported: boolean;
  110659. /**
  110660. * Updates the current state of the effect
  110661. * @hidden
  110662. */
  110663. _update(): void;
  110664. /**
  110665. * Attaches the effect on cameras
  110666. * @param cameras The camera to attach to.
  110667. * @hidden
  110668. */
  110669. _attachCameras(cameras: Camera): void;
  110670. /**
  110671. * Attaches the effect on cameras
  110672. * @param cameras The camera to attach to.
  110673. * @hidden
  110674. */
  110675. _attachCameras(cameras: Camera[]): void;
  110676. /**
  110677. * Detatches the effect on cameras
  110678. * @param cameras The camera to detatch from.
  110679. * @hidden
  110680. */
  110681. _detachCameras(cameras: Camera): void;
  110682. /**
  110683. * Detatches the effect on cameras
  110684. * @param cameras The camera to detatch from.
  110685. * @hidden
  110686. */
  110687. _detachCameras(cameras: Camera[]): void;
  110688. /**
  110689. * Enables the effect on given cameras
  110690. * @param cameras The camera to enable.
  110691. * @hidden
  110692. */
  110693. _enable(cameras: Camera): void;
  110694. /**
  110695. * Enables the effect on given cameras
  110696. * @param cameras The camera to enable.
  110697. * @hidden
  110698. */
  110699. _enable(cameras: Nullable<Camera[]>): void;
  110700. /**
  110701. * Disables the effect on the given cameras
  110702. * @param cameras The camera to disable.
  110703. * @hidden
  110704. */
  110705. _disable(cameras: Camera): void;
  110706. /**
  110707. * Disables the effect on the given cameras
  110708. * @param cameras The camera to disable.
  110709. * @hidden
  110710. */
  110711. _disable(cameras: Nullable<Camera[]>): void;
  110712. /**
  110713. * Gets a list of the post processes contained in the effect.
  110714. * @param camera The camera to get the post processes on.
  110715. * @returns The list of the post processes in the effect.
  110716. */
  110717. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  110718. }
  110719. }
  110720. declare module BABYLON {
  110721. /** @hidden */
  110722. export var extractHighlightsPixelShader: {
  110723. name: string;
  110724. shader: string;
  110725. };
  110726. }
  110727. declare module BABYLON {
  110728. /**
  110729. * 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.
  110730. */
  110731. export class ExtractHighlightsPostProcess extends PostProcess {
  110732. /**
  110733. * The luminance threshold, pixels below this value will be set to black.
  110734. */
  110735. threshold: number;
  110736. /** @hidden */
  110737. _exposure: number;
  110738. /**
  110739. * Post process which has the input texture to be used when performing highlight extraction
  110740. * @hidden
  110741. */
  110742. _inputPostProcess: Nullable<PostProcess>;
  110743. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110744. }
  110745. }
  110746. declare module BABYLON {
  110747. /** @hidden */
  110748. export var bloomMergePixelShader: {
  110749. name: string;
  110750. shader: string;
  110751. };
  110752. }
  110753. declare module BABYLON {
  110754. /**
  110755. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  110756. */
  110757. export class BloomMergePostProcess extends PostProcess {
  110758. /** Weight of the bloom to be added to the original input. */
  110759. weight: number;
  110760. /**
  110761. * Creates a new instance of @see BloomMergePostProcess
  110762. * @param name The name of the effect.
  110763. * @param originalFromInput Post process which's input will be used for the merge.
  110764. * @param blurred Blurred highlights post process which's output will be used.
  110765. * @param weight Weight of the bloom to be added to the original input.
  110766. * @param options The required width/height ratio to downsize to before computing the render pass.
  110767. * @param camera The camera to apply the render pass to.
  110768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110769. * @param engine The engine which the post process will be applied. (default: current engine)
  110770. * @param reusable If the post process can be reused on the same frame. (default: false)
  110771. * @param textureType Type of textures used when performing the post process. (default: 0)
  110772. * @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)
  110773. */
  110774. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  110775. /** Weight of the bloom to be added to the original input. */
  110776. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110777. }
  110778. }
  110779. declare module BABYLON {
  110780. /**
  110781. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  110782. */
  110783. export class BloomEffect extends PostProcessRenderEffect {
  110784. private bloomScale;
  110785. /**
  110786. * @hidden Internal
  110787. */
  110788. _effects: Array<PostProcess>;
  110789. /**
  110790. * @hidden Internal
  110791. */
  110792. _downscale: ExtractHighlightsPostProcess;
  110793. private _blurX;
  110794. private _blurY;
  110795. private _merge;
  110796. /**
  110797. * The luminance threshold to find bright areas of the image to bloom.
  110798. */
  110799. threshold: number;
  110800. /**
  110801. * The strength of the bloom.
  110802. */
  110803. weight: number;
  110804. /**
  110805. * Specifies the size of the bloom blur kernel, relative to the final output size
  110806. */
  110807. kernel: number;
  110808. /**
  110809. * Creates a new instance of @see BloomEffect
  110810. * @param scene The scene the effect belongs to.
  110811. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  110812. * @param bloomKernel The size of the kernel to be used when applying the blur.
  110813. * @param bloomWeight The the strength of bloom.
  110814. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  110815. * @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)
  110816. */
  110817. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  110818. /**
  110819. * Disposes each of the internal effects for a given camera.
  110820. * @param camera The camera to dispose the effect on.
  110821. */
  110822. disposeEffects(camera: Camera): void;
  110823. /**
  110824. * @hidden Internal
  110825. */
  110826. _updateEffects(): void;
  110827. /**
  110828. * Internal
  110829. * @returns if all the contained post processes are ready.
  110830. * @hidden
  110831. */
  110832. _isReady(): boolean;
  110833. }
  110834. }
  110835. declare module BABYLON {
  110836. /** @hidden */
  110837. export var chromaticAberrationPixelShader: {
  110838. name: string;
  110839. shader: string;
  110840. };
  110841. }
  110842. declare module BABYLON {
  110843. /**
  110844. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  110845. */
  110846. export class ChromaticAberrationPostProcess extends PostProcess {
  110847. /**
  110848. * The amount of seperation of rgb channels (default: 30)
  110849. */
  110850. aberrationAmount: number;
  110851. /**
  110852. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  110853. */
  110854. radialIntensity: number;
  110855. /**
  110856. * 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))
  110857. */
  110858. direction: Vector2;
  110859. /**
  110860. * 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))
  110861. */
  110862. centerPosition: Vector2;
  110863. /**
  110864. * Creates a new instance ChromaticAberrationPostProcess
  110865. * @param name The name of the effect.
  110866. * @param screenWidth The width of the screen to apply the effect on.
  110867. * @param screenHeight The height of the screen to apply the effect on.
  110868. * @param options The required width/height ratio to downsize to before computing the render pass.
  110869. * @param camera The camera to apply the render pass to.
  110870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110871. * @param engine The engine which the post process will be applied. (default: current engine)
  110872. * @param reusable If the post process can be reused on the same frame. (default: false)
  110873. * @param textureType Type of textures used when performing the post process. (default: 0)
  110874. * @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)
  110875. */
  110876. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110877. }
  110878. }
  110879. declare module BABYLON {
  110880. /** @hidden */
  110881. export var circleOfConfusionPixelShader: {
  110882. name: string;
  110883. shader: string;
  110884. };
  110885. }
  110886. declare module BABYLON {
  110887. /**
  110888. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  110889. */
  110890. export class CircleOfConfusionPostProcess extends PostProcess {
  110891. /**
  110892. * 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.
  110893. */
  110894. lensSize: number;
  110895. /**
  110896. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  110897. */
  110898. fStop: number;
  110899. /**
  110900. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  110901. */
  110902. focusDistance: number;
  110903. /**
  110904. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  110905. */
  110906. focalLength: number;
  110907. private _depthTexture;
  110908. /**
  110909. * Creates a new instance CircleOfConfusionPostProcess
  110910. * @param name The name of the effect.
  110911. * @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.
  110912. * @param options The required width/height ratio to downsize to before computing the render pass.
  110913. * @param camera The camera to apply the render pass to.
  110914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110915. * @param engine The engine which the post process will be applied. (default: current engine)
  110916. * @param reusable If the post process can be reused on the same frame. (default: false)
  110917. * @param textureType Type of textures used when performing the post process. (default: 0)
  110918. * @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)
  110919. */
  110920. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110921. /**
  110922. * 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.
  110923. */
  110924. depthTexture: RenderTargetTexture;
  110925. }
  110926. }
  110927. declare module BABYLON {
  110928. /** @hidden */
  110929. export var colorCorrectionPixelShader: {
  110930. name: string;
  110931. shader: string;
  110932. };
  110933. }
  110934. declare module BABYLON {
  110935. /**
  110936. *
  110937. * This post-process allows the modification of rendered colors by using
  110938. * a 'look-up table' (LUT). This effect is also called Color Grading.
  110939. *
  110940. * The object needs to be provided an url to a texture containing the color
  110941. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  110942. * Use an image editing software to tweak the LUT to match your needs.
  110943. *
  110944. * For an example of a color LUT, see here:
  110945. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  110946. * For explanations on color grading, see here:
  110947. * @see http://udn.epicgames.com/Three/ColorGrading.html
  110948. *
  110949. */
  110950. export class ColorCorrectionPostProcess extends PostProcess {
  110951. private _colorTableTexture;
  110952. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110953. }
  110954. }
  110955. declare module BABYLON {
  110956. /** @hidden */
  110957. export var convolutionPixelShader: {
  110958. name: string;
  110959. shader: string;
  110960. };
  110961. }
  110962. declare module BABYLON {
  110963. /**
  110964. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  110965. * input texture to perform effects such as edge detection or sharpening
  110966. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  110967. */
  110968. export class ConvolutionPostProcess extends PostProcess {
  110969. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  110970. kernel: number[];
  110971. /**
  110972. * Creates a new instance ConvolutionPostProcess
  110973. * @param name The name of the effect.
  110974. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  110975. * @param options The required width/height ratio to downsize to before computing the render pass.
  110976. * @param camera The camera to apply the render pass to.
  110977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110978. * @param engine The engine which the post process will be applied. (default: current engine)
  110979. * @param reusable If the post process can be reused on the same frame. (default: false)
  110980. * @param textureType Type of textures used when performing the post process. (default: 0)
  110981. */
  110982. constructor(name: string,
  110983. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  110984. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110985. /**
  110986. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110987. */
  110988. static EdgeDetect0Kernel: number[];
  110989. /**
  110990. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110991. */
  110992. static EdgeDetect1Kernel: number[];
  110993. /**
  110994. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110995. */
  110996. static EdgeDetect2Kernel: number[];
  110997. /**
  110998. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110999. */
  111000. static SharpenKernel: number[];
  111001. /**
  111002. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111003. */
  111004. static EmbossKernel: number[];
  111005. /**
  111006. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111007. */
  111008. static GaussianKernel: number[];
  111009. }
  111010. }
  111011. declare module BABYLON {
  111012. /**
  111013. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  111014. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  111015. * based on samples that have a large difference in distance than the center pixel.
  111016. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  111017. */
  111018. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  111019. direction: Vector2;
  111020. /**
  111021. * Creates a new instance CircleOfConfusionPostProcess
  111022. * @param name The name of the effect.
  111023. * @param scene The scene the effect belongs to.
  111024. * @param direction The direction the blur should be applied.
  111025. * @param kernel The size of the kernel used to blur.
  111026. * @param options The required width/height ratio to downsize to before computing the render pass.
  111027. * @param camera The camera to apply the render pass to.
  111028. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  111029. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  111030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111031. * @param engine The engine which the post process will be applied. (default: current engine)
  111032. * @param reusable If the post process can be reused on the same frame. (default: false)
  111033. * @param textureType Type of textures used when performing the post process. (default: 0)
  111034. * @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)
  111035. */
  111036. 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);
  111037. }
  111038. }
  111039. declare module BABYLON {
  111040. /** @hidden */
  111041. export var depthOfFieldMergePixelShader: {
  111042. name: string;
  111043. shader: string;
  111044. };
  111045. }
  111046. declare module BABYLON {
  111047. /**
  111048. * Options to be set when merging outputs from the default pipeline.
  111049. */
  111050. export class DepthOfFieldMergePostProcessOptions {
  111051. /**
  111052. * The original image to merge on top of
  111053. */
  111054. originalFromInput: PostProcess;
  111055. /**
  111056. * Parameters to perform the merge of the depth of field effect
  111057. */
  111058. depthOfField?: {
  111059. circleOfConfusion: PostProcess;
  111060. blurSteps: Array<PostProcess>;
  111061. };
  111062. /**
  111063. * Parameters to perform the merge of bloom effect
  111064. */
  111065. bloom?: {
  111066. blurred: PostProcess;
  111067. weight: number;
  111068. };
  111069. }
  111070. /**
  111071. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111072. */
  111073. export class DepthOfFieldMergePostProcess extends PostProcess {
  111074. private blurSteps;
  111075. /**
  111076. * Creates a new instance of DepthOfFieldMergePostProcess
  111077. * @param name The name of the effect.
  111078. * @param originalFromInput Post process which's input will be used for the merge.
  111079. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  111080. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  111081. * @param options The required width/height ratio to downsize to before computing the render pass.
  111082. * @param camera The camera to apply the render pass to.
  111083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111084. * @param engine The engine which the post process will be applied. (default: current engine)
  111085. * @param reusable If the post process can be reused on the same frame. (default: false)
  111086. * @param textureType Type of textures used when performing the post process. (default: 0)
  111087. * @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)
  111088. */
  111089. 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);
  111090. /**
  111091. * Updates the effect with the current post process compile time values and recompiles the shader.
  111092. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  111093. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  111094. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  111095. * @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
  111096. * @param onCompiled Called when the shader has been compiled.
  111097. * @param onError Called if there is an error when compiling a shader.
  111098. */
  111099. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  111100. }
  111101. }
  111102. declare module BABYLON {
  111103. /**
  111104. * Specifies the level of max blur that should be applied when using the depth of field effect
  111105. */
  111106. export enum DepthOfFieldEffectBlurLevel {
  111107. /**
  111108. * Subtle blur
  111109. */
  111110. Low = 0,
  111111. /**
  111112. * Medium blur
  111113. */
  111114. Medium = 1,
  111115. /**
  111116. * Large blur
  111117. */
  111118. High = 2
  111119. }
  111120. /**
  111121. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  111122. */
  111123. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  111124. private _circleOfConfusion;
  111125. /**
  111126. * @hidden Internal, blurs from high to low
  111127. */
  111128. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  111129. private _depthOfFieldBlurY;
  111130. private _dofMerge;
  111131. /**
  111132. * @hidden Internal post processes in depth of field effect
  111133. */
  111134. _effects: Array<PostProcess>;
  111135. /**
  111136. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  111137. */
  111138. focalLength: number;
  111139. /**
  111140. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111141. */
  111142. fStop: number;
  111143. /**
  111144. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111145. */
  111146. focusDistance: number;
  111147. /**
  111148. * 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.
  111149. */
  111150. lensSize: number;
  111151. /**
  111152. * Creates a new instance DepthOfFieldEffect
  111153. * @param scene The scene the effect belongs to.
  111154. * @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.
  111155. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111156. * @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)
  111157. */
  111158. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  111159. /**
  111160. * 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.
  111161. */
  111162. depthTexture: RenderTargetTexture;
  111163. /**
  111164. * Disposes each of the internal effects for a given camera.
  111165. * @param camera The camera to dispose the effect on.
  111166. */
  111167. disposeEffects(camera: Camera): void;
  111168. /**
  111169. * @hidden Internal
  111170. */
  111171. _updateEffects(): void;
  111172. /**
  111173. * Internal
  111174. * @returns if all the contained post processes are ready.
  111175. * @hidden
  111176. */
  111177. _isReady(): boolean;
  111178. }
  111179. }
  111180. declare module BABYLON {
  111181. /** @hidden */
  111182. export var displayPassPixelShader: {
  111183. name: string;
  111184. shader: string;
  111185. };
  111186. }
  111187. declare module BABYLON {
  111188. /**
  111189. * DisplayPassPostProcess which produces an output the same as it's input
  111190. */
  111191. export class DisplayPassPostProcess extends PostProcess {
  111192. /**
  111193. * Creates the DisplayPassPostProcess
  111194. * @param name The name of the effect.
  111195. * @param options The required width/height ratio to downsize to before computing the render pass.
  111196. * @param camera The camera to apply the render pass to.
  111197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111198. * @param engine The engine which the post process will be applied. (default: current engine)
  111199. * @param reusable If the post process can be reused on the same frame. (default: false)
  111200. */
  111201. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111202. }
  111203. }
  111204. declare module BABYLON {
  111205. /** @hidden */
  111206. export var filterPixelShader: {
  111207. name: string;
  111208. shader: string;
  111209. };
  111210. }
  111211. declare module BABYLON {
  111212. /**
  111213. * Applies a kernel filter to the image
  111214. */
  111215. export class FilterPostProcess extends PostProcess {
  111216. /** The matrix to be applied to the image */
  111217. kernelMatrix: Matrix;
  111218. /**
  111219. *
  111220. * @param name The name of the effect.
  111221. * @param kernelMatrix The matrix to be applied to the image
  111222. * @param options The required width/height ratio to downsize to before computing the render pass.
  111223. * @param camera The camera to apply the render pass to.
  111224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111225. * @param engine The engine which the post process will be applied. (default: current engine)
  111226. * @param reusable If the post process can be reused on the same frame. (default: false)
  111227. */
  111228. constructor(name: string,
  111229. /** The matrix to be applied to the image */
  111230. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111231. }
  111232. }
  111233. declare module BABYLON {
  111234. /** @hidden */
  111235. export var fxaaPixelShader: {
  111236. name: string;
  111237. shader: string;
  111238. };
  111239. }
  111240. declare module BABYLON {
  111241. /** @hidden */
  111242. export var fxaaVertexShader: {
  111243. name: string;
  111244. shader: string;
  111245. };
  111246. }
  111247. declare module BABYLON {
  111248. /**
  111249. * Fxaa post process
  111250. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  111251. */
  111252. export class FxaaPostProcess extends PostProcess {
  111253. /** @hidden */
  111254. texelWidth: number;
  111255. /** @hidden */
  111256. texelHeight: number;
  111257. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111258. private _getDefines;
  111259. }
  111260. }
  111261. declare module BABYLON {
  111262. /** @hidden */
  111263. export var grainPixelShader: {
  111264. name: string;
  111265. shader: string;
  111266. };
  111267. }
  111268. declare module BABYLON {
  111269. /**
  111270. * The GrainPostProcess adds noise to the image at mid luminance levels
  111271. */
  111272. export class GrainPostProcess extends PostProcess {
  111273. /**
  111274. * The intensity of the grain added (default: 30)
  111275. */
  111276. intensity: number;
  111277. /**
  111278. * If the grain should be randomized on every frame
  111279. */
  111280. animated: boolean;
  111281. /**
  111282. * Creates a new instance of @see GrainPostProcess
  111283. * @param name The name of the effect.
  111284. * @param options The required width/height ratio to downsize to before computing the render pass.
  111285. * @param camera The camera to apply the render pass to.
  111286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111287. * @param engine The engine which the post process will be applied. (default: current engine)
  111288. * @param reusable If the post process can be reused on the same frame. (default: false)
  111289. * @param textureType Type of textures used when performing the post process. (default: 0)
  111290. * @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)
  111291. */
  111292. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111293. }
  111294. }
  111295. declare module BABYLON {
  111296. /** @hidden */
  111297. export var highlightsPixelShader: {
  111298. name: string;
  111299. shader: string;
  111300. };
  111301. }
  111302. declare module BABYLON {
  111303. /**
  111304. * Extracts highlights from the image
  111305. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111306. */
  111307. export class HighlightsPostProcess extends PostProcess {
  111308. /**
  111309. * Extracts highlights from the image
  111310. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111311. * @param name The name of the effect.
  111312. * @param options The required width/height ratio to downsize to before computing the render pass.
  111313. * @param camera The camera to apply the render pass to.
  111314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111315. * @param engine The engine which the post process will be applied. (default: current engine)
  111316. * @param reusable If the post process can be reused on the same frame. (default: false)
  111317. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  111318. */
  111319. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111320. }
  111321. }
  111322. declare module BABYLON {
  111323. /** @hidden */
  111324. export var mrtFragmentDeclaration: {
  111325. name: string;
  111326. shader: string;
  111327. };
  111328. }
  111329. declare module BABYLON {
  111330. /** @hidden */
  111331. export var geometryPixelShader: {
  111332. name: string;
  111333. shader: string;
  111334. };
  111335. }
  111336. declare module BABYLON {
  111337. /** @hidden */
  111338. export var geometryVertexShader: {
  111339. name: string;
  111340. shader: string;
  111341. };
  111342. }
  111343. declare module BABYLON {
  111344. /**
  111345. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  111346. */
  111347. export class GeometryBufferRenderer {
  111348. /**
  111349. * Constant used to retrieve the position texture index in the G-Buffer textures array
  111350. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  111351. */
  111352. static readonly POSITION_TEXTURE_TYPE: number;
  111353. /**
  111354. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  111355. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  111356. */
  111357. static readonly VELOCITY_TEXTURE_TYPE: number;
  111358. /**
  111359. * Dictionary used to store the previous transformation matrices of each rendered mesh
  111360. * in order to compute objects velocities when enableVelocity is set to "true"
  111361. * @hidden
  111362. */
  111363. _previousTransformationMatrices: {
  111364. [index: number]: Matrix;
  111365. };
  111366. private _scene;
  111367. private _multiRenderTarget;
  111368. private _ratio;
  111369. private _enablePosition;
  111370. private _enableVelocity;
  111371. private _positionIndex;
  111372. private _velocityIndex;
  111373. protected _effect: Effect;
  111374. protected _cachedDefines: string;
  111375. /**
  111376. * Set the render list (meshes to be rendered) used in the G buffer.
  111377. */
  111378. renderList: Mesh[];
  111379. /**
  111380. * Gets wether or not G buffer are supported by the running hardware.
  111381. * This requires draw buffer supports
  111382. */
  111383. readonly isSupported: boolean;
  111384. /**
  111385. * Returns the index of the given texture type in the G-Buffer textures array
  111386. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  111387. * @returns the index of the given texture type in the G-Buffer textures array
  111388. */
  111389. getTextureIndex(textureType: number): number;
  111390. /**
  111391. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  111392. */
  111393. /**
  111394. * Sets whether or not objects positions are enabled for the G buffer.
  111395. */
  111396. enablePosition: boolean;
  111397. /**
  111398. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  111399. */
  111400. /**
  111401. * Sets wether or not objects velocities are enabled for the G buffer.
  111402. */
  111403. enableVelocity: boolean;
  111404. /**
  111405. * Gets the scene associated with the buffer.
  111406. */
  111407. readonly scene: Scene;
  111408. /**
  111409. * Gets the ratio used by the buffer during its creation.
  111410. * How big is the buffer related to the main canvas.
  111411. */
  111412. readonly ratio: number;
  111413. /** @hidden */
  111414. static _SceneComponentInitialization: (scene: Scene) => void;
  111415. /**
  111416. * Creates a new G Buffer for the scene
  111417. * @param scene The scene the buffer belongs to
  111418. * @param ratio How big is the buffer related to the main canvas.
  111419. */
  111420. constructor(scene: Scene, ratio?: number);
  111421. /**
  111422. * Checks wether everything is ready to render a submesh to the G buffer.
  111423. * @param subMesh the submesh to check readiness for
  111424. * @param useInstances is the mesh drawn using instance or not
  111425. * @returns true if ready otherwise false
  111426. */
  111427. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111428. /**
  111429. * Gets the current underlying G Buffer.
  111430. * @returns the buffer
  111431. */
  111432. getGBuffer(): MultiRenderTarget;
  111433. /**
  111434. * Gets the number of samples used to render the buffer (anti aliasing).
  111435. */
  111436. /**
  111437. * Sets the number of samples used to render the buffer (anti aliasing).
  111438. */
  111439. samples: number;
  111440. /**
  111441. * Disposes the renderer and frees up associated resources.
  111442. */
  111443. dispose(): void;
  111444. protected _createRenderTargets(): void;
  111445. }
  111446. }
  111447. declare module BABYLON {
  111448. interface Scene {
  111449. /** @hidden (Backing field) */
  111450. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  111451. /**
  111452. * Gets or Sets the current geometry buffer associated to the scene.
  111453. */
  111454. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  111455. /**
  111456. * Enables a GeometryBufferRender and associates it with the scene
  111457. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  111458. * @returns the GeometryBufferRenderer
  111459. */
  111460. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  111461. /**
  111462. * Disables the GeometryBufferRender associated with the scene
  111463. */
  111464. disableGeometryBufferRenderer(): void;
  111465. }
  111466. /**
  111467. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  111468. * in several rendering techniques.
  111469. */
  111470. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  111471. /**
  111472. * The component name helpful to identify the component in the list of scene components.
  111473. */
  111474. readonly name: string;
  111475. /**
  111476. * The scene the component belongs to.
  111477. */
  111478. scene: Scene;
  111479. /**
  111480. * Creates a new instance of the component for the given scene
  111481. * @param scene Defines the scene to register the component in
  111482. */
  111483. constructor(scene: Scene);
  111484. /**
  111485. * Registers the component in a given scene
  111486. */
  111487. register(): void;
  111488. /**
  111489. * Rebuilds the elements related to this component in case of
  111490. * context lost for instance.
  111491. */
  111492. rebuild(): void;
  111493. /**
  111494. * Disposes the component and the associated ressources
  111495. */
  111496. dispose(): void;
  111497. private _gatherRenderTargets;
  111498. }
  111499. }
  111500. declare module BABYLON {
  111501. /** @hidden */
  111502. export var motionBlurPixelShader: {
  111503. name: string;
  111504. shader: string;
  111505. };
  111506. }
  111507. declare module BABYLON {
  111508. /**
  111509. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  111510. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  111511. * As an example, all you have to do is to create the post-process:
  111512. * var mb = new BABYLON.MotionBlurPostProcess(
  111513. * 'mb', // The name of the effect.
  111514. * scene, // The scene containing the objects to blur according to their velocity.
  111515. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  111516. * camera // The camera to apply the render pass to.
  111517. * );
  111518. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  111519. */
  111520. export class MotionBlurPostProcess extends PostProcess {
  111521. /**
  111522. * Defines how much the image is blurred by the movement. Default value is equal to 1
  111523. */
  111524. motionStrength: number;
  111525. /**
  111526. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  111527. */
  111528. /**
  111529. * Sets the number of iterations to be used for motion blur quality
  111530. */
  111531. motionBlurSamples: number;
  111532. private _motionBlurSamples;
  111533. private _geometryBufferRenderer;
  111534. /**
  111535. * Creates a new instance MotionBlurPostProcess
  111536. * @param name The name of the effect.
  111537. * @param scene The scene containing the objects to blur according to their velocity.
  111538. * @param options The required width/height ratio to downsize to before computing the render pass.
  111539. * @param camera The camera to apply the render pass to.
  111540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111541. * @param engine The engine which the post process will be applied. (default: current engine)
  111542. * @param reusable If the post process can be reused on the same frame. (default: false)
  111543. * @param textureType Type of textures used when performing the post process. (default: 0)
  111544. * @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)
  111545. */
  111546. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111547. /**
  111548. * Disposes the post process.
  111549. * @param camera The camera to dispose the post process on.
  111550. */
  111551. dispose(camera?: Camera): void;
  111552. }
  111553. }
  111554. declare module BABYLON {
  111555. /** @hidden */
  111556. export var refractionPixelShader: {
  111557. name: string;
  111558. shader: string;
  111559. };
  111560. }
  111561. declare module BABYLON {
  111562. /**
  111563. * Post process which applies a refractin texture
  111564. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  111565. */
  111566. export class RefractionPostProcess extends PostProcess {
  111567. /** the base color of the refraction (used to taint the rendering) */
  111568. color: Color3;
  111569. /** simulated refraction depth */
  111570. depth: number;
  111571. /** the coefficient of the base color (0 to remove base color tainting) */
  111572. colorLevel: number;
  111573. private _refTexture;
  111574. private _ownRefractionTexture;
  111575. /**
  111576. * Gets or sets the refraction texture
  111577. * Please note that you are responsible for disposing the texture if you set it manually
  111578. */
  111579. refractionTexture: Texture;
  111580. /**
  111581. * Initializes the RefractionPostProcess
  111582. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  111583. * @param name The name of the effect.
  111584. * @param refractionTextureUrl Url of the refraction texture to use
  111585. * @param color the base color of the refraction (used to taint the rendering)
  111586. * @param depth simulated refraction depth
  111587. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  111588. * @param camera The camera to apply the render pass to.
  111589. * @param options The required width/height ratio to downsize to before computing the render pass.
  111590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111591. * @param engine The engine which the post process will be applied. (default: current engine)
  111592. * @param reusable If the post process can be reused on the same frame. (default: false)
  111593. */
  111594. constructor(name: string, refractionTextureUrl: string,
  111595. /** the base color of the refraction (used to taint the rendering) */
  111596. color: Color3,
  111597. /** simulated refraction depth */
  111598. depth: number,
  111599. /** the coefficient of the base color (0 to remove base color tainting) */
  111600. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111601. /**
  111602. * Disposes of the post process
  111603. * @param camera Camera to dispose post process on
  111604. */
  111605. dispose(camera: Camera): void;
  111606. }
  111607. }
  111608. declare module BABYLON {
  111609. /** @hidden */
  111610. export var sharpenPixelShader: {
  111611. name: string;
  111612. shader: string;
  111613. };
  111614. }
  111615. declare module BABYLON {
  111616. /**
  111617. * The SharpenPostProcess applies a sharpen kernel to every pixel
  111618. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  111619. */
  111620. export class SharpenPostProcess extends PostProcess {
  111621. /**
  111622. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  111623. */
  111624. colorAmount: number;
  111625. /**
  111626. * How much sharpness should be applied (default: 0.3)
  111627. */
  111628. edgeAmount: number;
  111629. /**
  111630. * Creates a new instance ConvolutionPostProcess
  111631. * @param name The name of the effect.
  111632. * @param options The required width/height ratio to downsize to before computing the render pass.
  111633. * @param camera The camera to apply the render pass to.
  111634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111635. * @param engine The engine which the post process will be applied. (default: current engine)
  111636. * @param reusable If the post process can be reused on the same frame. (default: false)
  111637. * @param textureType Type of textures used when performing the post process. (default: 0)
  111638. * @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)
  111639. */
  111640. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111641. }
  111642. }
  111643. declare module BABYLON {
  111644. /**
  111645. * PostProcessRenderPipeline
  111646. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111647. */
  111648. export class PostProcessRenderPipeline {
  111649. private engine;
  111650. private _renderEffects;
  111651. private _renderEffectsForIsolatedPass;
  111652. /**
  111653. * List of inspectable custom properties (used by the Inspector)
  111654. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111655. */
  111656. inspectableCustomProperties: IInspectable[];
  111657. /**
  111658. * @hidden
  111659. */
  111660. protected _cameras: Camera[];
  111661. /** @hidden */
  111662. _name: string;
  111663. /**
  111664. * Gets pipeline name
  111665. */
  111666. readonly name: string;
  111667. /**
  111668. * Initializes a PostProcessRenderPipeline
  111669. * @param engine engine to add the pipeline to
  111670. * @param name name of the pipeline
  111671. */
  111672. constructor(engine: Engine, name: string);
  111673. /**
  111674. * Gets the class name
  111675. * @returns "PostProcessRenderPipeline"
  111676. */
  111677. getClassName(): string;
  111678. /**
  111679. * If all the render effects in the pipeline are supported
  111680. */
  111681. readonly isSupported: boolean;
  111682. /**
  111683. * Adds an effect to the pipeline
  111684. * @param renderEffect the effect to add
  111685. */
  111686. addEffect(renderEffect: PostProcessRenderEffect): void;
  111687. /** @hidden */
  111688. _rebuild(): void;
  111689. /** @hidden */
  111690. _enableEffect(renderEffectName: string, cameras: Camera): void;
  111691. /** @hidden */
  111692. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  111693. /** @hidden */
  111694. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  111695. /** @hidden */
  111696. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  111697. /** @hidden */
  111698. _attachCameras(cameras: Camera, unique: boolean): void;
  111699. /** @hidden */
  111700. _attachCameras(cameras: Camera[], unique: boolean): void;
  111701. /** @hidden */
  111702. _detachCameras(cameras: Camera): void;
  111703. /** @hidden */
  111704. _detachCameras(cameras: Nullable<Camera[]>): void;
  111705. /** @hidden */
  111706. _update(): void;
  111707. /** @hidden */
  111708. _reset(): void;
  111709. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  111710. /**
  111711. * Disposes of the pipeline
  111712. */
  111713. dispose(): void;
  111714. }
  111715. }
  111716. declare module BABYLON {
  111717. /**
  111718. * PostProcessRenderPipelineManager class
  111719. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111720. */
  111721. export class PostProcessRenderPipelineManager {
  111722. private _renderPipelines;
  111723. /**
  111724. * Initializes a PostProcessRenderPipelineManager
  111725. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111726. */
  111727. constructor();
  111728. /**
  111729. * Gets the list of supported render pipelines
  111730. */
  111731. readonly supportedPipelines: PostProcessRenderPipeline[];
  111732. /**
  111733. * Adds a pipeline to the manager
  111734. * @param renderPipeline The pipeline to add
  111735. */
  111736. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  111737. /**
  111738. * Attaches a camera to the pipeline
  111739. * @param renderPipelineName The name of the pipeline to attach to
  111740. * @param cameras the camera to attach
  111741. * @param unique if the camera can be attached multiple times to the pipeline
  111742. */
  111743. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  111744. /**
  111745. * Detaches a camera from the pipeline
  111746. * @param renderPipelineName The name of the pipeline to detach from
  111747. * @param cameras the camera to detach
  111748. */
  111749. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  111750. /**
  111751. * Enables an effect by name on a pipeline
  111752. * @param renderPipelineName the name of the pipeline to enable the effect in
  111753. * @param renderEffectName the name of the effect to enable
  111754. * @param cameras the cameras that the effect should be enabled on
  111755. */
  111756. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  111757. /**
  111758. * Disables an effect by name on a pipeline
  111759. * @param renderPipelineName the name of the pipeline to disable the effect in
  111760. * @param renderEffectName the name of the effect to disable
  111761. * @param cameras the cameras that the effect should be disabled on
  111762. */
  111763. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  111764. /**
  111765. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  111766. */
  111767. update(): void;
  111768. /** @hidden */
  111769. _rebuild(): void;
  111770. /**
  111771. * Disposes of the manager and pipelines
  111772. */
  111773. dispose(): void;
  111774. }
  111775. }
  111776. declare module BABYLON {
  111777. interface Scene {
  111778. /** @hidden (Backing field) */
  111779. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  111780. /**
  111781. * Gets the postprocess render pipeline manager
  111782. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111783. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  111784. */
  111785. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  111786. }
  111787. /**
  111788. * Defines the Render Pipeline scene component responsible to rendering pipelines
  111789. */
  111790. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  111791. /**
  111792. * The component name helpfull to identify the component in the list of scene components.
  111793. */
  111794. readonly name: string;
  111795. /**
  111796. * The scene the component belongs to.
  111797. */
  111798. scene: Scene;
  111799. /**
  111800. * Creates a new instance of the component for the given scene
  111801. * @param scene Defines the scene to register the component in
  111802. */
  111803. constructor(scene: Scene);
  111804. /**
  111805. * Registers the component in a given scene
  111806. */
  111807. register(): void;
  111808. /**
  111809. * Rebuilds the elements related to this component in case of
  111810. * context lost for instance.
  111811. */
  111812. rebuild(): void;
  111813. /**
  111814. * Disposes the component and the associated ressources
  111815. */
  111816. dispose(): void;
  111817. private _gatherRenderTargets;
  111818. }
  111819. }
  111820. declare module BABYLON {
  111821. /**
  111822. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  111823. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  111824. */
  111825. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  111826. private _scene;
  111827. private _camerasToBeAttached;
  111828. /**
  111829. * ID of the sharpen post process,
  111830. */
  111831. private readonly SharpenPostProcessId;
  111832. /**
  111833. * @ignore
  111834. * ID of the image processing post process;
  111835. */
  111836. readonly ImageProcessingPostProcessId: string;
  111837. /**
  111838. * @ignore
  111839. * ID of the Fast Approximate Anti-Aliasing post process;
  111840. */
  111841. readonly FxaaPostProcessId: string;
  111842. /**
  111843. * ID of the chromatic aberration post process,
  111844. */
  111845. private readonly ChromaticAberrationPostProcessId;
  111846. /**
  111847. * ID of the grain post process
  111848. */
  111849. private readonly GrainPostProcessId;
  111850. /**
  111851. * Sharpen post process which will apply a sharpen convolution to enhance edges
  111852. */
  111853. sharpen: SharpenPostProcess;
  111854. private _sharpenEffect;
  111855. private bloom;
  111856. /**
  111857. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  111858. */
  111859. depthOfField: DepthOfFieldEffect;
  111860. /**
  111861. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  111862. */
  111863. fxaa: FxaaPostProcess;
  111864. /**
  111865. * Image post processing pass used to perform operations such as tone mapping or color grading.
  111866. */
  111867. imageProcessing: ImageProcessingPostProcess;
  111868. /**
  111869. * Chromatic aberration post process which will shift rgb colors in the image
  111870. */
  111871. chromaticAberration: ChromaticAberrationPostProcess;
  111872. private _chromaticAberrationEffect;
  111873. /**
  111874. * Grain post process which add noise to the image
  111875. */
  111876. grain: GrainPostProcess;
  111877. private _grainEffect;
  111878. /**
  111879. * Glow post process which adds a glow to emissive areas of the image
  111880. */
  111881. private _glowLayer;
  111882. /**
  111883. * Animations which can be used to tweak settings over a period of time
  111884. */
  111885. animations: Animation[];
  111886. private _imageProcessingConfigurationObserver;
  111887. private _sharpenEnabled;
  111888. private _bloomEnabled;
  111889. private _depthOfFieldEnabled;
  111890. private _depthOfFieldBlurLevel;
  111891. private _fxaaEnabled;
  111892. private _imageProcessingEnabled;
  111893. private _defaultPipelineTextureType;
  111894. private _bloomScale;
  111895. private _chromaticAberrationEnabled;
  111896. private _grainEnabled;
  111897. private _buildAllowed;
  111898. /**
  111899. * Gets active scene
  111900. */
  111901. readonly scene: Scene;
  111902. /**
  111903. * Enable or disable the sharpen process from the pipeline
  111904. */
  111905. sharpenEnabled: boolean;
  111906. private _resizeObserver;
  111907. private _hardwareScaleLevel;
  111908. private _bloomKernel;
  111909. /**
  111910. * Specifies the size of the bloom blur kernel, relative to the final output size
  111911. */
  111912. bloomKernel: number;
  111913. /**
  111914. * Specifies the weight of the bloom in the final rendering
  111915. */
  111916. private _bloomWeight;
  111917. /**
  111918. * Specifies the luma threshold for the area that will be blurred by the bloom
  111919. */
  111920. private _bloomThreshold;
  111921. private _hdr;
  111922. /**
  111923. * The strength of the bloom.
  111924. */
  111925. bloomWeight: number;
  111926. /**
  111927. * The strength of the bloom.
  111928. */
  111929. bloomThreshold: number;
  111930. /**
  111931. * The scale of the bloom, lower value will provide better performance.
  111932. */
  111933. bloomScale: number;
  111934. /**
  111935. * Enable or disable the bloom from the pipeline
  111936. */
  111937. bloomEnabled: boolean;
  111938. private _rebuildBloom;
  111939. /**
  111940. * If the depth of field is enabled.
  111941. */
  111942. depthOfFieldEnabled: boolean;
  111943. /**
  111944. * Blur level of the depth of field effect. (Higher blur will effect performance)
  111945. */
  111946. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  111947. /**
  111948. * If the anti aliasing is enabled.
  111949. */
  111950. fxaaEnabled: boolean;
  111951. private _samples;
  111952. /**
  111953. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  111954. */
  111955. samples: number;
  111956. /**
  111957. * If image processing is enabled.
  111958. */
  111959. imageProcessingEnabled: boolean;
  111960. /**
  111961. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  111962. */
  111963. glowLayerEnabled: boolean;
  111964. /**
  111965. * Enable or disable the chromaticAberration process from the pipeline
  111966. */
  111967. chromaticAberrationEnabled: boolean;
  111968. /**
  111969. * Enable or disable the grain process from the pipeline
  111970. */
  111971. grainEnabled: boolean;
  111972. /**
  111973. * @constructor
  111974. * @param name - The rendering pipeline name (default: "")
  111975. * @param hdr - If high dynamic range textures should be used (default: true)
  111976. * @param scene - The scene linked to this pipeline (default: the last created scene)
  111977. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  111978. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  111979. */
  111980. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  111981. /**
  111982. * Get the class name
  111983. * @returns "DefaultRenderingPipeline"
  111984. */
  111985. getClassName(): string;
  111986. /**
  111987. * Force the compilation of the entire pipeline.
  111988. */
  111989. prepare(): void;
  111990. private _hasCleared;
  111991. private _prevPostProcess;
  111992. private _prevPrevPostProcess;
  111993. private _setAutoClearAndTextureSharing;
  111994. private _depthOfFieldSceneObserver;
  111995. private _buildPipeline;
  111996. private _disposePostProcesses;
  111997. /**
  111998. * Adds a camera to the pipeline
  111999. * @param camera the camera to be added
  112000. */
  112001. addCamera(camera: Camera): void;
  112002. /**
  112003. * Removes a camera from the pipeline
  112004. * @param camera the camera to remove
  112005. */
  112006. removeCamera(camera: Camera): void;
  112007. /**
  112008. * Dispose of the pipeline and stop all post processes
  112009. */
  112010. dispose(): void;
  112011. /**
  112012. * Serialize the rendering pipeline (Used when exporting)
  112013. * @returns the serialized object
  112014. */
  112015. serialize(): any;
  112016. /**
  112017. * Parse the serialized pipeline
  112018. * @param source Source pipeline.
  112019. * @param scene The scene to load the pipeline to.
  112020. * @param rootUrl The URL of the serialized pipeline.
  112021. * @returns An instantiated pipeline from the serialized object.
  112022. */
  112023. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  112024. }
  112025. }
  112026. declare module BABYLON {
  112027. /** @hidden */
  112028. export var lensHighlightsPixelShader: {
  112029. name: string;
  112030. shader: string;
  112031. };
  112032. }
  112033. declare module BABYLON {
  112034. /** @hidden */
  112035. export var depthOfFieldPixelShader: {
  112036. name: string;
  112037. shader: string;
  112038. };
  112039. }
  112040. declare module BABYLON {
  112041. /**
  112042. * BABYLON.JS Chromatic Aberration GLSL Shader
  112043. * Author: Olivier Guyot
  112044. * Separates very slightly R, G and B colors on the edges of the screen
  112045. * Inspired by Francois Tarlier & Martins Upitis
  112046. */
  112047. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  112048. /**
  112049. * @ignore
  112050. * The chromatic aberration PostProcess id in the pipeline
  112051. */
  112052. LensChromaticAberrationEffect: string;
  112053. /**
  112054. * @ignore
  112055. * The highlights enhancing PostProcess id in the pipeline
  112056. */
  112057. HighlightsEnhancingEffect: string;
  112058. /**
  112059. * @ignore
  112060. * The depth-of-field PostProcess id in the pipeline
  112061. */
  112062. LensDepthOfFieldEffect: string;
  112063. private _scene;
  112064. private _depthTexture;
  112065. private _grainTexture;
  112066. private _chromaticAberrationPostProcess;
  112067. private _highlightsPostProcess;
  112068. private _depthOfFieldPostProcess;
  112069. private _edgeBlur;
  112070. private _grainAmount;
  112071. private _chromaticAberration;
  112072. private _distortion;
  112073. private _highlightsGain;
  112074. private _highlightsThreshold;
  112075. private _dofDistance;
  112076. private _dofAperture;
  112077. private _dofDarken;
  112078. private _dofPentagon;
  112079. private _blurNoise;
  112080. /**
  112081. * @constructor
  112082. *
  112083. * Effect parameters are as follow:
  112084. * {
  112085. * chromatic_aberration: number; // from 0 to x (1 for realism)
  112086. * edge_blur: number; // from 0 to x (1 for realism)
  112087. * distortion: number; // from 0 to x (1 for realism)
  112088. * grain_amount: number; // from 0 to 1
  112089. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  112090. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  112091. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  112092. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  112093. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  112094. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  112095. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  112096. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  112097. * }
  112098. * Note: if an effect parameter is unset, effect is disabled
  112099. *
  112100. * @param name The rendering pipeline name
  112101. * @param parameters - An object containing all parameters (see above)
  112102. * @param scene The scene linked to this pipeline
  112103. * @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)
  112104. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112105. */
  112106. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  112107. /**
  112108. * Get the class name
  112109. * @returns "LensRenderingPipeline"
  112110. */
  112111. getClassName(): string;
  112112. /**
  112113. * Gets associated scene
  112114. */
  112115. readonly scene: Scene;
  112116. /**
  112117. * Gets or sets the edge blur
  112118. */
  112119. edgeBlur: number;
  112120. /**
  112121. * Gets or sets the grain amount
  112122. */
  112123. grainAmount: number;
  112124. /**
  112125. * Gets or sets the chromatic aberration amount
  112126. */
  112127. chromaticAberration: number;
  112128. /**
  112129. * Gets or sets the depth of field aperture
  112130. */
  112131. dofAperture: number;
  112132. /**
  112133. * Gets or sets the edge distortion
  112134. */
  112135. edgeDistortion: number;
  112136. /**
  112137. * Gets or sets the depth of field distortion
  112138. */
  112139. dofDistortion: number;
  112140. /**
  112141. * Gets or sets the darken out of focus amount
  112142. */
  112143. darkenOutOfFocus: number;
  112144. /**
  112145. * Gets or sets a boolean indicating if blur noise is enabled
  112146. */
  112147. blurNoise: boolean;
  112148. /**
  112149. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  112150. */
  112151. pentagonBokeh: boolean;
  112152. /**
  112153. * Gets or sets the highlight grain amount
  112154. */
  112155. highlightsGain: number;
  112156. /**
  112157. * Gets or sets the highlight threshold
  112158. */
  112159. highlightsThreshold: number;
  112160. /**
  112161. * Sets the amount of blur at the edges
  112162. * @param amount blur amount
  112163. */
  112164. setEdgeBlur(amount: number): void;
  112165. /**
  112166. * Sets edge blur to 0
  112167. */
  112168. disableEdgeBlur(): void;
  112169. /**
  112170. * Sets the amout of grain
  112171. * @param amount Amount of grain
  112172. */
  112173. setGrainAmount(amount: number): void;
  112174. /**
  112175. * Set grain amount to 0
  112176. */
  112177. disableGrain(): void;
  112178. /**
  112179. * Sets the chromatic aberration amount
  112180. * @param amount amount of chromatic aberration
  112181. */
  112182. setChromaticAberration(amount: number): void;
  112183. /**
  112184. * Sets chromatic aberration amount to 0
  112185. */
  112186. disableChromaticAberration(): void;
  112187. /**
  112188. * Sets the EdgeDistortion amount
  112189. * @param amount amount of EdgeDistortion
  112190. */
  112191. setEdgeDistortion(amount: number): void;
  112192. /**
  112193. * Sets edge distortion to 0
  112194. */
  112195. disableEdgeDistortion(): void;
  112196. /**
  112197. * Sets the FocusDistance amount
  112198. * @param amount amount of FocusDistance
  112199. */
  112200. setFocusDistance(amount: number): void;
  112201. /**
  112202. * Disables depth of field
  112203. */
  112204. disableDepthOfField(): void;
  112205. /**
  112206. * Sets the Aperture amount
  112207. * @param amount amount of Aperture
  112208. */
  112209. setAperture(amount: number): void;
  112210. /**
  112211. * Sets the DarkenOutOfFocus amount
  112212. * @param amount amount of DarkenOutOfFocus
  112213. */
  112214. setDarkenOutOfFocus(amount: number): void;
  112215. private _pentagonBokehIsEnabled;
  112216. /**
  112217. * Creates a pentagon bokeh effect
  112218. */
  112219. enablePentagonBokeh(): void;
  112220. /**
  112221. * Disables the pentagon bokeh effect
  112222. */
  112223. disablePentagonBokeh(): void;
  112224. /**
  112225. * Enables noise blur
  112226. */
  112227. enableNoiseBlur(): void;
  112228. /**
  112229. * Disables noise blur
  112230. */
  112231. disableNoiseBlur(): void;
  112232. /**
  112233. * Sets the HighlightsGain amount
  112234. * @param amount amount of HighlightsGain
  112235. */
  112236. setHighlightsGain(amount: number): void;
  112237. /**
  112238. * Sets the HighlightsThreshold amount
  112239. * @param amount amount of HighlightsThreshold
  112240. */
  112241. setHighlightsThreshold(amount: number): void;
  112242. /**
  112243. * Disables highlights
  112244. */
  112245. disableHighlights(): void;
  112246. /**
  112247. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  112248. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  112249. */
  112250. dispose(disableDepthRender?: boolean): void;
  112251. private _createChromaticAberrationPostProcess;
  112252. private _createHighlightsPostProcess;
  112253. private _createDepthOfFieldPostProcess;
  112254. private _createGrainTexture;
  112255. }
  112256. }
  112257. declare module BABYLON {
  112258. /** @hidden */
  112259. export var ssao2PixelShader: {
  112260. name: string;
  112261. shader: string;
  112262. };
  112263. }
  112264. declare module BABYLON {
  112265. /** @hidden */
  112266. export var ssaoCombinePixelShader: {
  112267. name: string;
  112268. shader: string;
  112269. };
  112270. }
  112271. declare module BABYLON {
  112272. /**
  112273. * Render pipeline to produce ssao effect
  112274. */
  112275. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  112276. /**
  112277. * @ignore
  112278. * The PassPostProcess id in the pipeline that contains the original scene color
  112279. */
  112280. SSAOOriginalSceneColorEffect: string;
  112281. /**
  112282. * @ignore
  112283. * The SSAO PostProcess id in the pipeline
  112284. */
  112285. SSAORenderEffect: string;
  112286. /**
  112287. * @ignore
  112288. * The horizontal blur PostProcess id in the pipeline
  112289. */
  112290. SSAOBlurHRenderEffect: string;
  112291. /**
  112292. * @ignore
  112293. * The vertical blur PostProcess id in the pipeline
  112294. */
  112295. SSAOBlurVRenderEffect: string;
  112296. /**
  112297. * @ignore
  112298. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112299. */
  112300. SSAOCombineRenderEffect: string;
  112301. /**
  112302. * The output strength of the SSAO post-process. Default value is 1.0.
  112303. */
  112304. totalStrength: number;
  112305. /**
  112306. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  112307. */
  112308. maxZ: number;
  112309. /**
  112310. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  112311. */
  112312. minZAspect: number;
  112313. private _samples;
  112314. /**
  112315. * Number of samples used for the SSAO calculations. Default value is 8
  112316. */
  112317. samples: number;
  112318. private _textureSamples;
  112319. /**
  112320. * Number of samples to use for antialiasing
  112321. */
  112322. textureSamples: number;
  112323. /**
  112324. * Ratio object used for SSAO ratio and blur ratio
  112325. */
  112326. private _ratio;
  112327. /**
  112328. * Dynamically generated sphere sampler.
  112329. */
  112330. private _sampleSphere;
  112331. /**
  112332. * Blur filter offsets
  112333. */
  112334. private _samplerOffsets;
  112335. private _expensiveBlur;
  112336. /**
  112337. * If bilateral blur should be used
  112338. */
  112339. expensiveBlur: boolean;
  112340. /**
  112341. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  112342. */
  112343. radius: number;
  112344. /**
  112345. * The base color of the SSAO post-process
  112346. * The final result is "base + ssao" between [0, 1]
  112347. */
  112348. base: number;
  112349. /**
  112350. * Support test.
  112351. */
  112352. static readonly IsSupported: boolean;
  112353. private _scene;
  112354. private _depthTexture;
  112355. private _normalTexture;
  112356. private _randomTexture;
  112357. private _originalColorPostProcess;
  112358. private _ssaoPostProcess;
  112359. private _blurHPostProcess;
  112360. private _blurVPostProcess;
  112361. private _ssaoCombinePostProcess;
  112362. private _firstUpdate;
  112363. /**
  112364. * Gets active scene
  112365. */
  112366. readonly scene: Scene;
  112367. /**
  112368. * @constructor
  112369. * @param name The rendering pipeline name
  112370. * @param scene The scene linked to this pipeline
  112371. * @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 }
  112372. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112373. */
  112374. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  112375. /**
  112376. * Get the class name
  112377. * @returns "SSAO2RenderingPipeline"
  112378. */
  112379. getClassName(): string;
  112380. /**
  112381. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  112382. */
  112383. dispose(disableGeometryBufferRenderer?: boolean): void;
  112384. private _createBlurPostProcess;
  112385. /** @hidden */
  112386. _rebuild(): void;
  112387. private _bits;
  112388. private _radicalInverse_VdC;
  112389. private _hammersley;
  112390. private _hemisphereSample_uniform;
  112391. private _generateHemisphere;
  112392. private _createSSAOPostProcess;
  112393. private _createSSAOCombinePostProcess;
  112394. private _createRandomTexture;
  112395. /**
  112396. * Serialize the rendering pipeline (Used when exporting)
  112397. * @returns the serialized object
  112398. */
  112399. serialize(): any;
  112400. /**
  112401. * Parse the serialized pipeline
  112402. * @param source Source pipeline.
  112403. * @param scene The scene to load the pipeline to.
  112404. * @param rootUrl The URL of the serialized pipeline.
  112405. * @returns An instantiated pipeline from the serialized object.
  112406. */
  112407. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  112408. }
  112409. }
  112410. declare module BABYLON {
  112411. /** @hidden */
  112412. export var ssaoPixelShader: {
  112413. name: string;
  112414. shader: string;
  112415. };
  112416. }
  112417. declare module BABYLON {
  112418. /**
  112419. * Render pipeline to produce ssao effect
  112420. */
  112421. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  112422. /**
  112423. * @ignore
  112424. * The PassPostProcess id in the pipeline that contains the original scene color
  112425. */
  112426. SSAOOriginalSceneColorEffect: string;
  112427. /**
  112428. * @ignore
  112429. * The SSAO PostProcess id in the pipeline
  112430. */
  112431. SSAORenderEffect: string;
  112432. /**
  112433. * @ignore
  112434. * The horizontal blur PostProcess id in the pipeline
  112435. */
  112436. SSAOBlurHRenderEffect: string;
  112437. /**
  112438. * @ignore
  112439. * The vertical blur PostProcess id in the pipeline
  112440. */
  112441. SSAOBlurVRenderEffect: string;
  112442. /**
  112443. * @ignore
  112444. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112445. */
  112446. SSAOCombineRenderEffect: string;
  112447. /**
  112448. * The output strength of the SSAO post-process. Default value is 1.0.
  112449. */
  112450. totalStrength: number;
  112451. /**
  112452. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  112453. */
  112454. radius: number;
  112455. /**
  112456. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  112457. * Must not be equal to fallOff and superior to fallOff.
  112458. * Default value is 0.0075
  112459. */
  112460. area: number;
  112461. /**
  112462. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  112463. * Must not be equal to area and inferior to area.
  112464. * Default value is 0.000001
  112465. */
  112466. fallOff: number;
  112467. /**
  112468. * The base color of the SSAO post-process
  112469. * The final result is "base + ssao" between [0, 1]
  112470. */
  112471. base: number;
  112472. private _scene;
  112473. private _depthTexture;
  112474. private _randomTexture;
  112475. private _originalColorPostProcess;
  112476. private _ssaoPostProcess;
  112477. private _blurHPostProcess;
  112478. private _blurVPostProcess;
  112479. private _ssaoCombinePostProcess;
  112480. private _firstUpdate;
  112481. /**
  112482. * Gets active scene
  112483. */
  112484. readonly scene: Scene;
  112485. /**
  112486. * @constructor
  112487. * @param name - The rendering pipeline name
  112488. * @param scene - The scene linked to this pipeline
  112489. * @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 }
  112490. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  112491. */
  112492. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  112493. /**
  112494. * Get the class name
  112495. * @returns "SSAORenderingPipeline"
  112496. */
  112497. getClassName(): string;
  112498. /**
  112499. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  112500. */
  112501. dispose(disableDepthRender?: boolean): void;
  112502. private _createBlurPostProcess;
  112503. /** @hidden */
  112504. _rebuild(): void;
  112505. private _createSSAOPostProcess;
  112506. private _createSSAOCombinePostProcess;
  112507. private _createRandomTexture;
  112508. }
  112509. }
  112510. declare module BABYLON {
  112511. /** @hidden */
  112512. export var standardPixelShader: {
  112513. name: string;
  112514. shader: string;
  112515. };
  112516. }
  112517. declare module BABYLON {
  112518. /**
  112519. * Standard rendering pipeline
  112520. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  112521. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  112522. */
  112523. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  112524. /**
  112525. * Public members
  112526. */
  112527. /**
  112528. * Post-process which contains the original scene color before the pipeline applies all the effects
  112529. */
  112530. originalPostProcess: Nullable<PostProcess>;
  112531. /**
  112532. * Post-process used to down scale an image x4
  112533. */
  112534. downSampleX4PostProcess: Nullable<PostProcess>;
  112535. /**
  112536. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  112537. */
  112538. brightPassPostProcess: Nullable<PostProcess>;
  112539. /**
  112540. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  112541. */
  112542. blurHPostProcesses: PostProcess[];
  112543. /**
  112544. * Post-process array storing all the vertical blur post-processes used by the pipeline
  112545. */
  112546. blurVPostProcesses: PostProcess[];
  112547. /**
  112548. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  112549. */
  112550. textureAdderPostProcess: Nullable<PostProcess>;
  112551. /**
  112552. * Post-process used to create volumetric lighting effect
  112553. */
  112554. volumetricLightPostProcess: Nullable<PostProcess>;
  112555. /**
  112556. * Post-process used to smooth the previous volumetric light post-process on the X axis
  112557. */
  112558. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  112559. /**
  112560. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  112561. */
  112562. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  112563. /**
  112564. * Post-process used to merge the volumetric light effect and the real scene color
  112565. */
  112566. volumetricLightMergePostProces: Nullable<PostProcess>;
  112567. /**
  112568. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  112569. */
  112570. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  112571. /**
  112572. * Base post-process used to calculate the average luminance of the final image for HDR
  112573. */
  112574. luminancePostProcess: Nullable<PostProcess>;
  112575. /**
  112576. * Post-processes used to create down sample post-processes in order to get
  112577. * the average luminance of the final image for HDR
  112578. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  112579. */
  112580. luminanceDownSamplePostProcesses: PostProcess[];
  112581. /**
  112582. * Post-process used to create a HDR effect (light adaptation)
  112583. */
  112584. hdrPostProcess: Nullable<PostProcess>;
  112585. /**
  112586. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  112587. */
  112588. textureAdderFinalPostProcess: Nullable<PostProcess>;
  112589. /**
  112590. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  112591. */
  112592. lensFlareFinalPostProcess: Nullable<PostProcess>;
  112593. /**
  112594. * Post-process used to merge the final HDR post-process and the real scene color
  112595. */
  112596. hdrFinalPostProcess: Nullable<PostProcess>;
  112597. /**
  112598. * Post-process used to create a lens flare effect
  112599. */
  112600. lensFlarePostProcess: Nullable<PostProcess>;
  112601. /**
  112602. * Post-process that merges the result of the lens flare post-process and the real scene color
  112603. */
  112604. lensFlareComposePostProcess: Nullable<PostProcess>;
  112605. /**
  112606. * Post-process used to create a motion blur effect
  112607. */
  112608. motionBlurPostProcess: Nullable<PostProcess>;
  112609. /**
  112610. * Post-process used to create a depth of field effect
  112611. */
  112612. depthOfFieldPostProcess: Nullable<PostProcess>;
  112613. /**
  112614. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  112615. */
  112616. fxaaPostProcess: Nullable<FxaaPostProcess>;
  112617. /**
  112618. * Represents the brightness threshold in order to configure the illuminated surfaces
  112619. */
  112620. brightThreshold: number;
  112621. /**
  112622. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  112623. */
  112624. blurWidth: number;
  112625. /**
  112626. * Sets if the blur for highlighted surfaces must be only horizontal
  112627. */
  112628. horizontalBlur: boolean;
  112629. /**
  112630. * Sets the overall exposure used by the pipeline
  112631. */
  112632. exposure: number;
  112633. /**
  112634. * Texture used typically to simulate "dirty" on camera lens
  112635. */
  112636. lensTexture: Nullable<Texture>;
  112637. /**
  112638. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  112639. */
  112640. volumetricLightCoefficient: number;
  112641. /**
  112642. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  112643. */
  112644. volumetricLightPower: number;
  112645. /**
  112646. * Used the set the blur intensity to smooth the volumetric lights
  112647. */
  112648. volumetricLightBlurScale: number;
  112649. /**
  112650. * Light (spot or directional) used to generate the volumetric lights rays
  112651. * The source light must have a shadow generate so the pipeline can get its
  112652. * depth map
  112653. */
  112654. sourceLight: Nullable<SpotLight | DirectionalLight>;
  112655. /**
  112656. * For eye adaptation, represents the minimum luminance the eye can see
  112657. */
  112658. hdrMinimumLuminance: number;
  112659. /**
  112660. * For eye adaptation, represents the decrease luminance speed
  112661. */
  112662. hdrDecreaseRate: number;
  112663. /**
  112664. * For eye adaptation, represents the increase luminance speed
  112665. */
  112666. hdrIncreaseRate: number;
  112667. /**
  112668. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  112669. */
  112670. lensColorTexture: Nullable<Texture>;
  112671. /**
  112672. * The overall strengh for the lens flare effect
  112673. */
  112674. lensFlareStrength: number;
  112675. /**
  112676. * Dispersion coefficient for lens flare ghosts
  112677. */
  112678. lensFlareGhostDispersal: number;
  112679. /**
  112680. * Main lens flare halo width
  112681. */
  112682. lensFlareHaloWidth: number;
  112683. /**
  112684. * Based on the lens distortion effect, defines how much the lens flare result
  112685. * is distorted
  112686. */
  112687. lensFlareDistortionStrength: number;
  112688. /**
  112689. * Lens star texture must be used to simulate rays on the flares and is available
  112690. * in the documentation
  112691. */
  112692. lensStarTexture: Nullable<Texture>;
  112693. /**
  112694. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  112695. * flare effect by taking account of the dirt texture
  112696. */
  112697. lensFlareDirtTexture: Nullable<Texture>;
  112698. /**
  112699. * Represents the focal length for the depth of field effect
  112700. */
  112701. depthOfFieldDistance: number;
  112702. /**
  112703. * Represents the blur intensity for the blurred part of the depth of field effect
  112704. */
  112705. depthOfFieldBlurWidth: number;
  112706. /**
  112707. * For motion blur, defines how much the image is blurred by the movement
  112708. */
  112709. motionStrength: number;
  112710. /**
  112711. * List of animations for the pipeline (IAnimatable implementation)
  112712. */
  112713. animations: Animation[];
  112714. /**
  112715. * Private members
  112716. */
  112717. private _scene;
  112718. private _currentDepthOfFieldSource;
  112719. private _basePostProcess;
  112720. private _hdrCurrentLuminance;
  112721. private _floatTextureType;
  112722. private _ratio;
  112723. private _bloomEnabled;
  112724. private _depthOfFieldEnabled;
  112725. private _vlsEnabled;
  112726. private _lensFlareEnabled;
  112727. private _hdrEnabled;
  112728. private _motionBlurEnabled;
  112729. private _fxaaEnabled;
  112730. private _motionBlurSamples;
  112731. private _volumetricLightStepsCount;
  112732. private _samples;
  112733. /**
  112734. * @ignore
  112735. * Specifies if the bloom pipeline is enabled
  112736. */
  112737. BloomEnabled: boolean;
  112738. /**
  112739. * @ignore
  112740. * Specifies if the depth of field pipeline is enabed
  112741. */
  112742. DepthOfFieldEnabled: boolean;
  112743. /**
  112744. * @ignore
  112745. * Specifies if the lens flare pipeline is enabed
  112746. */
  112747. LensFlareEnabled: boolean;
  112748. /**
  112749. * @ignore
  112750. * Specifies if the HDR pipeline is enabled
  112751. */
  112752. HDREnabled: boolean;
  112753. /**
  112754. * @ignore
  112755. * Specifies if the volumetric lights scattering effect is enabled
  112756. */
  112757. VLSEnabled: boolean;
  112758. /**
  112759. * @ignore
  112760. * Specifies if the motion blur effect is enabled
  112761. */
  112762. MotionBlurEnabled: boolean;
  112763. /**
  112764. * Specifies if anti-aliasing is enabled
  112765. */
  112766. fxaaEnabled: boolean;
  112767. /**
  112768. * Specifies the number of steps used to calculate the volumetric lights
  112769. * Typically in interval [50, 200]
  112770. */
  112771. volumetricLightStepsCount: number;
  112772. /**
  112773. * Specifies the number of samples used for the motion blur effect
  112774. * Typically in interval [16, 64]
  112775. */
  112776. motionBlurSamples: number;
  112777. /**
  112778. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112779. */
  112780. samples: number;
  112781. /**
  112782. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  112783. * @constructor
  112784. * @param name The rendering pipeline name
  112785. * @param scene The scene linked to this pipeline
  112786. * @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)
  112787. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  112788. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112789. */
  112790. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  112791. private _buildPipeline;
  112792. private _createDownSampleX4PostProcess;
  112793. private _createBrightPassPostProcess;
  112794. private _createBlurPostProcesses;
  112795. private _createTextureAdderPostProcess;
  112796. private _createVolumetricLightPostProcess;
  112797. private _createLuminancePostProcesses;
  112798. private _createHdrPostProcess;
  112799. private _createLensFlarePostProcess;
  112800. private _createDepthOfFieldPostProcess;
  112801. private _createMotionBlurPostProcess;
  112802. private _getDepthTexture;
  112803. private _disposePostProcesses;
  112804. /**
  112805. * Dispose of the pipeline and stop all post processes
  112806. */
  112807. dispose(): void;
  112808. /**
  112809. * Serialize the rendering pipeline (Used when exporting)
  112810. * @returns the serialized object
  112811. */
  112812. serialize(): any;
  112813. /**
  112814. * Parse the serialized pipeline
  112815. * @param source Source pipeline.
  112816. * @param scene The scene to load the pipeline to.
  112817. * @param rootUrl The URL of the serialized pipeline.
  112818. * @returns An instantiated pipeline from the serialized object.
  112819. */
  112820. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  112821. /**
  112822. * Luminance steps
  112823. */
  112824. static LuminanceSteps: number;
  112825. }
  112826. }
  112827. declare module BABYLON {
  112828. /** @hidden */
  112829. export var tonemapPixelShader: {
  112830. name: string;
  112831. shader: string;
  112832. };
  112833. }
  112834. declare module BABYLON {
  112835. /** Defines operator used for tonemapping */
  112836. export enum TonemappingOperator {
  112837. /** Hable */
  112838. Hable = 0,
  112839. /** Reinhard */
  112840. Reinhard = 1,
  112841. /** HejiDawson */
  112842. HejiDawson = 2,
  112843. /** Photographic */
  112844. Photographic = 3
  112845. }
  112846. /**
  112847. * Defines a post process to apply tone mapping
  112848. */
  112849. export class TonemapPostProcess extends PostProcess {
  112850. private _operator;
  112851. /** Defines the required exposure adjustement */
  112852. exposureAdjustment: number;
  112853. /**
  112854. * Creates a new TonemapPostProcess
  112855. * @param name defines the name of the postprocess
  112856. * @param _operator defines the operator to use
  112857. * @param exposureAdjustment defines the required exposure adjustement
  112858. * @param camera defines the camera to use (can be null)
  112859. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  112860. * @param engine defines the hosting engine (can be ignore if camera is set)
  112861. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  112862. */
  112863. constructor(name: string, _operator: TonemappingOperator,
  112864. /** Defines the required exposure adjustement */
  112865. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  112866. }
  112867. }
  112868. declare module BABYLON {
  112869. /** @hidden */
  112870. export var depthVertexShader: {
  112871. name: string;
  112872. shader: string;
  112873. };
  112874. }
  112875. declare module BABYLON {
  112876. /** @hidden */
  112877. export var volumetricLightScatteringPixelShader: {
  112878. name: string;
  112879. shader: string;
  112880. };
  112881. }
  112882. declare module BABYLON {
  112883. /** @hidden */
  112884. export var volumetricLightScatteringPassPixelShader: {
  112885. name: string;
  112886. shader: string;
  112887. };
  112888. }
  112889. declare module BABYLON {
  112890. /**
  112891. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  112892. */
  112893. export class VolumetricLightScatteringPostProcess extends PostProcess {
  112894. private _volumetricLightScatteringPass;
  112895. private _volumetricLightScatteringRTT;
  112896. private _viewPort;
  112897. private _screenCoordinates;
  112898. private _cachedDefines;
  112899. /**
  112900. * If not undefined, the mesh position is computed from the attached node position
  112901. */
  112902. attachedNode: {
  112903. position: Vector3;
  112904. };
  112905. /**
  112906. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  112907. */
  112908. customMeshPosition: Vector3;
  112909. /**
  112910. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  112911. */
  112912. useCustomMeshPosition: boolean;
  112913. /**
  112914. * If the post-process should inverse the light scattering direction
  112915. */
  112916. invert: boolean;
  112917. /**
  112918. * The internal mesh used by the post-process
  112919. */
  112920. mesh: Mesh;
  112921. /**
  112922. * @hidden
  112923. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  112924. */
  112925. useDiffuseColor: boolean;
  112926. /**
  112927. * Array containing the excluded meshes not rendered in the internal pass
  112928. */
  112929. excludedMeshes: AbstractMesh[];
  112930. /**
  112931. * Controls the overall intensity of the post-process
  112932. */
  112933. exposure: number;
  112934. /**
  112935. * Dissipates each sample's contribution in range [0, 1]
  112936. */
  112937. decay: number;
  112938. /**
  112939. * Controls the overall intensity of each sample
  112940. */
  112941. weight: number;
  112942. /**
  112943. * Controls the density of each sample
  112944. */
  112945. density: number;
  112946. /**
  112947. * @constructor
  112948. * @param name The post-process name
  112949. * @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)
  112950. * @param camera The camera that the post-process will be attached to
  112951. * @param mesh The mesh used to create the light scattering
  112952. * @param samples The post-process quality, default 100
  112953. * @param samplingModeThe post-process filtering mode
  112954. * @param engine The babylon engine
  112955. * @param reusable If the post-process is reusable
  112956. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  112957. */
  112958. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  112959. /**
  112960. * Returns the string "VolumetricLightScatteringPostProcess"
  112961. * @returns "VolumetricLightScatteringPostProcess"
  112962. */
  112963. getClassName(): string;
  112964. private _isReady;
  112965. /**
  112966. * Sets the new light position for light scattering effect
  112967. * @param position The new custom light position
  112968. */
  112969. setCustomMeshPosition(position: Vector3): void;
  112970. /**
  112971. * Returns the light position for light scattering effect
  112972. * @return Vector3 The custom light position
  112973. */
  112974. getCustomMeshPosition(): Vector3;
  112975. /**
  112976. * Disposes the internal assets and detaches the post-process from the camera
  112977. */
  112978. dispose(camera: Camera): void;
  112979. /**
  112980. * Returns the render target texture used by the post-process
  112981. * @return the render target texture used by the post-process
  112982. */
  112983. getPass(): RenderTargetTexture;
  112984. private _meshExcluded;
  112985. private _createPass;
  112986. private _updateMeshScreenCoordinates;
  112987. /**
  112988. * Creates a default mesh for the Volumeric Light Scattering post-process
  112989. * @param name The mesh name
  112990. * @param scene The scene where to create the mesh
  112991. * @return the default mesh
  112992. */
  112993. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  112994. }
  112995. }
  112996. declare module BABYLON {
  112997. interface Scene {
  112998. /** @hidden (Backing field) */
  112999. _boundingBoxRenderer: BoundingBoxRenderer;
  113000. /** @hidden (Backing field) */
  113001. _forceShowBoundingBoxes: boolean;
  113002. /**
  113003. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  113004. */
  113005. forceShowBoundingBoxes: boolean;
  113006. /**
  113007. * Gets the bounding box renderer associated with the scene
  113008. * @returns a BoundingBoxRenderer
  113009. */
  113010. getBoundingBoxRenderer(): BoundingBoxRenderer;
  113011. }
  113012. interface AbstractMesh {
  113013. /** @hidden (Backing field) */
  113014. _showBoundingBox: boolean;
  113015. /**
  113016. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  113017. */
  113018. showBoundingBox: boolean;
  113019. }
  113020. /**
  113021. * Component responsible of rendering the bounding box of the meshes in a scene.
  113022. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  113023. */
  113024. export class BoundingBoxRenderer implements ISceneComponent {
  113025. /**
  113026. * The component name helpfull to identify the component in the list of scene components.
  113027. */
  113028. readonly name: string;
  113029. /**
  113030. * The scene the component belongs to.
  113031. */
  113032. scene: Scene;
  113033. /**
  113034. * Color of the bounding box lines placed in front of an object
  113035. */
  113036. frontColor: Color3;
  113037. /**
  113038. * Color of the bounding box lines placed behind an object
  113039. */
  113040. backColor: Color3;
  113041. /**
  113042. * Defines if the renderer should show the back lines or not
  113043. */
  113044. showBackLines: boolean;
  113045. /**
  113046. * @hidden
  113047. */
  113048. renderList: SmartArray<BoundingBox>;
  113049. private _colorShader;
  113050. private _vertexBuffers;
  113051. private _indexBuffer;
  113052. /**
  113053. * Instantiates a new bounding box renderer in a scene.
  113054. * @param scene the scene the renderer renders in
  113055. */
  113056. constructor(scene: Scene);
  113057. /**
  113058. * Registers the component in a given scene
  113059. */
  113060. register(): void;
  113061. private _evaluateSubMesh;
  113062. private _activeMesh;
  113063. private _prepareRessources;
  113064. private _createIndexBuffer;
  113065. /**
  113066. * Rebuilds the elements related to this component in case of
  113067. * context lost for instance.
  113068. */
  113069. rebuild(): void;
  113070. /**
  113071. * @hidden
  113072. */
  113073. reset(): void;
  113074. /**
  113075. * Render the bounding boxes of a specific rendering group
  113076. * @param renderingGroupId defines the rendering group to render
  113077. */
  113078. render(renderingGroupId: number): void;
  113079. /**
  113080. * In case of occlusion queries, we can render the occlusion bounding box through this method
  113081. * @param mesh Define the mesh to render the occlusion bounding box for
  113082. */
  113083. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  113084. /**
  113085. * Dispose and release the resources attached to this renderer.
  113086. */
  113087. dispose(): void;
  113088. }
  113089. }
  113090. declare module BABYLON {
  113091. /** @hidden */
  113092. export var depthPixelShader: {
  113093. name: string;
  113094. shader: string;
  113095. };
  113096. }
  113097. declare module BABYLON {
  113098. /**
  113099. * This represents a depth renderer in Babylon.
  113100. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  113101. */
  113102. export class DepthRenderer {
  113103. private _scene;
  113104. private _depthMap;
  113105. private _effect;
  113106. private _cachedDefines;
  113107. private _camera;
  113108. /**
  113109. * Specifiess that the depth renderer will only be used within
  113110. * the camera it is created for.
  113111. * This can help forcing its rendering during the camera processing.
  113112. */
  113113. useOnlyInActiveCamera: boolean;
  113114. /** @hidden */
  113115. static _SceneComponentInitialization: (scene: Scene) => void;
  113116. /**
  113117. * Instantiates a depth renderer
  113118. * @param scene The scene the renderer belongs to
  113119. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  113120. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  113121. */
  113122. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  113123. /**
  113124. * Creates the depth rendering effect and checks if the effect is ready.
  113125. * @param subMesh The submesh to be used to render the depth map of
  113126. * @param useInstances If multiple world instances should be used
  113127. * @returns if the depth renderer is ready to render the depth map
  113128. */
  113129. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113130. /**
  113131. * Gets the texture which the depth map will be written to.
  113132. * @returns The depth map texture
  113133. */
  113134. getDepthMap(): RenderTargetTexture;
  113135. /**
  113136. * Disposes of the depth renderer.
  113137. */
  113138. dispose(): void;
  113139. }
  113140. }
  113141. declare module BABYLON {
  113142. interface Scene {
  113143. /** @hidden (Backing field) */
  113144. _depthRenderer: {
  113145. [id: string]: DepthRenderer;
  113146. };
  113147. /**
  113148. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  113149. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  113150. * @returns the created depth renderer
  113151. */
  113152. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  113153. /**
  113154. * Disables a depth renderer for a given camera
  113155. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  113156. */
  113157. disableDepthRenderer(camera?: Nullable<Camera>): void;
  113158. }
  113159. /**
  113160. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  113161. * in several rendering techniques.
  113162. */
  113163. export class DepthRendererSceneComponent implements ISceneComponent {
  113164. /**
  113165. * The component name helpfull to identify the component in the list of scene components.
  113166. */
  113167. readonly name: string;
  113168. /**
  113169. * The scene the component belongs to.
  113170. */
  113171. scene: Scene;
  113172. /**
  113173. * Creates a new instance of the component for the given scene
  113174. * @param scene Defines the scene to register the component in
  113175. */
  113176. constructor(scene: Scene);
  113177. /**
  113178. * Registers the component in a given scene
  113179. */
  113180. register(): void;
  113181. /**
  113182. * Rebuilds the elements related to this component in case of
  113183. * context lost for instance.
  113184. */
  113185. rebuild(): void;
  113186. /**
  113187. * Disposes the component and the associated ressources
  113188. */
  113189. dispose(): void;
  113190. private _gatherRenderTargets;
  113191. private _gatherActiveCameraRenderTargets;
  113192. }
  113193. }
  113194. declare module BABYLON {
  113195. /** @hidden */
  113196. export var outlinePixelShader: {
  113197. name: string;
  113198. shader: string;
  113199. };
  113200. }
  113201. declare module BABYLON {
  113202. /** @hidden */
  113203. export var outlineVertexShader: {
  113204. name: string;
  113205. shader: string;
  113206. };
  113207. }
  113208. declare module BABYLON {
  113209. interface Scene {
  113210. /** @hidden */
  113211. _outlineRenderer: OutlineRenderer;
  113212. /**
  113213. * Gets the outline renderer associated with the scene
  113214. * @returns a OutlineRenderer
  113215. */
  113216. getOutlineRenderer(): OutlineRenderer;
  113217. }
  113218. interface AbstractMesh {
  113219. /** @hidden (Backing field) */
  113220. _renderOutline: boolean;
  113221. /**
  113222. * Gets or sets a boolean indicating if the outline must be rendered as well
  113223. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  113224. */
  113225. renderOutline: boolean;
  113226. /** @hidden (Backing field) */
  113227. _renderOverlay: boolean;
  113228. /**
  113229. * Gets or sets a boolean indicating if the overlay must be rendered as well
  113230. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  113231. */
  113232. renderOverlay: boolean;
  113233. }
  113234. /**
  113235. * This class is responsible to draw bothe outline/overlay of meshes.
  113236. * It should not be used directly but through the available method on mesh.
  113237. */
  113238. export class OutlineRenderer implements ISceneComponent {
  113239. /**
  113240. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  113241. */
  113242. private static _StencilReference;
  113243. /**
  113244. * The name of the component. Each component must have a unique name.
  113245. */
  113246. name: string;
  113247. /**
  113248. * The scene the component belongs to.
  113249. */
  113250. scene: Scene;
  113251. /**
  113252. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  113253. */
  113254. zOffset: number;
  113255. private _engine;
  113256. private _effect;
  113257. private _cachedDefines;
  113258. private _savedDepthWrite;
  113259. /**
  113260. * Instantiates a new outline renderer. (There could be only one per scene).
  113261. * @param scene Defines the scene it belongs to
  113262. */
  113263. constructor(scene: Scene);
  113264. /**
  113265. * Register the component to one instance of a scene.
  113266. */
  113267. register(): void;
  113268. /**
  113269. * Rebuilds the elements related to this component in case of
  113270. * context lost for instance.
  113271. */
  113272. rebuild(): void;
  113273. /**
  113274. * Disposes the component and the associated ressources.
  113275. */
  113276. dispose(): void;
  113277. /**
  113278. * Renders the outline in the canvas.
  113279. * @param subMesh Defines the sumesh to render
  113280. * @param batch Defines the batch of meshes in case of instances
  113281. * @param useOverlay Defines if the rendering is for the overlay or the outline
  113282. */
  113283. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  113284. /**
  113285. * Returns whether or not the outline renderer is ready for a given submesh.
  113286. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  113287. * @param subMesh Defines the submesh to check readyness for
  113288. * @param useInstances Defines wheter wee are trying to render instances or not
  113289. * @returns true if ready otherwise false
  113290. */
  113291. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113292. private _beforeRenderingMesh;
  113293. private _afterRenderingMesh;
  113294. }
  113295. }
  113296. declare module BABYLON {
  113297. /**
  113298. * Defines the list of states available for a task inside a AssetsManager
  113299. */
  113300. export enum AssetTaskState {
  113301. /**
  113302. * Initialization
  113303. */
  113304. INIT = 0,
  113305. /**
  113306. * Running
  113307. */
  113308. RUNNING = 1,
  113309. /**
  113310. * Done
  113311. */
  113312. DONE = 2,
  113313. /**
  113314. * Error
  113315. */
  113316. ERROR = 3
  113317. }
  113318. /**
  113319. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  113320. */
  113321. export abstract class AbstractAssetTask {
  113322. /**
  113323. * Task name
  113324. */ name: string;
  113325. /**
  113326. * Callback called when the task is successful
  113327. */
  113328. onSuccess: (task: any) => void;
  113329. /**
  113330. * Callback called when the task is not successful
  113331. */
  113332. onError: (task: any, message?: string, exception?: any) => void;
  113333. /**
  113334. * Creates a new AssetsManager
  113335. * @param name defines the name of the task
  113336. */
  113337. constructor(
  113338. /**
  113339. * Task name
  113340. */ name: string);
  113341. private _isCompleted;
  113342. private _taskState;
  113343. private _errorObject;
  113344. /**
  113345. * Get if the task is completed
  113346. */
  113347. readonly isCompleted: boolean;
  113348. /**
  113349. * Gets the current state of the task
  113350. */
  113351. readonly taskState: AssetTaskState;
  113352. /**
  113353. * Gets the current error object (if task is in error)
  113354. */
  113355. readonly errorObject: {
  113356. message?: string;
  113357. exception?: any;
  113358. };
  113359. /**
  113360. * Internal only
  113361. * @hidden
  113362. */
  113363. _setErrorObject(message?: string, exception?: any): void;
  113364. /**
  113365. * Execute the current task
  113366. * @param scene defines the scene where you want your assets to be loaded
  113367. * @param onSuccess is a callback called when the task is successfully executed
  113368. * @param onError is a callback called if an error occurs
  113369. */
  113370. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113371. /**
  113372. * Execute the current task
  113373. * @param scene defines the scene where you want your assets to be loaded
  113374. * @param onSuccess is a callback called when the task is successfully executed
  113375. * @param onError is a callback called if an error occurs
  113376. */
  113377. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113378. /**
  113379. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  113380. * This can be used with failed tasks that have the reason for failure fixed.
  113381. */
  113382. reset(): void;
  113383. private onErrorCallback;
  113384. private onDoneCallback;
  113385. }
  113386. /**
  113387. * Define the interface used by progress events raised during assets loading
  113388. */
  113389. export interface IAssetsProgressEvent {
  113390. /**
  113391. * Defines the number of remaining tasks to process
  113392. */
  113393. remainingCount: number;
  113394. /**
  113395. * Defines the total number of tasks
  113396. */
  113397. totalCount: number;
  113398. /**
  113399. * Defines the task that was just processed
  113400. */
  113401. task: AbstractAssetTask;
  113402. }
  113403. /**
  113404. * Class used to share progress information about assets loading
  113405. */
  113406. export class AssetsProgressEvent implements IAssetsProgressEvent {
  113407. /**
  113408. * Defines the number of remaining tasks to process
  113409. */
  113410. remainingCount: number;
  113411. /**
  113412. * Defines the total number of tasks
  113413. */
  113414. totalCount: number;
  113415. /**
  113416. * Defines the task that was just processed
  113417. */
  113418. task: AbstractAssetTask;
  113419. /**
  113420. * Creates a AssetsProgressEvent
  113421. * @param remainingCount defines the number of remaining tasks to process
  113422. * @param totalCount defines the total number of tasks
  113423. * @param task defines the task that was just processed
  113424. */
  113425. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  113426. }
  113427. /**
  113428. * Define a task used by AssetsManager to load meshes
  113429. */
  113430. export class MeshAssetTask extends AbstractAssetTask {
  113431. /**
  113432. * Defines the name of the task
  113433. */
  113434. name: string;
  113435. /**
  113436. * Defines the list of mesh's names you want to load
  113437. */
  113438. meshesNames: any;
  113439. /**
  113440. * Defines the root url to use as a base to load your meshes and associated resources
  113441. */
  113442. rootUrl: string;
  113443. /**
  113444. * Defines the filename of the scene to load from
  113445. */
  113446. sceneFilename: string;
  113447. /**
  113448. * Gets the list of loaded meshes
  113449. */
  113450. loadedMeshes: Array<AbstractMesh>;
  113451. /**
  113452. * Gets the list of loaded particle systems
  113453. */
  113454. loadedParticleSystems: Array<IParticleSystem>;
  113455. /**
  113456. * Gets the list of loaded skeletons
  113457. */
  113458. loadedSkeletons: Array<Skeleton>;
  113459. /**
  113460. * Gets the list of loaded animation groups
  113461. */
  113462. loadedAnimationGroups: Array<AnimationGroup>;
  113463. /**
  113464. * Callback called when the task is successful
  113465. */
  113466. onSuccess: (task: MeshAssetTask) => void;
  113467. /**
  113468. * Callback called when the task is successful
  113469. */
  113470. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  113471. /**
  113472. * Creates a new MeshAssetTask
  113473. * @param name defines the name of the task
  113474. * @param meshesNames defines the list of mesh's names you want to load
  113475. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  113476. * @param sceneFilename defines the filename of the scene to load from
  113477. */
  113478. constructor(
  113479. /**
  113480. * Defines the name of the task
  113481. */
  113482. name: string,
  113483. /**
  113484. * Defines the list of mesh's names you want to load
  113485. */
  113486. meshesNames: any,
  113487. /**
  113488. * Defines the root url to use as a base to load your meshes and associated resources
  113489. */
  113490. rootUrl: string,
  113491. /**
  113492. * Defines the filename of the scene to load from
  113493. */
  113494. sceneFilename: string);
  113495. /**
  113496. * Execute the current task
  113497. * @param scene defines the scene where you want your assets to be loaded
  113498. * @param onSuccess is a callback called when the task is successfully executed
  113499. * @param onError is a callback called if an error occurs
  113500. */
  113501. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113502. }
  113503. /**
  113504. * Define a task used by AssetsManager to load text content
  113505. */
  113506. export class TextFileAssetTask extends AbstractAssetTask {
  113507. /**
  113508. * Defines the name of the task
  113509. */
  113510. name: string;
  113511. /**
  113512. * Defines the location of the file to load
  113513. */
  113514. url: string;
  113515. /**
  113516. * Gets the loaded text string
  113517. */
  113518. text: string;
  113519. /**
  113520. * Callback called when the task is successful
  113521. */
  113522. onSuccess: (task: TextFileAssetTask) => void;
  113523. /**
  113524. * Callback called when the task is successful
  113525. */
  113526. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  113527. /**
  113528. * Creates a new TextFileAssetTask object
  113529. * @param name defines the name of the task
  113530. * @param url defines the location of the file to load
  113531. */
  113532. constructor(
  113533. /**
  113534. * Defines the name of the task
  113535. */
  113536. name: string,
  113537. /**
  113538. * Defines the location of the file to load
  113539. */
  113540. url: string);
  113541. /**
  113542. * Execute the current task
  113543. * @param scene defines the scene where you want your assets to be loaded
  113544. * @param onSuccess is a callback called when the task is successfully executed
  113545. * @param onError is a callback called if an error occurs
  113546. */
  113547. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113548. }
  113549. /**
  113550. * Define a task used by AssetsManager to load binary data
  113551. */
  113552. export class BinaryFileAssetTask extends AbstractAssetTask {
  113553. /**
  113554. * Defines the name of the task
  113555. */
  113556. name: string;
  113557. /**
  113558. * Defines the location of the file to load
  113559. */
  113560. url: string;
  113561. /**
  113562. * Gets the lodaded data (as an array buffer)
  113563. */
  113564. data: ArrayBuffer;
  113565. /**
  113566. * Callback called when the task is successful
  113567. */
  113568. onSuccess: (task: BinaryFileAssetTask) => void;
  113569. /**
  113570. * Callback called when the task is successful
  113571. */
  113572. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  113573. /**
  113574. * Creates a new BinaryFileAssetTask object
  113575. * @param name defines the name of the new task
  113576. * @param url defines the location of the file to load
  113577. */
  113578. constructor(
  113579. /**
  113580. * Defines the name of the task
  113581. */
  113582. name: string,
  113583. /**
  113584. * Defines the location of the file to load
  113585. */
  113586. url: string);
  113587. /**
  113588. * Execute the current task
  113589. * @param scene defines the scene where you want your assets to be loaded
  113590. * @param onSuccess is a callback called when the task is successfully executed
  113591. * @param onError is a callback called if an error occurs
  113592. */
  113593. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113594. }
  113595. /**
  113596. * Define a task used by AssetsManager to load images
  113597. */
  113598. export class ImageAssetTask extends AbstractAssetTask {
  113599. /**
  113600. * Defines the name of the task
  113601. */
  113602. name: string;
  113603. /**
  113604. * Defines the location of the image to load
  113605. */
  113606. url: string;
  113607. /**
  113608. * Gets the loaded images
  113609. */
  113610. image: HTMLImageElement;
  113611. /**
  113612. * Callback called when the task is successful
  113613. */
  113614. onSuccess: (task: ImageAssetTask) => void;
  113615. /**
  113616. * Callback called when the task is successful
  113617. */
  113618. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  113619. /**
  113620. * Creates a new ImageAssetTask
  113621. * @param name defines the name of the task
  113622. * @param url defines the location of the image to load
  113623. */
  113624. constructor(
  113625. /**
  113626. * Defines the name of the task
  113627. */
  113628. name: string,
  113629. /**
  113630. * Defines the location of the image to load
  113631. */
  113632. url: string);
  113633. /**
  113634. * Execute the current task
  113635. * @param scene defines the scene where you want your assets to be loaded
  113636. * @param onSuccess is a callback called when the task is successfully executed
  113637. * @param onError is a callback called if an error occurs
  113638. */
  113639. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113640. }
  113641. /**
  113642. * Defines the interface used by texture loading tasks
  113643. */
  113644. export interface ITextureAssetTask<TEX extends BaseTexture> {
  113645. /**
  113646. * Gets the loaded texture
  113647. */
  113648. texture: TEX;
  113649. }
  113650. /**
  113651. * Define a task used by AssetsManager to load 2D textures
  113652. */
  113653. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  113654. /**
  113655. * Defines the name of the task
  113656. */
  113657. name: string;
  113658. /**
  113659. * Defines the location of the file to load
  113660. */
  113661. url: string;
  113662. /**
  113663. * Defines if mipmap should not be generated (default is false)
  113664. */
  113665. noMipmap?: boolean | undefined;
  113666. /**
  113667. * Defines if texture must be inverted on Y axis (default is false)
  113668. */
  113669. invertY?: boolean | undefined;
  113670. /**
  113671. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  113672. */
  113673. samplingMode: number;
  113674. /**
  113675. * Gets the loaded texture
  113676. */
  113677. texture: Texture;
  113678. /**
  113679. * Callback called when the task is successful
  113680. */
  113681. onSuccess: (task: TextureAssetTask) => void;
  113682. /**
  113683. * Callback called when the task is successful
  113684. */
  113685. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  113686. /**
  113687. * Creates a new TextureAssetTask object
  113688. * @param name defines the name of the task
  113689. * @param url defines the location of the file to load
  113690. * @param noMipmap defines if mipmap should not be generated (default is false)
  113691. * @param invertY defines if texture must be inverted on Y axis (default is false)
  113692. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  113693. */
  113694. constructor(
  113695. /**
  113696. * Defines the name of the task
  113697. */
  113698. name: string,
  113699. /**
  113700. * Defines the location of the file to load
  113701. */
  113702. url: string,
  113703. /**
  113704. * Defines if mipmap should not be generated (default is false)
  113705. */
  113706. noMipmap?: boolean | undefined,
  113707. /**
  113708. * Defines if texture must be inverted on Y axis (default is false)
  113709. */
  113710. invertY?: boolean | undefined,
  113711. /**
  113712. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  113713. */
  113714. samplingMode?: number);
  113715. /**
  113716. * Execute the current task
  113717. * @param scene defines the scene where you want your assets to be loaded
  113718. * @param onSuccess is a callback called when the task is successfully executed
  113719. * @param onError is a callback called if an error occurs
  113720. */
  113721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113722. }
  113723. /**
  113724. * Define a task used by AssetsManager to load cube textures
  113725. */
  113726. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  113727. /**
  113728. * Defines the name of the task
  113729. */
  113730. name: string;
  113731. /**
  113732. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  113733. */
  113734. url: string;
  113735. /**
  113736. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  113737. */
  113738. extensions?: string[] | undefined;
  113739. /**
  113740. * Defines if mipmaps should not be generated (default is false)
  113741. */
  113742. noMipmap?: boolean | undefined;
  113743. /**
  113744. * Defines the explicit list of files (undefined by default)
  113745. */
  113746. files?: string[] | undefined;
  113747. /**
  113748. * Gets the loaded texture
  113749. */
  113750. texture: CubeTexture;
  113751. /**
  113752. * Callback called when the task is successful
  113753. */
  113754. onSuccess: (task: CubeTextureAssetTask) => void;
  113755. /**
  113756. * Callback called when the task is successful
  113757. */
  113758. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  113759. /**
  113760. * Creates a new CubeTextureAssetTask
  113761. * @param name defines the name of the task
  113762. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  113763. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  113764. * @param noMipmap defines if mipmaps should not be generated (default is false)
  113765. * @param files defines the explicit list of files (undefined by default)
  113766. */
  113767. constructor(
  113768. /**
  113769. * Defines the name of the task
  113770. */
  113771. name: string,
  113772. /**
  113773. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  113774. */
  113775. url: string,
  113776. /**
  113777. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  113778. */
  113779. extensions?: string[] | undefined,
  113780. /**
  113781. * Defines if mipmaps should not be generated (default is false)
  113782. */
  113783. noMipmap?: boolean | undefined,
  113784. /**
  113785. * Defines the explicit list of files (undefined by default)
  113786. */
  113787. files?: string[] | undefined);
  113788. /**
  113789. * Execute the current task
  113790. * @param scene defines the scene where you want your assets to be loaded
  113791. * @param onSuccess is a callback called when the task is successfully executed
  113792. * @param onError is a callback called if an error occurs
  113793. */
  113794. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113795. }
  113796. /**
  113797. * Define a task used by AssetsManager to load HDR cube textures
  113798. */
  113799. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  113800. /**
  113801. * Defines the name of the task
  113802. */
  113803. name: string;
  113804. /**
  113805. * Defines the location of the file to load
  113806. */
  113807. url: string;
  113808. /**
  113809. * Defines the desired size (the more it increases the longer the generation will be)
  113810. */
  113811. size: number;
  113812. /**
  113813. * Defines if mipmaps should not be generated (default is false)
  113814. */
  113815. noMipmap: boolean;
  113816. /**
  113817. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113818. */
  113819. generateHarmonics: boolean;
  113820. /**
  113821. * 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)
  113822. */
  113823. gammaSpace: boolean;
  113824. /**
  113825. * Internal Use Only
  113826. */
  113827. reserved: boolean;
  113828. /**
  113829. * Gets the loaded texture
  113830. */
  113831. texture: HDRCubeTexture;
  113832. /**
  113833. * Callback called when the task is successful
  113834. */
  113835. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  113836. /**
  113837. * Callback called when the task is successful
  113838. */
  113839. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  113840. /**
  113841. * Creates a new HDRCubeTextureAssetTask object
  113842. * @param name defines the name of the task
  113843. * @param url defines the location of the file to load
  113844. * @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.
  113845. * @param noMipmap defines if mipmaps should not be generated (default is false)
  113846. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113847. * @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)
  113848. * @param reserved Internal use only
  113849. */
  113850. constructor(
  113851. /**
  113852. * Defines the name of the task
  113853. */
  113854. name: string,
  113855. /**
  113856. * Defines the location of the file to load
  113857. */
  113858. url: string,
  113859. /**
  113860. * Defines the desired size (the more it increases the longer the generation will be)
  113861. */
  113862. size: number,
  113863. /**
  113864. * Defines if mipmaps should not be generated (default is false)
  113865. */
  113866. noMipmap?: boolean,
  113867. /**
  113868. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113869. */
  113870. generateHarmonics?: boolean,
  113871. /**
  113872. * 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)
  113873. */
  113874. gammaSpace?: boolean,
  113875. /**
  113876. * Internal Use Only
  113877. */
  113878. reserved?: boolean);
  113879. /**
  113880. * Execute the current task
  113881. * @param scene defines the scene where you want your assets to be loaded
  113882. * @param onSuccess is a callback called when the task is successfully executed
  113883. * @param onError is a callback called if an error occurs
  113884. */
  113885. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113886. }
  113887. /**
  113888. * Define a task used by AssetsManager to load Equirectangular cube textures
  113889. */
  113890. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  113891. /**
  113892. * Defines the name of the task
  113893. */
  113894. name: string;
  113895. /**
  113896. * Defines the location of the file to load
  113897. */
  113898. url: string;
  113899. /**
  113900. * Defines the desired size (the more it increases the longer the generation will be)
  113901. */
  113902. size: number;
  113903. /**
  113904. * Defines if mipmaps should not be generated (default is false)
  113905. */
  113906. noMipmap: boolean;
  113907. /**
  113908. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  113909. * but the standard material would require them in Gamma space) (default is true)
  113910. */
  113911. gammaSpace: boolean;
  113912. /**
  113913. * Gets the loaded texture
  113914. */
  113915. texture: EquiRectangularCubeTexture;
  113916. /**
  113917. * Callback called when the task is successful
  113918. */
  113919. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  113920. /**
  113921. * Callback called when the task is successful
  113922. */
  113923. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  113924. /**
  113925. * Creates a new EquiRectangularCubeTextureAssetTask object
  113926. * @param name defines the name of the task
  113927. * @param url defines the location of the file to load
  113928. * @param size defines the desired size (the more it increases the longer the generation will be)
  113929. * If the size is omitted this implies you are using a preprocessed cubemap.
  113930. * @param noMipmap defines if mipmaps should not be generated (default is false)
  113931. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  113932. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  113933. * (default is true)
  113934. */
  113935. constructor(
  113936. /**
  113937. * Defines the name of the task
  113938. */
  113939. name: string,
  113940. /**
  113941. * Defines the location of the file to load
  113942. */
  113943. url: string,
  113944. /**
  113945. * Defines the desired size (the more it increases the longer the generation will be)
  113946. */
  113947. size: number,
  113948. /**
  113949. * Defines if mipmaps should not be generated (default is false)
  113950. */
  113951. noMipmap?: boolean,
  113952. /**
  113953. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  113954. * but the standard material would require them in Gamma space) (default is true)
  113955. */
  113956. gammaSpace?: boolean);
  113957. /**
  113958. * Execute the current task
  113959. * @param scene defines the scene where you want your assets to be loaded
  113960. * @param onSuccess is a callback called when the task is successfully executed
  113961. * @param onError is a callback called if an error occurs
  113962. */
  113963. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113964. }
  113965. /**
  113966. * This class can be used to easily import assets into a scene
  113967. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  113968. */
  113969. export class AssetsManager {
  113970. private _scene;
  113971. private _isLoading;
  113972. protected _tasks: AbstractAssetTask[];
  113973. protected _waitingTasksCount: number;
  113974. protected _totalTasksCount: number;
  113975. /**
  113976. * Callback called when all tasks are processed
  113977. */
  113978. onFinish: (tasks: AbstractAssetTask[]) => void;
  113979. /**
  113980. * Callback called when a task is successful
  113981. */
  113982. onTaskSuccess: (task: AbstractAssetTask) => void;
  113983. /**
  113984. * Callback called when a task had an error
  113985. */
  113986. onTaskError: (task: AbstractAssetTask) => void;
  113987. /**
  113988. * Callback called when a task is done (whatever the result is)
  113989. */
  113990. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  113991. /**
  113992. * Observable called when all tasks are processed
  113993. */
  113994. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  113995. /**
  113996. * Observable called when a task had an error
  113997. */
  113998. onTaskErrorObservable: Observable<AbstractAssetTask>;
  113999. /**
  114000. * Observable called when all tasks were executed
  114001. */
  114002. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  114003. /**
  114004. * Observable called when a task is done (whatever the result is)
  114005. */
  114006. onProgressObservable: Observable<IAssetsProgressEvent>;
  114007. /**
  114008. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  114009. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114010. */
  114011. useDefaultLoadingScreen: boolean;
  114012. /**
  114013. * Creates a new AssetsManager
  114014. * @param scene defines the scene to work on
  114015. */
  114016. constructor(scene: Scene);
  114017. /**
  114018. * Add a MeshAssetTask to the list of active tasks
  114019. * @param taskName defines the name of the new task
  114020. * @param meshesNames defines the name of meshes to load
  114021. * @param rootUrl defines the root url to use to locate files
  114022. * @param sceneFilename defines the filename of the scene file
  114023. * @returns a new MeshAssetTask object
  114024. */
  114025. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  114026. /**
  114027. * Add a TextFileAssetTask to the list of active tasks
  114028. * @param taskName defines the name of the new task
  114029. * @param url defines the url of the file to load
  114030. * @returns a new TextFileAssetTask object
  114031. */
  114032. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  114033. /**
  114034. * Add a BinaryFileAssetTask to the list of active tasks
  114035. * @param taskName defines the name of the new task
  114036. * @param url defines the url of the file to load
  114037. * @returns a new BinaryFileAssetTask object
  114038. */
  114039. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  114040. /**
  114041. * Add a ImageAssetTask to the list of active tasks
  114042. * @param taskName defines the name of the new task
  114043. * @param url defines the url of the file to load
  114044. * @returns a new ImageAssetTask object
  114045. */
  114046. addImageTask(taskName: string, url: string): ImageAssetTask;
  114047. /**
  114048. * Add a TextureAssetTask to the list of active tasks
  114049. * @param taskName defines the name of the new task
  114050. * @param url defines the url of the file to load
  114051. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114052. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  114053. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114054. * @returns a new TextureAssetTask object
  114055. */
  114056. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  114057. /**
  114058. * Add a CubeTextureAssetTask to the list of active tasks
  114059. * @param taskName defines the name of the new task
  114060. * @param url defines the url of the file to load
  114061. * @param extensions defines the extension to use to load the cube map (can be null)
  114062. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114063. * @param files defines the list of files to load (can be null)
  114064. * @returns a new CubeTextureAssetTask object
  114065. */
  114066. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  114067. /**
  114068. *
  114069. * Add a HDRCubeTextureAssetTask to the list of active tasks
  114070. * @param taskName defines the name of the new task
  114071. * @param url defines the url of the file to load
  114072. * @param size defines the size you want for the cubemap (can be null)
  114073. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114074. * @param generateHarmonics defines if you want to automatically generate (true by default)
  114075. * @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)
  114076. * @param reserved Internal use only
  114077. * @returns a new HDRCubeTextureAssetTask object
  114078. */
  114079. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  114080. /**
  114081. *
  114082. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  114083. * @param taskName defines the name of the new task
  114084. * @param url defines the url of the file to load
  114085. * @param size defines the size you want for the cubemap (can be null)
  114086. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114087. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114088. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114089. * @returns a new EquiRectangularCubeTextureAssetTask object
  114090. */
  114091. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  114092. /**
  114093. * Remove a task from the assets manager.
  114094. * @param task the task to remove
  114095. */
  114096. removeTask(task: AbstractAssetTask): void;
  114097. private _decreaseWaitingTasksCount;
  114098. private _runTask;
  114099. /**
  114100. * Reset the AssetsManager and remove all tasks
  114101. * @return the current instance of the AssetsManager
  114102. */
  114103. reset(): AssetsManager;
  114104. /**
  114105. * Start the loading process
  114106. * @return the current instance of the AssetsManager
  114107. */
  114108. load(): AssetsManager;
  114109. /**
  114110. * Start the loading process as an async operation
  114111. * @return a promise returning the list of failed tasks
  114112. */
  114113. loadAsync(): Promise<void>;
  114114. }
  114115. }
  114116. declare module BABYLON {
  114117. /**
  114118. * Wrapper class for promise with external resolve and reject.
  114119. */
  114120. export class Deferred<T> {
  114121. /**
  114122. * The promise associated with this deferred object.
  114123. */
  114124. readonly promise: Promise<T>;
  114125. private _resolve;
  114126. private _reject;
  114127. /**
  114128. * The resolve method of the promise associated with this deferred object.
  114129. */
  114130. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  114131. /**
  114132. * The reject method of the promise associated with this deferred object.
  114133. */
  114134. readonly reject: (reason?: any) => void;
  114135. /**
  114136. * Constructor for this deferred object.
  114137. */
  114138. constructor();
  114139. }
  114140. }
  114141. declare module BABYLON {
  114142. /**
  114143. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  114144. */
  114145. export class MeshExploder {
  114146. private _centerMesh;
  114147. private _meshes;
  114148. private _meshesOrigins;
  114149. private _toCenterVectors;
  114150. private _scaledDirection;
  114151. private _newPosition;
  114152. private _centerPosition;
  114153. /**
  114154. * Explodes meshes from a center mesh.
  114155. * @param meshes The meshes to explode.
  114156. * @param centerMesh The mesh to be center of explosion.
  114157. */
  114158. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  114159. private _setCenterMesh;
  114160. /**
  114161. * Get class name
  114162. * @returns "MeshExploder"
  114163. */
  114164. getClassName(): string;
  114165. /**
  114166. * "Exploded meshes"
  114167. * @returns Array of meshes with the centerMesh at index 0.
  114168. */
  114169. getMeshes(): Array<Mesh>;
  114170. /**
  114171. * Explodes meshes giving a specific direction
  114172. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  114173. */
  114174. explode(direction?: number): void;
  114175. }
  114176. }
  114177. declare module BABYLON {
  114178. /**
  114179. * Class used to help managing file picking and drag'n'drop
  114180. */
  114181. export class FilesInput {
  114182. /**
  114183. * List of files ready to be loaded
  114184. */
  114185. static readonly FilesToLoad: {
  114186. [key: string]: File;
  114187. };
  114188. /**
  114189. * Callback called when a file is processed
  114190. */
  114191. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  114192. private _engine;
  114193. private _currentScene;
  114194. private _sceneLoadedCallback;
  114195. private _progressCallback;
  114196. private _additionalRenderLoopLogicCallback;
  114197. private _textureLoadingCallback;
  114198. private _startingProcessingFilesCallback;
  114199. private _onReloadCallback;
  114200. private _errorCallback;
  114201. private _elementToMonitor;
  114202. private _sceneFileToLoad;
  114203. private _filesToLoad;
  114204. /**
  114205. * Creates a new FilesInput
  114206. * @param engine defines the rendering engine
  114207. * @param scene defines the hosting scene
  114208. * @param sceneLoadedCallback callback called when scene is loaded
  114209. * @param progressCallback callback called to track progress
  114210. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  114211. * @param textureLoadingCallback callback called when a texture is loading
  114212. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  114213. * @param onReloadCallback callback called when a reload is requested
  114214. * @param errorCallback callback call if an error occurs
  114215. */
  114216. 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);
  114217. private _dragEnterHandler;
  114218. private _dragOverHandler;
  114219. private _dropHandler;
  114220. /**
  114221. * Calls this function to listen to drag'n'drop events on a specific DOM element
  114222. * @param elementToMonitor defines the DOM element to track
  114223. */
  114224. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  114225. /**
  114226. * Release all associated resources
  114227. */
  114228. dispose(): void;
  114229. private renderFunction;
  114230. private drag;
  114231. private drop;
  114232. private _traverseFolder;
  114233. private _processFiles;
  114234. /**
  114235. * Load files from a drop event
  114236. * @param event defines the drop event to use as source
  114237. */
  114238. loadFiles(event: any): void;
  114239. private _processReload;
  114240. /**
  114241. * Reload the current scene from the loaded files
  114242. */
  114243. reload(): void;
  114244. }
  114245. }
  114246. declare module BABYLON {
  114247. /**
  114248. * Defines the root class used to create scene optimization to use with SceneOptimizer
  114249. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114250. */
  114251. export class SceneOptimization {
  114252. /**
  114253. * Defines the priority of this optimization (0 by default which means first in the list)
  114254. */
  114255. priority: number;
  114256. /**
  114257. * Gets a string describing the action executed by the current optimization
  114258. * @returns description string
  114259. */
  114260. getDescription(): string;
  114261. /**
  114262. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114263. * @param scene defines the current scene where to apply this optimization
  114264. * @param optimizer defines the current optimizer
  114265. * @returns true if everything that can be done was applied
  114266. */
  114267. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114268. /**
  114269. * Creates the SceneOptimization object
  114270. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114271. * @param desc defines the description associated with the optimization
  114272. */
  114273. constructor(
  114274. /**
  114275. * Defines the priority of this optimization (0 by default which means first in the list)
  114276. */
  114277. priority?: number);
  114278. }
  114279. /**
  114280. * Defines an optimization used to reduce the size of render target textures
  114281. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114282. */
  114283. export class TextureOptimization extends SceneOptimization {
  114284. /**
  114285. * Defines the priority of this optimization (0 by default which means first in the list)
  114286. */
  114287. priority: number;
  114288. /**
  114289. * 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
  114290. */
  114291. maximumSize: number;
  114292. /**
  114293. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114294. */
  114295. step: number;
  114296. /**
  114297. * Gets a string describing the action executed by the current optimization
  114298. * @returns description string
  114299. */
  114300. getDescription(): string;
  114301. /**
  114302. * Creates the TextureOptimization object
  114303. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114304. * @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
  114305. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114306. */
  114307. constructor(
  114308. /**
  114309. * Defines the priority of this optimization (0 by default which means first in the list)
  114310. */
  114311. priority?: number,
  114312. /**
  114313. * 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
  114314. */
  114315. maximumSize?: number,
  114316. /**
  114317. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114318. */
  114319. step?: number);
  114320. /**
  114321. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114322. * @param scene defines the current scene where to apply this optimization
  114323. * @param optimizer defines the current optimizer
  114324. * @returns true if everything that can be done was applied
  114325. */
  114326. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114327. }
  114328. /**
  114329. * Defines an optimization used to increase or decrease the rendering resolution
  114330. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114331. */
  114332. export class HardwareScalingOptimization extends SceneOptimization {
  114333. /**
  114334. * Defines the priority of this optimization (0 by default which means first in the list)
  114335. */
  114336. priority: number;
  114337. /**
  114338. * Defines the maximum scale to use (2 by default)
  114339. */
  114340. maximumScale: number;
  114341. /**
  114342. * Defines the step to use between two passes (0.5 by default)
  114343. */
  114344. step: number;
  114345. private _currentScale;
  114346. private _directionOffset;
  114347. /**
  114348. * Gets a string describing the action executed by the current optimization
  114349. * @return description string
  114350. */
  114351. getDescription(): string;
  114352. /**
  114353. * Creates the HardwareScalingOptimization object
  114354. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114355. * @param maximumScale defines the maximum scale to use (2 by default)
  114356. * @param step defines the step to use between two passes (0.5 by default)
  114357. */
  114358. constructor(
  114359. /**
  114360. * Defines the priority of this optimization (0 by default which means first in the list)
  114361. */
  114362. priority?: number,
  114363. /**
  114364. * Defines the maximum scale to use (2 by default)
  114365. */
  114366. maximumScale?: number,
  114367. /**
  114368. * Defines the step to use between two passes (0.5 by default)
  114369. */
  114370. step?: number);
  114371. /**
  114372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114373. * @param scene defines the current scene where to apply this optimization
  114374. * @param optimizer defines the current optimizer
  114375. * @returns true if everything that can be done was applied
  114376. */
  114377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114378. }
  114379. /**
  114380. * Defines an optimization used to remove shadows
  114381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114382. */
  114383. export class ShadowsOptimization extends SceneOptimization {
  114384. /**
  114385. * Gets a string describing the action executed by the current optimization
  114386. * @return description string
  114387. */
  114388. getDescription(): string;
  114389. /**
  114390. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114391. * @param scene defines the current scene where to apply this optimization
  114392. * @param optimizer defines the current optimizer
  114393. * @returns true if everything that can be done was applied
  114394. */
  114395. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114396. }
  114397. /**
  114398. * Defines an optimization used to turn post-processes off
  114399. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114400. */
  114401. export class PostProcessesOptimization extends SceneOptimization {
  114402. /**
  114403. * Gets a string describing the action executed by the current optimization
  114404. * @return description string
  114405. */
  114406. getDescription(): string;
  114407. /**
  114408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114409. * @param scene defines the current scene where to apply this optimization
  114410. * @param optimizer defines the current optimizer
  114411. * @returns true if everything that can be done was applied
  114412. */
  114413. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114414. }
  114415. /**
  114416. * Defines an optimization used to turn lens flares off
  114417. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114418. */
  114419. export class LensFlaresOptimization extends SceneOptimization {
  114420. /**
  114421. * Gets a string describing the action executed by the current optimization
  114422. * @return description string
  114423. */
  114424. getDescription(): string;
  114425. /**
  114426. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114427. * @param scene defines the current scene where to apply this optimization
  114428. * @param optimizer defines the current optimizer
  114429. * @returns true if everything that can be done was applied
  114430. */
  114431. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114432. }
  114433. /**
  114434. * Defines an optimization based on user defined callback.
  114435. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114436. */
  114437. export class CustomOptimization extends SceneOptimization {
  114438. /**
  114439. * Callback called to apply the custom optimization.
  114440. */
  114441. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  114442. /**
  114443. * Callback called to get custom description
  114444. */
  114445. onGetDescription: () => string;
  114446. /**
  114447. * Gets a string describing the action executed by the current optimization
  114448. * @returns description string
  114449. */
  114450. getDescription(): string;
  114451. /**
  114452. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114453. * @param scene defines the current scene where to apply this optimization
  114454. * @param optimizer defines the current optimizer
  114455. * @returns true if everything that can be done was applied
  114456. */
  114457. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114458. }
  114459. /**
  114460. * Defines an optimization used to turn particles off
  114461. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114462. */
  114463. export class ParticlesOptimization extends SceneOptimization {
  114464. /**
  114465. * Gets a string describing the action executed by the current optimization
  114466. * @return description string
  114467. */
  114468. getDescription(): string;
  114469. /**
  114470. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114471. * @param scene defines the current scene where to apply this optimization
  114472. * @param optimizer defines the current optimizer
  114473. * @returns true if everything that can be done was applied
  114474. */
  114475. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114476. }
  114477. /**
  114478. * Defines an optimization used to turn render targets off
  114479. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114480. */
  114481. export class RenderTargetsOptimization extends SceneOptimization {
  114482. /**
  114483. * Gets a string describing the action executed by the current optimization
  114484. * @return description string
  114485. */
  114486. getDescription(): string;
  114487. /**
  114488. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114489. * @param scene defines the current scene where to apply this optimization
  114490. * @param optimizer defines the current optimizer
  114491. * @returns true if everything that can be done was applied
  114492. */
  114493. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114494. }
  114495. /**
  114496. * Defines an optimization used to merge meshes with compatible materials
  114497. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114498. */
  114499. export class MergeMeshesOptimization extends SceneOptimization {
  114500. private static _UpdateSelectionTree;
  114501. /**
  114502. * Gets or sets a boolean which defines if optimization octree has to be updated
  114503. */
  114504. /**
  114505. * Gets or sets a boolean which defines if optimization octree has to be updated
  114506. */
  114507. static UpdateSelectionTree: boolean;
  114508. /**
  114509. * Gets a string describing the action executed by the current optimization
  114510. * @return description string
  114511. */
  114512. getDescription(): string;
  114513. private _canBeMerged;
  114514. /**
  114515. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114516. * @param scene defines the current scene where to apply this optimization
  114517. * @param optimizer defines the current optimizer
  114518. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  114519. * @returns true if everything that can be done was applied
  114520. */
  114521. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  114522. }
  114523. /**
  114524. * Defines a list of options used by SceneOptimizer
  114525. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114526. */
  114527. export class SceneOptimizerOptions {
  114528. /**
  114529. * Defines the target frame rate to reach (60 by default)
  114530. */
  114531. targetFrameRate: number;
  114532. /**
  114533. * Defines the interval between two checkes (2000ms by default)
  114534. */
  114535. trackerDuration: number;
  114536. /**
  114537. * Gets the list of optimizations to apply
  114538. */
  114539. optimizations: SceneOptimization[];
  114540. /**
  114541. * Creates a new list of options used by SceneOptimizer
  114542. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  114543. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  114544. */
  114545. constructor(
  114546. /**
  114547. * Defines the target frame rate to reach (60 by default)
  114548. */
  114549. targetFrameRate?: number,
  114550. /**
  114551. * Defines the interval between two checkes (2000ms by default)
  114552. */
  114553. trackerDuration?: number);
  114554. /**
  114555. * Add a new optimization
  114556. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  114557. * @returns the current SceneOptimizerOptions
  114558. */
  114559. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  114560. /**
  114561. * Add a new custom optimization
  114562. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  114563. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  114564. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114565. * @returns the current SceneOptimizerOptions
  114566. */
  114567. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  114568. /**
  114569. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  114570. * @param targetFrameRate defines the target frame rate (60 by default)
  114571. * @returns a SceneOptimizerOptions object
  114572. */
  114573. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  114574. /**
  114575. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  114576. * @param targetFrameRate defines the target frame rate (60 by default)
  114577. * @returns a SceneOptimizerOptions object
  114578. */
  114579. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  114580. /**
  114581. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  114582. * @param targetFrameRate defines the target frame rate (60 by default)
  114583. * @returns a SceneOptimizerOptions object
  114584. */
  114585. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  114586. }
  114587. /**
  114588. * Class used to run optimizations in order to reach a target frame rate
  114589. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114590. */
  114591. export class SceneOptimizer implements IDisposable {
  114592. private _isRunning;
  114593. private _options;
  114594. private _scene;
  114595. private _currentPriorityLevel;
  114596. private _targetFrameRate;
  114597. private _trackerDuration;
  114598. private _currentFrameRate;
  114599. private _sceneDisposeObserver;
  114600. private _improvementMode;
  114601. /**
  114602. * Defines an observable called when the optimizer reaches the target frame rate
  114603. */
  114604. onSuccessObservable: Observable<SceneOptimizer>;
  114605. /**
  114606. * Defines an observable called when the optimizer enables an optimization
  114607. */
  114608. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  114609. /**
  114610. * Defines an observable called when the optimizer is not able to reach the target frame rate
  114611. */
  114612. onFailureObservable: Observable<SceneOptimizer>;
  114613. /**
  114614. * Gets a boolean indicating if the optimizer is in improvement mode
  114615. */
  114616. readonly isInImprovementMode: boolean;
  114617. /**
  114618. * Gets the current priority level (0 at start)
  114619. */
  114620. readonly currentPriorityLevel: number;
  114621. /**
  114622. * Gets the current frame rate checked by the SceneOptimizer
  114623. */
  114624. readonly currentFrameRate: number;
  114625. /**
  114626. * Gets or sets the current target frame rate (60 by default)
  114627. */
  114628. /**
  114629. * Gets or sets the current target frame rate (60 by default)
  114630. */
  114631. targetFrameRate: number;
  114632. /**
  114633. * Gets or sets the current interval between two checks (every 2000ms by default)
  114634. */
  114635. /**
  114636. * Gets or sets the current interval between two checks (every 2000ms by default)
  114637. */
  114638. trackerDuration: number;
  114639. /**
  114640. * Gets the list of active optimizations
  114641. */
  114642. readonly optimizations: SceneOptimization[];
  114643. /**
  114644. * Creates a new SceneOptimizer
  114645. * @param scene defines the scene to work on
  114646. * @param options defines the options to use with the SceneOptimizer
  114647. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  114648. * @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)
  114649. */
  114650. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  114651. /**
  114652. * Stops the current optimizer
  114653. */
  114654. stop(): void;
  114655. /**
  114656. * Reset the optimizer to initial step (current priority level = 0)
  114657. */
  114658. reset(): void;
  114659. /**
  114660. * Start the optimizer. By default it will try to reach a specific framerate
  114661. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  114662. */
  114663. start(): void;
  114664. private _checkCurrentState;
  114665. /**
  114666. * Release all resources
  114667. */
  114668. dispose(): void;
  114669. /**
  114670. * Helper function to create a SceneOptimizer with one single line of code
  114671. * @param scene defines the scene to work on
  114672. * @param options defines the options to use with the SceneOptimizer
  114673. * @param onSuccess defines a callback to call on success
  114674. * @param onFailure defines a callback to call on failure
  114675. * @returns the new SceneOptimizer object
  114676. */
  114677. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  114678. }
  114679. }
  114680. declare module BABYLON {
  114681. /**
  114682. * Class used to serialize a scene into a string
  114683. */
  114684. export class SceneSerializer {
  114685. /**
  114686. * Clear cache used by a previous serialization
  114687. */
  114688. static ClearCache(): void;
  114689. /**
  114690. * Serialize a scene into a JSON compatible object
  114691. * @param scene defines the scene to serialize
  114692. * @returns a JSON compatible object
  114693. */
  114694. static Serialize(scene: Scene): any;
  114695. /**
  114696. * Serialize a mesh into a JSON compatible object
  114697. * @param toSerialize defines the mesh to serialize
  114698. * @param withParents defines if parents must be serialized as well
  114699. * @param withChildren defines if children must be serialized as well
  114700. * @returns a JSON compatible object
  114701. */
  114702. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  114703. }
  114704. }
  114705. declare module BABYLON {
  114706. /**
  114707. * Class used to host texture specific utilities
  114708. */
  114709. export class TextureTools {
  114710. /**
  114711. * Uses the GPU to create a copy texture rescaled at a given size
  114712. * @param texture Texture to copy from
  114713. * @param width defines the desired width
  114714. * @param height defines the desired height
  114715. * @param useBilinearMode defines if bilinear mode has to be used
  114716. * @return the generated texture
  114717. */
  114718. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  114719. }
  114720. }
  114721. declare module BABYLON {
  114722. /**
  114723. * This represents the different options avilable for the video capture.
  114724. */
  114725. export interface VideoRecorderOptions {
  114726. /** Defines the mime type of the video */
  114727. mimeType: string;
  114728. /** Defines the video the video should be recorded at */
  114729. fps: number;
  114730. /** Defines the chunk size for the recording data */
  114731. recordChunckSize: number;
  114732. /** The audio tracks to attach to the record */
  114733. audioTracks?: MediaStreamTrack[];
  114734. }
  114735. /**
  114736. * This can helps recording videos from BabylonJS.
  114737. * This is based on the available WebRTC functionalities of the browser.
  114738. *
  114739. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  114740. */
  114741. export class VideoRecorder {
  114742. private static readonly _defaultOptions;
  114743. /**
  114744. * Returns wehther or not the VideoRecorder is available in your browser.
  114745. * @param engine Defines the Babylon Engine to check the support for
  114746. * @returns true if supported otherwise false
  114747. */
  114748. static IsSupported(engine: Engine): boolean;
  114749. private readonly _options;
  114750. private _canvas;
  114751. private _mediaRecorder;
  114752. private _recordedChunks;
  114753. private _fileName;
  114754. private _resolve;
  114755. private _reject;
  114756. /**
  114757. * True wether a recording is already in progress.
  114758. */
  114759. readonly isRecording: boolean;
  114760. /**
  114761. * Create a new VideoCapture object which can help converting what you see in Babylon to
  114762. * a video file.
  114763. * @param engine Defines the BabylonJS Engine you wish to record
  114764. * @param options Defines options that can be used to customized the capture
  114765. */
  114766. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  114767. /**
  114768. * Stops the current recording before the default capture timeout passed in the startRecording
  114769. * functions.
  114770. */
  114771. stopRecording(): void;
  114772. /**
  114773. * Starts recording the canvas for a max duration specified in parameters.
  114774. * @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.
  114775. * @param maxDuration Defines the maximum recording time in seconds.
  114776. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  114777. * @return a promise callback at the end of the recording with the video data in Blob.
  114778. */
  114779. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  114780. /**
  114781. * Releases internal resources used during the recording.
  114782. */
  114783. dispose(): void;
  114784. private _handleDataAvailable;
  114785. private _handleError;
  114786. private _handleStop;
  114787. }
  114788. }
  114789. declare module BABYLON {
  114790. /**
  114791. * Helper class to push actions to a pool of workers.
  114792. */
  114793. export class WorkerPool implements IDisposable {
  114794. private _workerInfos;
  114795. private _pendingActions;
  114796. /**
  114797. * Constructor
  114798. * @param workers Array of workers to use for actions
  114799. */
  114800. constructor(workers: Array<Worker>);
  114801. /**
  114802. * Terminates all workers and clears any pending actions.
  114803. */
  114804. dispose(): void;
  114805. /**
  114806. * Pushes an action to the worker pool. If all the workers are active, the action will be
  114807. * pended until a worker has completed its action.
  114808. * @param action The action to perform. Call onComplete when the action is complete.
  114809. */
  114810. push(action: (worker: Worker, onComplete: () => void) => void): void;
  114811. private _execute;
  114812. }
  114813. }
  114814. declare module BABYLON {
  114815. /**
  114816. * Class containing a set of static utilities functions for screenshots
  114817. */
  114818. export class ScreenshotTools {
  114819. /**
  114820. * Captures a screenshot of the current rendering
  114821. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114822. * @param engine defines the rendering engine
  114823. * @param camera defines the source camera
  114824. * @param size This parameter can be set to a single number or to an object with the
  114825. * following (optional) properties: precision, width, height. If a single number is passed,
  114826. * it will be used for both width and height. If an object is passed, the screenshot size
  114827. * will be derived from the parameters. The precision property is a multiplier allowing
  114828. * rendering at a higher or lower resolution
  114829. * @param successCallback defines the callback receives a single parameter which contains the
  114830. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114831. * src parameter of an <img> to display it
  114832. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114833. * Check your browser for supported MIME types
  114834. */
  114835. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  114836. /**
  114837. * Generates an image screenshot from the specified camera.
  114838. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114839. * @param engine The engine to use for rendering
  114840. * @param camera The camera to use for rendering
  114841. * @param size This parameter can be set to a single number or to an object with the
  114842. * following (optional) properties: precision, width, height. If a single number is passed,
  114843. * it will be used for both width and height. If an object is passed, the screenshot size
  114844. * will be derived from the parameters. The precision property is a multiplier allowing
  114845. * rendering at a higher or lower resolution
  114846. * @param successCallback The callback receives a single parameter which contains the
  114847. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114848. * src parameter of an <img> to display it
  114849. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114850. * Check your browser for supported MIME types
  114851. * @param samples Texture samples (default: 1)
  114852. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114853. * @param fileName A name for for the downloaded file.
  114854. */
  114855. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  114856. }
  114857. }
  114858. declare module BABYLON {
  114859. /**
  114860. * A cursor which tracks a point on a path
  114861. */
  114862. export class PathCursor {
  114863. private path;
  114864. /**
  114865. * Stores path cursor callbacks for when an onchange event is triggered
  114866. */
  114867. private _onchange;
  114868. /**
  114869. * The value of the path cursor
  114870. */
  114871. value: number;
  114872. /**
  114873. * The animation array of the path cursor
  114874. */
  114875. animations: Animation[];
  114876. /**
  114877. * Initializes the path cursor
  114878. * @param path The path to track
  114879. */
  114880. constructor(path: Path2);
  114881. /**
  114882. * Gets the cursor point on the path
  114883. * @returns A point on the path cursor at the cursor location
  114884. */
  114885. getPoint(): Vector3;
  114886. /**
  114887. * Moves the cursor ahead by the step amount
  114888. * @param step The amount to move the cursor forward
  114889. * @returns This path cursor
  114890. */
  114891. moveAhead(step?: number): PathCursor;
  114892. /**
  114893. * Moves the cursor behind by the step amount
  114894. * @param step The amount to move the cursor back
  114895. * @returns This path cursor
  114896. */
  114897. moveBack(step?: number): PathCursor;
  114898. /**
  114899. * Moves the cursor by the step amount
  114900. * If the step amount is greater than one, an exception is thrown
  114901. * @param step The amount to move the cursor
  114902. * @returns This path cursor
  114903. */
  114904. move(step: number): PathCursor;
  114905. /**
  114906. * Ensures that the value is limited between zero and one
  114907. * @returns This path cursor
  114908. */
  114909. private ensureLimits;
  114910. /**
  114911. * Runs onchange callbacks on change (used by the animation engine)
  114912. * @returns This path cursor
  114913. */
  114914. private raiseOnChange;
  114915. /**
  114916. * Executes a function on change
  114917. * @param f A path cursor onchange callback
  114918. * @returns This path cursor
  114919. */
  114920. onchange(f: (cursor: PathCursor) => void): PathCursor;
  114921. }
  114922. }
  114923. declare module BABYLON {
  114924. /** @hidden */
  114925. export var blurPixelShader: {
  114926. name: string;
  114927. shader: string;
  114928. };
  114929. }
  114930. declare module BABYLON {
  114931. /** @hidden */
  114932. export var bones300Declaration: {
  114933. name: string;
  114934. shader: string;
  114935. };
  114936. }
  114937. declare module BABYLON {
  114938. /** @hidden */
  114939. export var instances300Declaration: {
  114940. name: string;
  114941. shader: string;
  114942. };
  114943. }
  114944. declare module BABYLON {
  114945. /** @hidden */
  114946. export var pointCloudVertexDeclaration: {
  114947. name: string;
  114948. shader: string;
  114949. };
  114950. }
  114951. // Mixins
  114952. interface Window {
  114953. mozIndexedDB: IDBFactory;
  114954. webkitIndexedDB: IDBFactory;
  114955. msIndexedDB: IDBFactory;
  114956. webkitURL: typeof URL;
  114957. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  114958. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  114959. WebGLRenderingContext: WebGLRenderingContext;
  114960. MSGesture: MSGesture;
  114961. CANNON: any;
  114962. AudioContext: AudioContext;
  114963. webkitAudioContext: AudioContext;
  114964. PointerEvent: any;
  114965. Math: Math;
  114966. Uint8Array: Uint8ArrayConstructor;
  114967. Float32Array: Float32ArrayConstructor;
  114968. mozURL: typeof URL;
  114969. msURL: typeof URL;
  114970. VRFrameData: any; // WebVR, from specs 1.1
  114971. DracoDecoderModule: any;
  114972. setImmediate(handler: (...args: any[]) => void): number;
  114973. }
  114974. interface HTMLCanvasElement {
  114975. requestPointerLock(): void;
  114976. msRequestPointerLock?(): void;
  114977. mozRequestPointerLock?(): void;
  114978. webkitRequestPointerLock?(): void;
  114979. /** Track wether a record is in progress */
  114980. isRecording: boolean;
  114981. /** Capture Stream method defined by some browsers */
  114982. captureStream(fps?: number): MediaStream;
  114983. }
  114984. interface CanvasRenderingContext2D {
  114985. msImageSmoothingEnabled: boolean;
  114986. }
  114987. interface MouseEvent {
  114988. mozMovementX: number;
  114989. mozMovementY: number;
  114990. webkitMovementX: number;
  114991. webkitMovementY: number;
  114992. msMovementX: number;
  114993. msMovementY: number;
  114994. }
  114995. interface Navigator {
  114996. mozGetVRDevices: (any: any) => any;
  114997. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  114998. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  114999. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115000. webkitGetGamepads(): Gamepad[];
  115001. msGetGamepads(): Gamepad[];
  115002. webkitGamepads(): Gamepad[];
  115003. }
  115004. interface HTMLVideoElement {
  115005. mozSrcObject: any;
  115006. }
  115007. interface Math {
  115008. fround(x: number): number;
  115009. imul(a: number, b: number): number;
  115010. }
  115011. interface WebGLProgram {
  115012. context?: WebGLRenderingContext;
  115013. vertexShader?: WebGLShader;
  115014. fragmentShader?: WebGLShader;
  115015. isParallelCompiled: boolean;
  115016. onCompiled?: () => void;
  115017. }
  115018. interface WebGLRenderingContext {
  115019. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  115020. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  115021. vertexAttribDivisor(index: number, divisor: number): void;
  115022. createVertexArray(): any;
  115023. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  115024. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  115025. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  115026. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  115027. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  115028. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  115029. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  115030. // Queries
  115031. createQuery(): WebGLQuery;
  115032. deleteQuery(query: WebGLQuery): void;
  115033. beginQuery(target: number, query: WebGLQuery): void;
  115034. endQuery(target: number): void;
  115035. getQueryParameter(query: WebGLQuery, pname: number): any;
  115036. getQuery(target: number, pname: number): any;
  115037. MAX_SAMPLES: number;
  115038. RGBA8: number;
  115039. READ_FRAMEBUFFER: number;
  115040. DRAW_FRAMEBUFFER: number;
  115041. UNIFORM_BUFFER: number;
  115042. HALF_FLOAT_OES: number;
  115043. RGBA16F: number;
  115044. RGBA32F: number;
  115045. R32F: number;
  115046. RG32F: number;
  115047. RGB32F: number;
  115048. R16F: number;
  115049. RG16F: number;
  115050. RGB16F: number;
  115051. RED: number;
  115052. RG: number;
  115053. R8: number;
  115054. RG8: number;
  115055. UNSIGNED_INT_24_8: number;
  115056. DEPTH24_STENCIL8: number;
  115057. /* Multiple Render Targets */
  115058. drawBuffers(buffers: number[]): void;
  115059. readBuffer(src: number): void;
  115060. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  115061. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  115062. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  115063. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  115064. // Occlusion Query
  115065. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  115066. ANY_SAMPLES_PASSED: number;
  115067. QUERY_RESULT_AVAILABLE: number;
  115068. QUERY_RESULT: number;
  115069. }
  115070. interface WebGLBuffer {
  115071. references: number;
  115072. capacity: number;
  115073. is32Bits: boolean;
  115074. }
  115075. interface WebGLProgram {
  115076. transformFeedback?: WebGLTransformFeedback | null;
  115077. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  115078. }
  115079. interface EXT_disjoint_timer_query {
  115080. QUERY_COUNTER_BITS_EXT: number;
  115081. TIME_ELAPSED_EXT: number;
  115082. TIMESTAMP_EXT: number;
  115083. GPU_DISJOINT_EXT: number;
  115084. QUERY_RESULT_EXT: number;
  115085. QUERY_RESULT_AVAILABLE_EXT: number;
  115086. queryCounterEXT(query: WebGLQuery, target: number): void;
  115087. createQueryEXT(): WebGLQuery;
  115088. beginQueryEXT(target: number, query: WebGLQuery): void;
  115089. endQueryEXT(target: number): void;
  115090. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  115091. deleteQueryEXT(query: WebGLQuery): void;
  115092. }
  115093. interface WebGLUniformLocation {
  115094. _currentState: any;
  115095. }
  115096. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  115097. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  115098. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  115099. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115100. interface WebGLRenderingContext {
  115101. readonly RASTERIZER_DISCARD: number;
  115102. readonly DEPTH_COMPONENT24: number;
  115103. readonly TEXTURE_3D: number;
  115104. readonly TEXTURE_2D_ARRAY: number;
  115105. readonly TEXTURE_COMPARE_FUNC: number;
  115106. readonly TEXTURE_COMPARE_MODE: number;
  115107. readonly COMPARE_REF_TO_TEXTURE: number;
  115108. readonly TEXTURE_WRAP_R: number;
  115109. readonly HALF_FLOAT: number;
  115110. readonly RGB8: number;
  115111. readonly RED_INTEGER: number;
  115112. readonly RG_INTEGER: number;
  115113. readonly RGB_INTEGER: number;
  115114. readonly RGBA_INTEGER: number;
  115115. readonly R8_SNORM: number;
  115116. readonly RG8_SNORM: number;
  115117. readonly RGB8_SNORM: number;
  115118. readonly RGBA8_SNORM: number;
  115119. readonly R8I: number;
  115120. readonly RG8I: number;
  115121. readonly RGB8I: number;
  115122. readonly RGBA8I: number;
  115123. readonly R8UI: number;
  115124. readonly RG8UI: number;
  115125. readonly RGB8UI: number;
  115126. readonly RGBA8UI: number;
  115127. readonly R16I: number;
  115128. readonly RG16I: number;
  115129. readonly RGB16I: number;
  115130. readonly RGBA16I: number;
  115131. readonly R16UI: number;
  115132. readonly RG16UI: number;
  115133. readonly RGB16UI: number;
  115134. readonly RGBA16UI: number;
  115135. readonly R32I: number;
  115136. readonly RG32I: number;
  115137. readonly RGB32I: number;
  115138. readonly RGBA32I: number;
  115139. readonly R32UI: number;
  115140. readonly RG32UI: number;
  115141. readonly RGB32UI: number;
  115142. readonly RGBA32UI: number;
  115143. readonly RGB10_A2UI: number;
  115144. readonly R11F_G11F_B10F: number;
  115145. readonly RGB9_E5: number;
  115146. readonly RGB10_A2: number;
  115147. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  115148. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  115149. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  115150. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  115151. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  115152. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  115153. 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;
  115154. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  115155. readonly TRANSFORM_FEEDBACK: number;
  115156. readonly INTERLEAVED_ATTRIBS: number;
  115157. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  115158. createTransformFeedback(): WebGLTransformFeedback;
  115159. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  115160. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  115161. beginTransformFeedback(primitiveMode: number): void;
  115162. endTransformFeedback(): void;
  115163. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  115164. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115165. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115166. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115167. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  115168. }
  115169. interface ImageBitmap {
  115170. readonly width: number;
  115171. readonly height: number;
  115172. close(): void;
  115173. }
  115174. interface WebGLQuery extends WebGLObject {
  115175. }
  115176. declare var WebGLQuery: {
  115177. prototype: WebGLQuery;
  115178. new(): WebGLQuery;
  115179. };
  115180. interface WebGLSampler extends WebGLObject {
  115181. }
  115182. declare var WebGLSampler: {
  115183. prototype: WebGLSampler;
  115184. new(): WebGLSampler;
  115185. };
  115186. interface WebGLSync extends WebGLObject {
  115187. }
  115188. declare var WebGLSync: {
  115189. prototype: WebGLSync;
  115190. new(): WebGLSync;
  115191. };
  115192. interface WebGLTransformFeedback extends WebGLObject {
  115193. }
  115194. declare var WebGLTransformFeedback: {
  115195. prototype: WebGLTransformFeedback;
  115196. new(): WebGLTransformFeedback;
  115197. };
  115198. interface WebGLVertexArrayObject extends WebGLObject {
  115199. }
  115200. declare var WebGLVertexArrayObject: {
  115201. prototype: WebGLVertexArrayObject;
  115202. new(): WebGLVertexArrayObject;
  115203. };
  115204. // Type definitions for WebVR API
  115205. // Project: https://w3c.github.io/webvr/
  115206. // Definitions by: six a <https://github.com/lostfictions>
  115207. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115208. interface VRDisplay extends EventTarget {
  115209. /**
  115210. * Dictionary of capabilities describing the VRDisplay.
  115211. */
  115212. readonly capabilities: VRDisplayCapabilities;
  115213. /**
  115214. * z-depth defining the far plane of the eye view frustum
  115215. * enables mapping of values in the render target depth
  115216. * attachment to scene coordinates. Initially set to 10000.0.
  115217. */
  115218. depthFar: number;
  115219. /**
  115220. * z-depth defining the near plane of the eye view frustum
  115221. * enables mapping of values in the render target depth
  115222. * attachment to scene coordinates. Initially set to 0.01.
  115223. */
  115224. depthNear: number;
  115225. /**
  115226. * An identifier for this distinct VRDisplay. Used as an
  115227. * association point in the Gamepad API.
  115228. */
  115229. readonly displayId: number;
  115230. /**
  115231. * A display name, a user-readable name identifying it.
  115232. */
  115233. readonly displayName: string;
  115234. readonly isConnected: boolean;
  115235. readonly isPresenting: boolean;
  115236. /**
  115237. * If this VRDisplay supports room-scale experiences, the optional
  115238. * stage attribute contains details on the room-scale parameters.
  115239. */
  115240. readonly stageParameters: VRStageParameters | null;
  115241. /**
  115242. * Passing the value returned by `requestAnimationFrame` to
  115243. * `cancelAnimationFrame` will unregister the callback.
  115244. * @param handle Define the hanle of the request to cancel
  115245. */
  115246. cancelAnimationFrame(handle: number): void;
  115247. /**
  115248. * Stops presenting to the VRDisplay.
  115249. * @returns a promise to know when it stopped
  115250. */
  115251. exitPresent(): Promise<void>;
  115252. /**
  115253. * Return the current VREyeParameters for the given eye.
  115254. * @param whichEye Define the eye we want the parameter for
  115255. * @returns the eye parameters
  115256. */
  115257. getEyeParameters(whichEye: string): VREyeParameters;
  115258. /**
  115259. * Populates the passed VRFrameData with the information required to render
  115260. * the current frame.
  115261. * @param frameData Define the data structure to populate
  115262. * @returns true if ok otherwise false
  115263. */
  115264. getFrameData(frameData: VRFrameData): boolean;
  115265. /**
  115266. * Get the layers currently being presented.
  115267. * @returns the list of VR layers
  115268. */
  115269. getLayers(): VRLayer[];
  115270. /**
  115271. * Return a VRPose containing the future predicted pose of the VRDisplay
  115272. * when the current frame will be presented. The value returned will not
  115273. * change until JavaScript has returned control to the browser.
  115274. *
  115275. * The VRPose will contain the position, orientation, velocity,
  115276. * and acceleration of each of these properties.
  115277. * @returns the pose object
  115278. */
  115279. getPose(): VRPose;
  115280. /**
  115281. * Return the current instantaneous pose of the VRDisplay, with no
  115282. * prediction applied.
  115283. * @returns the current instantaneous pose
  115284. */
  115285. getImmediatePose(): VRPose;
  115286. /**
  115287. * The callback passed to `requestAnimationFrame` will be called
  115288. * any time a new frame should be rendered. When the VRDisplay is
  115289. * presenting the callback will be called at the native refresh
  115290. * rate of the HMD. When not presenting this function acts
  115291. * identically to how window.requestAnimationFrame acts. Content should
  115292. * make no assumptions of frame rate or vsync behavior as the HMD runs
  115293. * asynchronously from other displays and at differing refresh rates.
  115294. * @param callback Define the eaction to run next frame
  115295. * @returns the request handle it
  115296. */
  115297. requestAnimationFrame(callback: FrameRequestCallback): number;
  115298. /**
  115299. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  115300. * Repeat calls while already presenting will update the VRLayers being displayed.
  115301. * @param layers Define the list of layer to present
  115302. * @returns a promise to know when the request has been fulfilled
  115303. */
  115304. requestPresent(layers: VRLayer[]): Promise<void>;
  115305. /**
  115306. * Reset the pose for this display, treating its current position and
  115307. * orientation as the "origin/zero" values. VRPose.position,
  115308. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  115309. * updated when calling resetPose(). This should be called in only
  115310. * sitting-space experiences.
  115311. */
  115312. resetPose(): void;
  115313. /**
  115314. * The VRLayer provided to the VRDisplay will be captured and presented
  115315. * in the HMD. Calling this function has the same effect on the source
  115316. * canvas as any other operation that uses its source image, and canvases
  115317. * created without preserveDrawingBuffer set to true will be cleared.
  115318. * @param pose Define the pose to submit
  115319. */
  115320. submitFrame(pose?: VRPose): void;
  115321. }
  115322. declare var VRDisplay: {
  115323. prototype: VRDisplay;
  115324. new(): VRDisplay;
  115325. };
  115326. interface VRLayer {
  115327. leftBounds?: number[] | Float32Array | null;
  115328. rightBounds?: number[] | Float32Array | null;
  115329. source?: HTMLCanvasElement | null;
  115330. }
  115331. interface VRDisplayCapabilities {
  115332. readonly canPresent: boolean;
  115333. readonly hasExternalDisplay: boolean;
  115334. readonly hasOrientation: boolean;
  115335. readonly hasPosition: boolean;
  115336. readonly maxLayers: number;
  115337. }
  115338. interface VREyeParameters {
  115339. /** @deprecated */
  115340. readonly fieldOfView: VRFieldOfView;
  115341. readonly offset: Float32Array;
  115342. readonly renderHeight: number;
  115343. readonly renderWidth: number;
  115344. }
  115345. interface VRFieldOfView {
  115346. readonly downDegrees: number;
  115347. readonly leftDegrees: number;
  115348. readonly rightDegrees: number;
  115349. readonly upDegrees: number;
  115350. }
  115351. interface VRFrameData {
  115352. readonly leftProjectionMatrix: Float32Array;
  115353. readonly leftViewMatrix: Float32Array;
  115354. readonly pose: VRPose;
  115355. readonly rightProjectionMatrix: Float32Array;
  115356. readonly rightViewMatrix: Float32Array;
  115357. readonly timestamp: number;
  115358. }
  115359. interface VRPose {
  115360. readonly angularAcceleration: Float32Array | null;
  115361. readonly angularVelocity: Float32Array | null;
  115362. readonly linearAcceleration: Float32Array | null;
  115363. readonly linearVelocity: Float32Array | null;
  115364. readonly orientation: Float32Array | null;
  115365. readonly position: Float32Array | null;
  115366. readonly timestamp: number;
  115367. }
  115368. interface VRStageParameters {
  115369. sittingToStandingTransform?: Float32Array;
  115370. sizeX?: number;
  115371. sizeY?: number;
  115372. }
  115373. interface Navigator {
  115374. getVRDisplays(): Promise<VRDisplay[]>;
  115375. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  115376. }
  115377. interface Window {
  115378. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  115379. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  115380. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  115381. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115382. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115383. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  115384. }
  115385. interface Gamepad {
  115386. readonly displayId: number;
  115387. }
  115388. interface XRDevice {
  115389. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  115390. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  115391. }
  115392. interface XRSession {
  115393. getInputSources(): Array<any>;
  115394. baseLayer: XRWebGLLayer;
  115395. requestFrameOfReference(type: string): Promise<void>;
  115396. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  115397. end(): Promise<void>;
  115398. requestAnimationFrame: Function;
  115399. addEventListener: Function;
  115400. }
  115401. interface XRSessionCreationOptions {
  115402. outputContext?: WebGLRenderingContext | null;
  115403. immersive?: boolean;
  115404. environmentIntegration?: boolean;
  115405. }
  115406. interface XRLayer {
  115407. getViewport: Function;
  115408. framebufferWidth: number;
  115409. framebufferHeight: number;
  115410. }
  115411. interface XRView {
  115412. projectionMatrix: Float32Array;
  115413. }
  115414. interface XRFrame {
  115415. getDevicePose: Function;
  115416. getInputPose: Function;
  115417. views: Array<XRView>;
  115418. baseLayer: XRLayer;
  115419. }
  115420. interface XRFrameOfReference {
  115421. }
  115422. interface XRWebGLLayer extends XRLayer {
  115423. framebuffer: WebGLFramebuffer;
  115424. }
  115425. declare var XRWebGLLayer: {
  115426. prototype: XRWebGLLayer;
  115427. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  115428. };